Annotation of 43BSDReno/bin/adb/common_source/defs.h, revision 1.1.1.1

1.1       root        1: /*     @(#)defs.h      5.4 (Berkeley) 2/20/90  */
                      2: 
                      3: /*
                      4:  * adb: common definitions
                      5:  */
                      6: 
                      7: #include <sys/param.h>
                      8: #include <sys/user.h>
                      9: 
                     10: #include <a.out.h>
                     11: 
                     12: /* machine dependent types and definitions */
                     13: #include "machdep.h"
                     14: 
                     15: /*
                     16:  * Signals.  Adb catches SIGINT and SIGQUIT; the variables sigint and
                     17:  * sigquit hold the original state for adb's children.
                     18:  */
                     19: sig_t  sigint;                 /* original SIGINT state */
                     20: sig_t  sigquit;                /* original SIGQUIT state */
                     21: sig_t  intcatch;               /* interrupt catch routine, or SIG_IGN */
                     22: 
                     23: /*
                     24:  * Address spaces.  We distinguish only between instruction & data.
                     25:  * The spaces NONE, INSTR, and DATA (without the STAR flag) are also used
                     26:  * to tag symbols.
                     27:  */
                     28: #define        SP_NONE         0       /* not in any space, just a number */
                     29: #define        SP_INSTR        1       /* instruction space */
                     30: #define        SP_DATA         2       /* data space */
                     31: #define        SP_STAR         4       /* or'ed in; see below */
                     32: 
                     33: /*
                     34:  * The symbol and core files.
                     35:  */
                     36: struct {
                     37:        char    *name;          /* file name */
                     38:        int     fd;             /* and descriptor */
                     39: } symfile, corefile;
                     40: 
                     41: /*
                     42:  * File address maps.
                     43:  */
                     44: struct m1 {
                     45:        addr_t  b;              /* begins at b */
                     46:        addr_t  e;              /* ends at e */
                     47:        addr_t  f;              /* with offset f */
                     48: };
                     49: struct map {
                     50:        struct  m1 m1;          /* regular map */
                     51:        struct  m1 m2;          /* `star' (alternate) map */
                     52:        int     ufd;            /* unix file descriptor */
                     53: };
                     54: 
                     55: struct map txtmap;             /* the `?' or text file */
                     56: struct map datmap;             /* the `/' or data/core file */
                     57: 
                     58: /*
                     59:  * Program and file I/O.
                     60:  */
                     61: enum rwmode { RWMODE_READ, RWMODE_WRITE };
                     62: #define        adbread(space, rmtaddr, localaddr, nbytes) \
                     63:        adbio(RWMODE_READ, space, rmtaddr, (caddr_t)(localaddr), nbytes)
                     64: #define        adbwrite(space, rmtaddr, localaddr, nbytes) \
                     65:        adbio(RWMODE_WRITE, space, rmtaddr, (caddr_t)(localaddr), nbytes)
                     66: 
                     67: addr_t vtophys();              /* -k: kernel virtual addr to physical */
                     68: 
                     69: /*
                     70:  * Errors.  errflag should be set to point to the error message when
                     71:  * an error occurs.  error(s) sets errflag to s and jumps back
                     72:  * to the main loop via longjmp().  In some places this is unsafe
                     73:  * or undesirable, and instead errflag is set directly; checkerr()
                     74:  * can be used to test (and jump on) for such errors later.
                     75:  *
                     76:  * mkfault creates a `generic' error after a keyboard interrupt.
                     77:  *
                     78:  * Various error strings are defined in message.c and referenced
                     79:  * through names below.
                     80:  */
                     81: char   *errflag;               /* the error, or NULL */
                     82: int    mkfault;                /* interrupted; pretend an error */
                     83: 
                     84: #define        iserr() (errflag || mkfault)
                     85: #define        checkerr() \
                     86:        if (!iserr()) \
                     87:                /* void */; \
                     88:        else \
                     89:                error(errflag)
                     90: /* if checkerr() above is undefined, a function version is used instead */
                     91: 
                     92: /*
                     93:  * Locations.
                     94:  *
                     95:  * HSZ and FSZ are defined here as the sizes of `half' and `full' words
                     96:  * respectively.  While these are not `locations', they are commonly used
                     97:  * to set the value of dotinc.
                     98:  */
                     99: int    gavedot;                /* true iff this command set dot */
                    100: addr_t dot;                    /* current location; but see also edot */
                    101: addr_t ditto;                  /* previous dot */
                    102: int    dotinc;                 /* size of last object examined */
                    103: 
                    104: extern char ADDRWRAP[];        /* "address wrap around" */
                    105: 
                    106: /* compute dot+offset, checking for overflow */
                    107: #define        inkdot(o) (ADDRESS_WRAP(dot, dot+(o)) ? error(ADDRWRAP), 0 : dot+(o))
                    108: /* if inkdot() above is undefined, a function version is used instead */
                    109: 
                    110: /*
                    111:  * Expressions.
                    112:  *
                    113:  * oexpr() evaluates an optional expression; rexpr() does a required
                    114:  * expression, and returns expv as a convenience.
                    115:  *
                    116:  * N.B.: edot is valid only if gavedot.
                    117:  */
                    118: int    oexpr();                /* returns 1 if found expr, else 0 */
                    119: expr_t rexpr();                /* aborts if no expression found */
                    120: 
                    121: expr_t edot;                   /* dot as an expression (possibly more bits) */
                    122: int    gavecount;              /* true iff this command gave a count */
                    123: expr_t ecount;                 /* repeat count from addr,count format */
                    124: expr_t expv;                   /* value from last expression */
                    125: expr_t var[36];                /* adb's 36 variables (0..9 then a..z) */
                    126: 
                    127: /*
                    128:  * Input.
                    129:  *
                    130:  * The global lp points to the current input line.  The routine
                    131:  * readchar() picks up the next character, incrementing lp, but
                    132:  * can read more if appropriate.  lastc retains the most recently
                    133:  * read character.  unreadc() in effect `puts back' lastc.  rdc()
                    134:  * is like readchar() but skips white space.
                    135:  */
                    136: char   *lp;                    /* pointer into current line */
                    137: int    lastc;                  /* character most recently read */
                    138: int    readchar();             /* get the next char */
                    139: int    rdc();                  /* get the next nonblank char */
                    140: #ifndef lint
                    141: #define        unreadc()       (lastc ? lp-- : 0)
                    142: #else
                    143: #define        unreadc()       (lp--)
                    144: #endif
                    145: #ifndef lint
                    146: #define        readchar()      (((lastc = *lp) == 0 ? 0 : lp++), lastc)
                    147: #endif
                    148: /* if readchar() above is undefined, a function version is used instead */
                    149: #define        eol(c)          ((c) == '\n' || (c) == ';')
                    150: 
                    151: /*
                    152:  * Miscellaneous globals, functions, and macros.
                    153:  */
                    154: int    kernel;                 /* debugging kernel (-k flag) */
                    155: int    kcore;                  /* have a post-mortem dump (-k + core) */
                    156: int    wtflag;                 /* adb => 0, adb -w => 2 */
                    157: int    radix;                  /* current radix (input and %r/%R formats) */
                    158: int    pid;                    /* process id being debugged, or 0 */
                    159: int    signo;                  /* signal that stopped process pid */
                    160: int    sigcode;                /* extension info (machine dependent) */
                    161: 
                    162: addr_t maxoff;                 /* max offset for symbol match ($s) */
                    163: #define        MAXOFF  1024            /* default value */
                    164: 
                    165: int    maxcol;                 /* max output column ($w) */
                    166: #define        MAXCOL  80              /* default value */
                    167: 
                    168: #define        LINELEN 1024            /* max input line length */
                    169: #define        SYMLEN  1024            /* max symbol length */
                    170: 
                    171: int    errno;                  /* our old friend */
                    172: 
                    173: /*
                    174:  * checkfloat() returns an error string if a float or double is
                    175:  * some sort of reserved bit pattern, such that trying to print it
                    176:  * would cause a fault.  It is called with the address of the
                    177:  * float or double, and a 0 or 1 to indicate float and double
                    178:  * respectively.  checkfloat() returns NULL if the number is printable.
                    179:  */
                    180: char   *checkfloat();          /* check a float or double for correctness */
                    181: 
                    182: struct reglist *reglookup();   /* find a register by name */
                    183: 
                    184: struct nlist *lookup();                /* look up a symbol */
                    185: struct nlist *findsym();       /* like lookup, but allows an offset */
                    186: struct nlist *nextlocal();     /* given a sym, return the next local sym */
                    187: 
                    188: struct nlist *symtab;          /* symbol table */
                    189: struct nlist *esymtab;         /* end of symtab */
                    190: 
                    191: expr_t getreg();               /* returns the value in a register */
                    192: 
                    193: addr_t eval_localsym();        /* compute the address of a local symbol */
                    194: 
                    195: /*
                    196:  * eqstr(a, b) is true iff the given strings compare equal.
                    197:  * eqsym(a, b, c) is true if symbols a and b match, but allowing
                    198:  * the `a' symbol to begin with the character `c'.
                    199:  */
                    200: #define        eqstr(a, b)     (*(a) == *(b) && strcmp(a, b) == 0)
                    201: #define        eqsym(a, b, c)  (eqstr(a, b) || *(a) == (c) && eqstr((a) + 1, b))
                    202: 
                    203: /*
                    204:  * The user structure.
                    205:  */
                    206: union {
                    207:        struct  user user;              /* the actual user struct */
                    208:        char    upages[ctob(UPAGES)];   /* u. + kernel stack */
                    209: } uu;
                    210: #define        u uu.user

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.