|
|
1.1 root 1: /*
2: * trace.h
3: */
4:
5: #include <sys/types.h>
6: #include "i8086trace.h"
7:
8: /*
9: * Adjustable constants.
10: */
11: #define NBPT 16 /* Number of breakpoints */
12: #define CCSSIZE 8 /* C compiler symbol size */
13: #define ARGSIZE 20 /* Max number of args for `:e' */
14: #define VALSIZE 10 /* Number of expressions allowed */
15: #define DISSIZE 64 /* Terminal display size */
16: #define FORSIZE 64 /* Size of format for segments */
17: #define COMSIZE 128 /* Size of command sequence */
18: #define MISSIZE 256 /* Size of miscellaneous buffer */
19:
20: /*
21: * Modes for single step.
22: */
23: #define SNULL 0 /* Do nothing */
24: #define SSTEP 1 /* Single step */
25: #define SCONT 2 /* Continuous step */
26: #define SCSET 3 /* Continuous step setup */
27: #define SWAIT 4 /* Wait for function return */
28:
29: /*
30: * Breakpoint flags.
31: */
32: #define BBPT 1 /* Breakpoint set */
33: #define BRET 2 /* Breakpoint return set */
34: #define BSIN 4 /* Breakpoint single continue set */
35:
36: /*
37: * Breakpoint table.
38: */
39: typedef struct b_st {
40: int b_flag; /* Flag word */
41: caddr_t b_badd; /* Breakpoint address */
42: caddr_t b_rfpt; /* Return frame pointer */
43: caddr_t b_sfpt; /* Single continue frame pointer */
44: char *b_bcom; /* Breakpoint command */
45: char *b_rcom; /* Return command */
46: BIN b_bins; /* Instruction we replaced */
47: } BPT;
48:
49: /*
50: * Segment definitions.
51: */
52: #define NSEGM 3 /* Number of segments */
53:
54: #define DSEG 0
55: #define ISEG 1
56: #define USEG 2
57:
58: #define DSPACE segmapl[DSEG] /* Data space */
59: #define ISPACE segmapl[ISEG] /* Instruction space */
60: #define USPACE segmapl[USEG] /* User area */
61:
62: /*
63: * Segmentation map table structure.
64: */
65: typedef struct map {
66: struct map *m_next; /* Pointer to next */
67: off_t m_base; /* Segmentation base */
68: off_t m_bend; /* End of base */
69: off_t m_offt; /* Offset */
70: int (*m_getf)(); /* Read function */
71: int (*m_putf)(); /* Write function */
72: int m_segi; /* Index for segment */
73: } MAP;
74:
75: /*
76: *Default segment attribute definitions.
77: */
78: #define DSA16 16 /* 16 bit default operand and address size */
79: #define DSA32 32 /* 32 bit default operand and address size */
80:
81: /*
82: * Storing some important file header information in memory.
83: */
84: typedef struct fileheaderInfo {
85: unsigned short magic;
86: unsigned short defsegatt; /*Default segment attribute definitions */
87: } HDRINFO;
88:
89: /*
90: * Extension of symbols.
91: */
92: #define L_REG 11 /* Register symbol type */
93:
94: /*
95: * Symbol header structure in memory.
96: */
97: struct LDSYM {
98: char ls_id[NCPLN]; /* Symbol name */
99: short ls_type; /* Global + Seg. */
100: off_t ls_addr; /* Value of symbol */
101: };
102:
103: /*
104: * Symbol in memory.
105: */
106: typedef struct sym {
107: unsigned char s_hash; /* Hash value */
108: unsigned char s_type; /* Type */
109: unsigned s_sval; /* Value of symbol */
110: } SYM;
111:
112: /*
113: * Default file names.
114: */
115: #define DEFLT_OBJ "l.out" /* object file */
116: #define DEFLT_AUX "core" /* auxiliary file */
117:
118: /*
119: * Flags in value.
120: */
121: #define VNULL 1 /* Value is null */
122: #define VLVAL 2 /* Value is a left value */
123:
124: /*
125: * Value descriptor.
126: */
127: typedef struct val {
128: unsigned char v_flag; /* Flag word */
129: unsigned char v_segn; /* Segment number */
130: long v_nval; /* Value */
131: } VAL;
132:
133: /*
134: * Types of input.
135: */
136: #define IFILE 1 /* File I/O */
137: #define ICORE 2 /* Core I/O */
138:
139: /*
140: * Next input stack.
141: */
142: typedef union inp {
143: struct {
144: union inp *i_next; /* Pointer to next */
145: int i_type; /* Type of input */
146: FILE *i_filp; /* File pointer */
147: } i_st1;
148:
149: struct {
150: union inp *i_next; /* Pointer to next */
151: int i_type; /* Type of input */
152: char *i_strp; /* String pointer */
153: } i_st2;
154: } INP;
155:
156: /*
157: * To find a structure offset.
158: */
159: #define offset(s, m) ((int) &(((struct s *) 0)->m))
160:
161: /*
162: * Functions defined by the machine dependent routines.
163: */
164: caddr_t getpc(); /* Get programme counter */
165:
166: /*
167: * Function for the C compiler.
168: */
169: int armsint(); /* trace1.c */
170: MAP *setsmap(); /* trace1.c */
171: MAP *clrsmap(); /* trace1.c */
172: FILE *openfil(); /* trace1.c */
173: int getp(); /* trace2.c */
174: int putp(); /* trace2.c */
175: char *conform(); /* trace3.c */
176: char *getform(); /* trace3.c */
177: char *gettime(); /* trace3.c */
178: long lvalue(); /* trace5.c */
179: long rvalue(); /* trace5.c */
180: int getb(); /* trace6.c */
181: int putb(); /* trace6.c */
182: int getf(); /* trace6.c */
183: int putf(); /* trace6.c */
184: MAP *mapaddr(); /* trace6.c */
185: char *conaddr(); /* trace6.c */
186: char *nalloc(); /* trace6.c */
187:
188: /*
189: * Variables defined by machine dependent routine.
190: */
191: extern char *signame[]; /* Names of signals */
192:
193: /*
194: * Global variables.
195: */
196: extern BIN bin; /* Breakpoint instruction */
197: extern BPT bpt[NBPT]; /* Breakpoint table */
198: extern FILE *cfp; /* Core file pointer */
199: extern FILE *lfp; /* l.out file pointer */
200: extern FILE *sfp; /* Symbol table file pointer */
201: extern INP *inpp; /* Input pointer */
202: extern MAP *endpure; /* End of pure area */
203: extern MAP *segmapl[NSEGM]; /* Segment descriptors */
204: extern SYM *ssymp; /* Pointer to core symbol table */
205: extern char *errrstr; /* Last error */
206: extern char *lfn; /* l.out file name */
207: extern char *segname[NSEGM]; /* Names of segments */
208: extern char *sinp; /* Command for single step */
209: extern char *trapstr; /* Fault type */
210: extern char miscbuf[MISSIZE]; /* Miscellaneous buffer */
211: extern char segform[NSEGM][FORSIZE];/* Formats for segments */
212: extern int bitflag; /* Single step next instruction */
213: extern int cantype; /* Canonization type */
214: extern int cseg; /* Current segment */
215: extern int excflag; /* Programme is in execution */
216: extern int intflag; /* Interrupt count */
217: extern int lastc; /* Character for ungetn */
218: extern int modsize; /* Size of last display mode */
219: extern int objflag; /* Programme can run */
220: extern int pid; /* Current process id */
221: extern int regflag; /* Registers exist */
222: extern int rflag; /* Read only flag */
223: extern int sflag; /* Don't read symbol table */
224: extern int sincmod; /* Last mode ran (if single) */
225: extern int sindecr; /* Single step count */
226: extern int sinmode; /* Single step mode */
227: extern long add; /* Address used by getb */
228: extern long dot; /* Current address */
229: extern long lad; /* Last address of dot */
230: extern off_t sbase; /* Base of symbols */
231: extern off_t snsym; /* Number of symbols */
232:
233: extern HDRINFO hdrinfo; /* important file header info */
234: extern off_t sngblsym; /* Number of symbols of type global */
235: extern off_t *gblsymMap; /* Maps global symbols to symbol table
236: area of the coff header */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.