Hackfix and re-enable strtoull and wcstoull, see bug #3798.
[sdcc.git] / sdcc / debugger / mcs51 / sdcdb.h
blob91a42ba64a4395fce2e29340b7c219e8a5a5664b
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
8 later version.
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 -------------------------------------------------------------------------*/
24 #ifndef SDCDB_H
25 #define SDCDB_H
27 #define SDCDB_VERSION "0.9"
29 #define SDCDB_DEBUG
31 #ifdef SDCDB_DEBUG
32 // set D_x to 0 to turn off, 1 to turn on.
33 #define D_break 0x01
34 #define D_simi 0x02
35 #define D_sdcdb 0x04
36 #define D_symtab 0x08
38 extern int sdcdbDebug;
40 #define Dprintf(f, fs) {if (f & sdcdbDebug) printf fs ; }
41 #else
42 #define Dprintf(f, fs) { }
43 #endif
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <ctype.h>
49 #include <limits.h>
50 #ifdef HAVE_CONFIG_H
51 # include "config.h"
52 #elif defined(_WIN32) && !defined(__MINGW32__)
53 # include "sdcc_vc.h"
54 #else
55 # include "sdccconf.h"
56 #endif
57 #include "src/SDCCset.h"
58 #include "src/SDCChasht.h"
60 #define TRUE 1
61 #define FALSE !TRUE
63 typedef short bool;
65 #ifndef max
66 #define max(a,b) (a > b ? a : b)
67 #endif
69 #ifndef min
70 #define min(a,b) (a < b ? a : b)
71 #endif
74 * #ifndef ALLOC
75 * #define ALLOC(x,sz) if (!(x = calloc(1, sz))) \
76 * { \
77 * fprintf(stderr,"sdcdb: out of memory\n"); \
78 * exit (1); \
79 * }
80 * #endif
81 * #ifndef ALLOC_ATOMIC
82 * #define ALLOC_ATOMIC(x,sz) if (!(x = calloc(1, sz))) \
83 * { \
84 * fprintf(stderr,"sdcdb: out of memory\n"); \
85 * exit (1); \
86 * }
87 * #endif
90 /* generalpurpose stack related macros */
91 #define STACK_DCL(stack, type, size) \
92 typedef type t_##stack; \
93 t_##stack stack[size]; \
94 t_##stack *p_##stack = stack - 1; \
95 t_##stack *w_##stack;
97 /* define extern stack */
98 #define EXTERN_STACK_DCL(stack, type, size) \
99 typedef type t_##stack; \
100 extern t_##stack stack[size]; \
101 extern t_##stack *p_##stack; \
102 extern t_##stack *w_##stack;
104 #define STACK_EMPTY(stack) ((p_##stack) < stack)
105 #define STACK_FULL(stack) ((p_##stack) >= (stack + \
106 sizeof(stack) / sizeof(*stack) - 1) )
108 #define STACK_PUSH_(stack, x) (*++p_##stack = (x))
109 #define STACK_POP_(stack) (*p_##stack--)
111 #define STACK_PUSH(stack, x) (STACK_FULL(stack) \
112 ? (STACK_ERR(1, stack), *p_##stack) \
113 : STACK_PUSH_(stack, x) )
115 #define STACK_POP(stack) (STACK_EMPTY(stack) \
116 ? (STACK_ERR(-1, stack), *stack) \
117 : STACK_POP_(stack) )
119 #define STACK_PEEK(stack) (STACK_EMPTY(stack) \
120 ? (STACK_ERR(0, stack), *stack) \
121 : *p_##stack )
123 #define STACK_PPEEK(stack) (((p_##stack - 1) < stack) \
124 ? (STACK_ERR(0, stack), *stack) \
125 : *(p_##stack - 1) )
127 #define STACK_ERR(o, stack) (fprintf(stderr, "stack '%s' %s\n", \
128 #stack, \
129 (o < 0) \
130 ? "underflow" \
131 : (o > 0) \
132 ? "overflow" \
133 : "empty") )
135 #define STACK_STARTWALK(stack) (w_##stack = p_##stack)
137 #define STACK_WALK(stack) (w_##stack >= stack \
138 ? NULL : STACK_POP_(stack) )
140 #include "src/SDCCbitv.h"
142 enum {
143 SYM_REC = 1,
144 LNK_REC,
145 FUNC_REC,
146 STRUCT_REC,
147 MOD_REC
150 enum {
151 FMT_NON = 0,
152 FMT_BIN = 1,
153 FMT_OCT = 2,
154 FMT_DEZ = 3,
155 FMT_HEX = 4
158 enum { SRC_CMODE = 1, SRC_AMODE };
160 /*-----------------------------------------------------------------*/
161 /* source line structure */
162 /*-----------------------------------------------------------------*/
163 typedef struct srcLine
165 unsigned addr ;
166 short block;
167 int level; /* scope information */
168 char *src ;
170 } srcLine ;
172 /*-----------------------------------------------------------------*/
173 /* structure for cdb record */
174 /*-----------------------------------------------------------------*/
175 typedef struct cdbrecs {
176 char type ; /* type of line */
177 char *line; /* contents of line */
178 struct cdbrecs *next; /* next in chain */
179 } cdbrecs ;
181 /*-----------------------------------------------------------------*/
182 /* module definition */
183 /*-----------------------------------------------------------------*/
184 typedef struct module {
185 char *cfullname ; /* full name Includeing path for the module */
186 char *afullname; /* fullname of assembly file */
187 char *name ; /* name of module */
188 char *c_name; /* c filename */
189 char *asm_name; /* asm file name */
190 int ncLines; /* number of lines in this module */
191 int nasmLines; /* # of lines in the assembler file */
192 srcLine **cLines; /* actual source lines */
193 srcLine **asmLines; /* actual assembler source lines*/
194 set *cfpoints; /* set of double line execution points */
195 } module;
197 /*-----------------------------------------------------------------*/
198 /* execution point definition */
199 /*-----------------------------------------------------------------*/
200 typedef struct exePoint
202 unsigned addr ;
203 int line ;
204 short block ;
205 int level ;
206 } exePoint ;
208 /*-----------------------------------------------------------------*/
209 /* definition for a function */
210 /*-----------------------------------------------------------------*/
211 typedef struct function {
212 struct symbol *sym ;/* pointer to symbol for function */
213 char *modName ;/* module name */
214 module *mod ;/* module for this function */
215 int entryline ;/* first line in the function */
216 int aentryline ;
217 int exitline ;/* last line in the function */
218 int aexitline ;
219 set *cfpoints ;/* set of all C execution points in func */
220 set *afpoints ;/* set of all ASM execution points in func */
221 unsigned int laddr ;/* last executed address */
222 int lline ;/* last executed linenumber */
223 unsigned int stkaddr ;/* stackpointer at beginning of function
224 * (not reentrant ! ) only actual */
225 } function ;
227 /*-----------------------------------------------------------------*/
228 /* link record defintion */
229 /*-----------------------------------------------------------------*/
230 typedef struct linkrec {
231 char type; /* type of linker rec */
232 unsigned addr ; /* address specified by the linker rec */
233 char *name ; /* name specified by linker rec */
234 } linkrec;
236 /*-----------------------------------------------------------------*/
237 /* program context */
238 /*-----------------------------------------------------------------*/
239 typedef struct context {
240 function *func; /* current function we are in */
241 char *modName; /* name of the module */
242 unsigned int addr ; /* current pc */
243 int cline ; /* current c line number */
244 int asmline; /* current asm line number */
245 int block ; /* current block number */
246 int level ; /* current level number */
247 } context ;
249 /*-----------------------------------------------------------------*/
250 /* symbol display information */
251 /*-----------------------------------------------------------------*/
252 typedef struct _dsymbol
254 char *name;
255 int dnum;
256 int fmt;
257 char *rs;
258 } dsymbol;
261 extern cdbrecs *recsRoot ;
262 extern context *currCtxt ;
263 extern set *modules ; /* set of modules */
264 extern set *functions; /* set of functions */
265 extern set *symbols ; /* set of symbols */
266 extern set *sfrsymbols;/* set of symbols of sfr or sbit */
267 extern set *dispsymbols; /* set of displayable symbols */
270 extern char *currModName ;
271 extern char userinterrupt ;
272 extern char nointerrupt ;
273 extern short showfull ;
274 extern int nStructs ;
275 extern struct structdef **structs ; /* all structures */
276 extern char *ssdirl; /* source directory search path */
277 void **resize (void **, int );
278 char *alloccpy(char *,int );
279 char *gc_strdup(const char *s);
280 srcLine **loadFile (char *name, int *nlines);
282 extern short fullname;
283 extern int srcMode;
284 extern char contsim;
285 char *searchDirsFname (char *);
286 char *getNextCmdLine(void);
287 void setCmdLine(char *);
288 void stopCommandList(void);
290 char *argsToCmdLine(char **args, int nargs);
292 /* trimming functions */
293 extern char *trim_left(char *s);
294 extern char *trim_right(char *s);
295 extern char *trim(char *s);
297 #endif