1: /*
   2:  *
   3:  *      UNIX debugger - common definitions
   4:  *
   5:  *	1998/4/21 - remove local redefinitions used with ptrace
   6:  *
   7:  *      Layout of a.out file (fsym):
   8:  *
   9:  *	This has changed over time - see a.out.h, sys/exec.h and nlist.h
  10:  *	for the current a.out definition and format.
  11:  */
  12: 
  13: #include <sys/param.h>
  14: #include <sys/user.h>
  15: #include <machine/reg.h>
  16: #include <sgtty.h>
  17: #include <setjmp.h>
  18: #include <unistd.h>
  19: #include <a.out.h>
  20: #include <sys/ptrace.h>
  21: 
  22: #define MAXSYMLEN   32
  23: #define MAXCOM  64
  24: #define MAXARG  32
  25: #define LINSIZ  512
  26: 
  27: #define BEGIN   {
  28: #define END }
  29: 
  30: #define IF  if(
  31: #define THEN    ){
  32: #define ELSE    } else {
  33: #define ELIF    } else if (
  34: #define FI  }
  35: 
  36: #define FOR for(
  37: #define WHILE   while(
  38: #define DO  ){
  39: #define OD  }
  40: #define REP do{
  41: #define PER }while(
  42: #define DONE    );
  43: #define LOOP    for(;;){
  44: #define POOL    }
  45: 
  46: #define ANDF    &&
  47: #define ORF ||
  48: 
  49: #define LPRMODE "%Q"
  50: #define OFFMODE "+%o"
  51: 
  52: /*
  53:  * This is the memory resident portion of a symbol.  The only difference
  54:  * between this and a 'nlist' entry is the size of the string offset   By
  55:  * restricting the string table to be less than 64kb we save 2 bytes per
  56:  * symbol - approximately 7.5kb of D space in the case of /unix's symbol
  57:  * table.  In practice this restriction is unlikely to be reached since
  58:  * even the kernel's symbol table of ~28kb only has a strings table of 21kb.
  59: */
  60: 
  61:     struct  SYMbol
  62:         {
  63:         u_short value;
  64:         char    type;
  65:         char    ovno;
  66:         u_short soff;       /* low order of string table offset */
  67:         };
  68: 
  69: #define SYMTYPE(symflag) (( symflag>=041 || (symflag>=02 && symflag<=04))\
  70:                 ?  ((symflag&07)>=3 ? DSYM : (symflag&07))\
  71:                 : NSYM)
  72: 
  73: typedef char        MSG[];
  74: typedef struct map  MAP;
  75: typedef MAP     *MAPPTR;
  76: typedef struct bkpt BKPT;
  77: typedef BKPT        *BKPTR;
  78: typedef struct user U;
  79: 
  80: /* file address maps */
  81: struct map {
  82:     long    b1;
  83:     long    e1;
  84:     long    f1;
  85:     long    bo;
  86:     long    eo;
  87:     long    fo;
  88:     long    b2;
  89:     long    e2;
  90:     long    f2;
  91:     int ufd;
  92: };
  93: 
  94: struct bkpt {
  95:     int loc;
  96:     int ins;
  97:     int count;
  98:     int initcnt;
  99:     char    flag;
 100:     char    ovly;
 101:     char    comm[MAXCOM];
 102:     BKPT    *nxtbkpt;
 103: };
 104: 
 105: typedef struct reglist  REGLIST;
 106: typedef REGLIST     *REGPTR;
 107: struct reglist {
 108:     char    *rname;
 109:     int roffs;
 110: };
 111: 
 112: /*
 113:  * Internal variables ---
 114:  *  They are addressed by name. (e.g. (`0'-`9', `a'-`b'))
 115:  *  thus there can only be 36 of them.
 116:  */
 117: 
 118: #define VARB    11
 119: #define VARC    12      /* current overlay number */
 120: #define VARD    13
 121: #define VARE    14
 122: #define VARM    22
 123: #define VARO    24      /* overlay text segment addition */
 124: #define VARS    28
 125: #define VART    29
 126: 
 127: #define RD      0
 128: #define WT      1
 129: #define NSP     0
 130: #define ISP     1
 131: #define DSP     2
 132: #define STAR    4
 133: #define DSYM    7
 134: #define ISYM    2
 135: #define ASYM    1
 136: #define NSYM    0
 137: #define ESYM    0177
 138: #define BKPTSET 1
 139: #define BKPTEXEC 2
 140: 
 141: #define BPT     03
 142: 
 143: #define NOREG   32767           /* impossible return from getreg() */
 144: #define NREG    9       /* 8 regs + PS from kernel stack */
 145: /*
 146:  * UAR0 is the value used for subprocesses when there is no core file.
 147:  * If it doesn't correspond to reality, use pstat -u on a core file to
 148:  * get uar0, subtract 0140000, and divide by 2 (sizeof int).
 149:  */
 150: #define UAR0    (&corhdr[ctob(USIZE)/sizeof(u_int) - 3]) /* default address of r0 (u.u_ar0) */
 151: 
 152: #define KR0     (0300/2)       /* location of r0 in kernel dump */
 153: #define KR1     (KR0+1)
 154: #define KR2     (KR0+2)
 155: #define KR3     (KR0+3)
 156: #define KR4     (KR0+4)
 157: #define KR5     (KR0+5)
 158: #define KSP     (KR0+6)
 159: #define KA6     (KR0+7)       /* saved ka6 in kernel dump */
 160: 
 161: #define MAXOFF  255
 162: #define MAXPOS  80
 163: #define MAXLIN  128
 164: 
 165: #define TRUE     (-1)
 166: #define FALSE   0
 167: #define LOBYTE  0377
 168: #define HIBYTE  0177400
 169: #define STRIP   0177
 170: 
 171: #define SP  ' '
 172: #define TB  '\t'
 173: #define EOR     '\n'
 174: #define QUOTE   0200
 175: #define EVEN    (~1)
 176: 
 177: /* long to ints and back (puns) */
 178: union {
 179:     int     I[2];
 180:     long   L;
 181: } itolws;
 182: 
 183: #define leng(a)         ((long)((unsigned)(a)))
 184: #define shorten(a)      ((int)(a))
 185: #define itol(a,b)       (itolws.I[0]=(a), itolws.I[1]=(b), itolws.L)
 186: 
 187: /* result type declarations */
 188: long    inkdot();
 189: struct  SYMbol  *lookupsym();
 190: struct  SYMbol  *symget();
 191: u_int   get(), chkget();
 192: char    *exform();
 193: char    *cache_sym(), *no_cache_sym();
 194: long    round();
 195: BKPTR           scanbkpt();
 196: 
 197: struct sgttyb adbtty, usrtty;
 198: jmp_buf erradb;

