1 /*-------------------------------------------------------------------------
2 sdcdb.h - Header file used by ALL source files for the debugger
3 Written By - Sandeep Dutta . sandeep.dutta@usa.net (1999)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 In other words, you are welcome to use, share and improve this program.
20 You are forbidden to forbid anyone else to use, share and improve
21 what you give them. Help stamp out software-hoarding!
22 -------------------------------------------------------------------------*/
30 // set D_x to 0 to turn off, 1 to turn on.
36 extern int sdcdbDebug;
38 #define Dprintf(f, fs) {if (f & sdcdbDebug) printf fs ; }
40 #define Dprintf(f, fs) { }
49 #include "src/SDCCset.h"
50 #include "src/SDCChasht.h"
58 #define max(a,b) (a > b ? a : b)
62 #define min(a,b) (a < b ? a : b)
67 * #define ALLOC(x,sz) if (!(x = calloc(1, sz))) \
69 * fprintf(stderr,"sdcdb: out of memory\n"); \
73 * #ifndef ALLOC_ATOMIC
74 * #define ALLOC_ATOMIC(x,sz) if (!(x = calloc(1, sz))) \
76 * fprintf(stderr,"sdcdb: out of memory\n"); \
82 #include "src/SDCCbitv.h"
100 enum { SRC_CMODE = 1, SRC_AMODE };
102 /*-----------------------------------------------------------------*/
103 /* source line structure */
104 /*-----------------------------------------------------------------*/
105 typedef struct srcLine
108 short block, level; /* scope information */
113 /*-----------------------------------------------------------------*/
114 /* structure for cdb record */
115 /*-----------------------------------------------------------------*/
116 typedef struct cdbrecs {
117 char type ; /* type of line */
118 char *line; /* contents of line */
119 struct cdbrecs *next; /* next in chain */
122 /*-----------------------------------------------------------------*/
123 /* module definition */
124 /*-----------------------------------------------------------------*/
125 typedef struct module {
126 char *cfullname ; /* full name Includeing path for the module */
127 char *afullname; /* fullname of assembly file */
128 char *name ; /* name of module */
129 char *c_name; /* c filename */
130 char *asm_name; /* asm file name */
131 int ncLines; /* number of lines in this module */
132 int nasmLines; /* # of lines in the assembler file */
133 srcLine **cLines; /* actual source lines */
134 srcLine **asmLines; /* actual assembler source lines*/
135 set *cfpoints; /* set of double line execution points */
138 /*-----------------------------------------------------------------*/
139 /* execution point definition */
140 /*-----------------------------------------------------------------*/
141 typedef struct exePoint
145 short block , level ;
148 /*-----------------------------------------------------------------*/
149 /* definition for a function */
150 /*-----------------------------------------------------------------*/
151 typedef struct function {
152 struct symbol *sym ;/* pointer to symbol for function */
153 char *modName ;/* module name */
154 module *mod ;/* module for this function */
155 int entryline ;/* first line in the function */
157 int exitline ;/* last line in the function */
159 set *cfpoints ;/* set of all C execution points in func */
160 set *afpoints ;/* set of all ASM execution points in func */
161 unsigned int laddr ;/* last executed address */
162 int lline ;/* last executed linenumber */
163 unsigned int stkaddr ;/* stackpointer at beginning of function
164 * (not reentrant ! ) only actual */
167 /*-----------------------------------------------------------------*/
168 /* link record defintion */
169 /*-----------------------------------------------------------------*/
170 typedef struct linkrec {
171 char type; /* type of linker rec */
172 unsigned addr ; /* address specified by the linker rec */
173 char *name ; /* name specified by linker rec */
176 /*-----------------------------------------------------------------*/
177 /* program context */
178 /*-----------------------------------------------------------------*/
179 typedef struct context {
180 function *func; /* current function we are in */
181 char *modName; /* name of the module */
182 unsigned int addr ; /* current pc */
183 int cline ; /* current c line number */
184 int asmline; /* current asm line number */
185 int block ; /* current block number */
186 int level ; /* current level number */
189 /*-----------------------------------------------------------------*/
190 /* symbol display information */
191 /*-----------------------------------------------------------------*/
192 typedef struct _dsymbol
201 extern cdbrecs *recsRoot ;
202 extern context *currCtxt ;
203 extern set *modules ; /* set of modules */
204 extern set *functions; /* set of functions */
205 extern set *symbols ; /* set of symbols */
206 extern set *sfrsymbols;/* set of symbols of sfr or sbit */
207 extern set *dispsymbols; /* set of displayable symbols */
210 extern char *currModName ;
211 extern char userinterrupt ;
212 extern char nointerrupt ;
213 extern short showfull ;
214 extern int nStructs ;
215 extern struct structdef **structs ; /* all structures */
216 extern char *ssdirl; /* source directory search path */
217 void **resize (void **, int );
218 char *alloccpy(char *,int );
219 char *gc_strdup(const char *s);
220 srcLine **loadFile (char *name, int *nlines);
222 extern short fullname;
225 char *searchDirsFname (char *);
226 char *getNextCmdLine(void );
227 void setCmdLine( char * );
228 void stopCommandList( void );
230 /* trimming functions */
231 extern char *trim_left(char *s);
232 extern char *trim_right(char *s);
233 extern char *trim(char *s);