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
Defined struct's
SYMbol
defined in line
61; used 48 times
- in line 189-190(4)
- in /usr/src/bin/adb/expr.c line
12(2),
118(2),
244-248(4)
- in /usr/src/bin/adb/findfn.c line
6(2)
- in /usr/src/bin/adb/format.c line
7(2)
- in /usr/src/bin/adb/print.c line
13(2),
76(2)
- in /usr/src/bin/adb/sym.c line
6(2),
22(2),
31(2),
98-99(4),
138(2),
159(2),
186(4),
202(4),
244(2),
284(2),
308(2)
bkpt
defined in line
94; used 1 times
map
defined in line
81; used 1 times
Defined typedef's
BKPT
defined in line
76; used 2 times
BKPTR
defined in line
77; used 18 times
- in line 195
- in /usr/src/bin/adb/access.c line
48
- in /usr/src/bin/adb/pcs.c line
10,
30,
62(2)
- in /usr/src/bin/adb/print.c line
24,
71
- in /usr/src/bin/adb/runpcs.c line
10,
41,
78,
110,
161-163(2),
176,
186,
207,
216
MAP
defined in line
74; used 13 times
MSG
defined in line
73; used 61 times
U
defined in line
78; used 13 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
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
- in /usr/src/bin/adb/access.c line
55,
70,
82-85(2),
95-96(2),
122,
131
- in /usr/src/bin/adb/command.c line
75,
103
- in /usr/src/bin/adb/expr.c line
87,
139
- in /usr/src/bin/adb/findfn.c line
29-32(2)
- in /usr/src/bin/adb/print.c line
194,
202-206(2),
225,
232,
248,
258(3),
275,
283
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
EOR
defined in line
173; used 26 times
- in /usr/src/bin/adb/command.c line
50,
152
- in /usr/src/bin/adb/format.c line
179,
233
- in /usr/src/bin/adb/input.c line
7,
15,
33,
66
- in /usr/src/bin/adb/main.c line
133,
149
- in /usr/src/bin/adb/output.c line
22,
36,
53
- in /usr/src/bin/adb/pcs.c line
76
- in /usr/src/bin/adb/print.c line
85,
103-106(2),
284,
332,
368-373(2),
409
- in /usr/src/bin/adb/runpcs.c line
100,
133,
140,
156
ESYM
defined in line
137;
never used
EVEN
defined in line
175; used 4 times
FALSE
defined in line
166; used 12 times
FI
defined in line
34;
never used
FOR
defined in line
36;
never used
IF
defined in line
30;
never used
ISP
defined in line
130; used 14 times
ISYM
defined in line
134; used 15 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
LOOP
defined in line
43;
never used
NREG
defined in line
144; used 3 times
NSP
defined in line
129; used 7 times
NSYM
defined in line
136; used 4 times
OD
defined in line
39;
never used
ORF
defined in line
47;
never used
PER
defined in line
41;
never used
POOL
defined in line
44;
never used
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
TB
defined in line
172; used 4 times
THEN
defined in line
31;
never used
TRUE
defined in line
165; used 14 times
UAR0
defined in line
150; used 1 times
VARB
defined in line
118; used 1 times
VARC
defined in line
119; used 7 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
leng
defined in line
183; used 16 times
Usage of this include