Defined variables

adbtty defined in line 197; used 2 times
erradb defined in line 198; used 3 times
usrtty defined in line 197; used 4 times

Defined struct's

SYMbol defined in line 61; used 48 times
bkpt defined in line 94; used 1 times
  • in line 76
map defined in line 81; used 1 times
  • in line 74
reglist defined in line 107; used 1 times

Defined typedef's

BKPT defined in line 76; used 2 times
BKPTR defined in line 77; used 18 times
MAP defined in line 74; used 13 times
MAPPTR defined in line 75; used 3 times
REGLIST defined in line 105; used 4 times
REGPTR defined in line 106; used 2 times

Defined macros

ANDF defined in line 46; never used
ASYM defined in line 135; used 1 times
BEGIN defined in line 27; never used
BKPTEXEC defined in line 139; used 2 times
BKPTSET defined in line 138; used 3 times
BPT defined in line 141; used 2 times
DO defined in line 38; never used
DONE defined in line 42; never used
DSP defined in line 131; used 25 times
DSYM defined in line 133; used 7 times
ELIF defined in line 33; never used
ELSE defined in line 32; never used
END defined in line 28; never used
ESYM defined in line 137; never used
EVEN defined in line 175; used 4 times
FI defined in line 34; never used
FOR defined in line 36; never used
HIBYTE defined in line 168; never used
IF defined in line 30; never used
ISP defined in line 130; used 14 times
KA6 defined in line 159; used 3 times
KR0 defined in line 152; used 8 times
KR1 defined in line 153; used 1 times
KR2 defined in line 154; used 1 times
KR3 defined in line 155; used 1 times
KR4 defined in line 156; used 1 times
KR5 defined in line 157; used 3 times
KSP defined in line 158; used 1 times
LINSIZ defined in line 25; used 2 times
LOBYTE defined in line 167; used 38 times
LOOP defined in line 43; never used
LPRMODE defined in line 49; used 1 times
MAXARG defined in line 24; used 1 times
MAXCOM defined in line 23; used 2 times
MAXLIN defined in line 163; used 2 times
MAXOFF defined in line 161; used 2 times
MAXPOS defined in line 162; used 2 times
MAXSYMLEN defined in line 22; used 4 times
NOREG defined in line 143; used 4 times
NREG defined in line 144; used 3 times
NSYM defined in line 136; used 4 times
OD defined in line 39; never used
OFFMODE defined in line 50; used 2 times
ORF defined in line 47; never used
PER defined in line 41; never used
POOL defined in line 44; never used
QUOTE defined in line 174; used 2 times
RD defined in line 127; used 2 times
REP defined in line 40; never used
SP defined in line 171; used 9 times
STAR defined in line 132; used 3 times
STRIP defined in line 169; used 2 times
SYMTYPE defined in line 69; used 1 times
TB defined in line 172; used 4 times
THEN defined in line 31; never used
UAR0 defined in line 150; used 1 times
VARB defined in line 118; used 1 times
VARD defined in line 120; used 1 times
VARE defined in line 121; used 1 times
VARM defined in line 122; used 1 times
VARO defined in line 123; used 1 times
VARS defined in line 124; used 1 times
VART defined in line 125; used 1 times
WHILE defined in line 37; never used
WT defined in line 128; used 2 times
itol defined in line 185; used 4 times

Usage of this include

Last modified: 1998-04-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4076
Valid CSS Valid XHTML 1.0 Strict