File: sdcdb.h

package info (click to toggle)
sdcc 4.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 112,804 kB
  • sloc: ansic: 622,685; cpp: 259,454; makefile: 81,253; sh: 40,203; asm: 19,222; perl: 12,139; yacc: 7,761; awk: 3,378; lisp: 1,677; python: 1,097; lex: 1,028; sed: 76
file content (297 lines) | stat: -rw-r--r-- 11,033 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*-------------------------------------------------------------------------
  sdcdb.h - Header file used by ALL source files for the debugger
        Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   In other words, you are welcome to use, share and improve this program.
   You are forbidden to forbid anyone else to use, share and improve
   what you give them.   Help stamp out software-hoarding!
-------------------------------------------------------------------------*/

#ifndef  SDCDB_H
#define  SDCDB_H

#define SDCDB_VERSION	"0.9"

#define SDCDB_DEBUG

#ifdef SDCDB_DEBUG
// set D_x to 0 to turn off, 1 to turn on.
#define D_break  0x01
#define D_simi   0x02
#define D_sdcdb  0x04
#define D_symtab 0x08

extern int sdcdbDebug;

#define Dprintf(f, fs) {if (f & sdcdbDebug) printf fs ; }
#else
#define Dprintf(f, fs) { }
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#ifdef HAVE_CONFIG_H
# include "config.h"
#elif defined(_WIN32) && !defined(__MINGW32__)
# include "sdcc_vc.h"
#else
# include "sdccconf.h"
#endif
#include "src/SDCCset.h"
#include "src/SDCChasht.h"

#define TRUE 1
#define FALSE !TRUE

typedef short bool;

#ifndef max
#define max(a,b) (a > b ? a : b)
#endif

#ifndef min
#define min(a,b) (a < b ? a : b)
#endif

/*
 * #ifndef ALLOC
 * #define  ALLOC(x,sz) if (!(x = calloc(1, sz)))                       \
 *          {                                                           \
 *             fprintf(stderr,"sdcdb: out of memory\n");                \
 *             exit (1);                                                \
 *          }
 * #endif
 * #ifndef ALLOC_ATOMIC
 * #define ALLOC_ATOMIC(x,sz)   if (!(x = calloc(1, sz)))   \
 *          {                                               \
 *             fprintf(stderr,"sdcdb: out of memory\n");    \
 *             exit (1);                                    \
 *          }
 * #endif
 */

/* generalpurpose stack related macros */
#define  STACK_DCL(stack, type, size)                                      \
         typedef type t_##stack;                                           \
         t_##stack stack[size];                                            \
         t_##stack *p_##stack = stack - 1;                               \
         t_##stack *w_##stack;

/* define extern stack */
#define EXTERN_STACK_DCL(stack, type, size)                                \
        typedef type t_##stack;                                            \
        extern t_##stack stack[size];                                      \
        extern t_##stack *p_##stack;                                       \
        extern t_##stack *w_##stack;

#define STACK_EMPTY(stack)     ((p_##stack) < stack)
#define STACK_FULL(stack)      ((p_##stack) >= (stack +                   \
                               sizeof(stack) / sizeof(*stack) - 1)        )

#define STACK_PUSH_(stack, x)  (*++p_##stack = (x))
#define STACK_POP_(stack)      (*p_##stack--)

#define STACK_PUSH(stack, x)   (STACK_FULL(stack)                         \
                               ? (STACK_ERR(1, stack), *p_##stack)        \
                               : STACK_PUSH_(stack, x)                    )

#define STACK_POP(stack)       (STACK_EMPTY(stack)                        \
                               ? (STACK_ERR(-1, stack), *stack)           \
                               : STACK_POP_(stack)                        )

#define STACK_PEEK(stack)      (STACK_EMPTY(stack)                        \
                               ? (STACK_ERR(0, stack), *stack)            \
                               : *p_##stack                               )

#define STACK_PPEEK(stack)     (((p_##stack - 1) < stack)                 \
                               ? (STACK_ERR(0, stack), *stack)            \
                               : *(p_##stack - 1)                         )

#define STACK_ERR(o, stack)    (fprintf(stderr, "stack '%s' %s\n",        \
                                        #stack,                           \
                                        (o < 0)                           \
                                        ? "underflow"                     \
                                        : (o > 0)                         \
                                          ? "overflow"                    \
                                          : "empty")                      )

#define STACK_STARTWALK(stack) (w_##stack = p_##stack)

#define STACK_WALK(stack)      (w_##stack >= stack                        \
                               ? NULL : STACK_POP_(stack)                 )

#include "src/SDCCbitv.h"

enum {
    SYM_REC = 1,
    LNK_REC,
    FUNC_REC,
    STRUCT_REC,
    MOD_REC
};

enum {
    FMT_NON = 0,
    FMT_BIN = 1,
    FMT_OCT = 2,
    FMT_DEZ = 3,
    FMT_HEX = 4
};

enum { SRC_CMODE = 1, SRC_AMODE };

/*-----------------------------------------------------------------*/
/*                         source line structure                   */
/*-----------------------------------------------------------------*/
typedef struct srcLine
{
    unsigned addr     ;
    short block;
    int level; /* scope information */
    char     *src ;

} srcLine ;

/*-----------------------------------------------------------------*/
/*                     structure for cdb record                    */
/*-----------------------------------------------------------------*/
typedef struct  cdbrecs {
    char type ;               /* type of line */
    char *line;               /* contents of line */
    struct cdbrecs *next;     /* next in chain */
} cdbrecs ;

/*-----------------------------------------------------------------*/
/*                     module definition                           */
/*-----------------------------------------------------------------*/
typedef struct module {
    char *cfullname ;        /* full name Includeing path for the module */
    char *afullname;         /* fullname of assembly file */
    char *name ;             /* name of module */
    char *c_name;            /* c filename     */
    char *asm_name;          /* asm file name  */
    int   ncLines;           /* number of lines in this module */
    int   nasmLines;         /* # of lines in the assembler file */
    srcLine  **cLines;       /* actual source lines */
    srcLine  **asmLines;     /* actual assembler source lines*/
    set       *cfpoints;     /* set of double line execution points */
} module;

/*-----------------------------------------------------------------*/
/*            execution point definition                           */
/*-----------------------------------------------------------------*/
typedef struct exePoint
{
    unsigned addr  ;
    int      line  ;
    short    block ;
    int      level ;
} exePoint ;

/*-----------------------------------------------------------------*/
/*                   definition for a function                     */
/*-----------------------------------------------------------------*/
typedef struct function {
    struct symbol  *sym     ;/* pointer to symbol for function */
    char           *modName ;/* module name */
    module         *mod     ;/* module for this function */
    int        entryline    ;/* first line in the function */
    int        aentryline   ;
    int        exitline     ;/* last line in the function  */
    int        aexitline    ;
    set       *cfpoints     ;/* set of all C execution points in func   */
    set       *afpoints     ;/* set of all ASM execution points in func */
    unsigned   int laddr    ;/* last executed address                   */
    int        lline        ;/* last executed linenumber                */
    unsigned   int stkaddr  ;/* stackpointer at beginning of function
                              * (not reentrant ! ) only actual */
} function ;

/*-----------------------------------------------------------------*/
/*                  link record defintion                          */
/*-----------------------------------------------------------------*/
typedef struct linkrec {
    char type;        /* type of linker rec */
    unsigned addr ;   /* address specified by the linker rec */
    char *name    ;   /* name specified by linker rec */
} linkrec;

/*-----------------------------------------------------------------*/
/*                       program context                           */
/*-----------------------------------------------------------------*/
typedef struct context {
    function *func;           /* current function we are in */
    char     *modName;        /* name of the module         */
    unsigned int addr ;       /* current pc                 */
    int      cline ;          /* current c line number      */
    int      asmline;         /* current asm line number    */
    int      block ;          /* current block number       */
    int      level ;          /* current level number       */
} context ;

/*-----------------------------------------------------------------*/
/*                     symbol display information                  */
/*-----------------------------------------------------------------*/
typedef struct _dsymbol
{
    char *name;
    int  dnum;
    int  fmt;
    char *rs;
} dsymbol;


extern cdbrecs *recsRoot ;
extern context *currCtxt ;
extern set *modules  ; /* set of modules   */
extern set *functions; /* set of functions */
extern set *symbols  ; /* set of symbols */
extern set *sfrsymbols;/* set of symbols of sfr or sbit */
extern set *dispsymbols; /* set of displayable symbols */


extern char *currModName ;
extern char userinterrupt ;
extern char nointerrupt ;
extern short showfull ;
extern int nStructs ;
extern struct structdef **structs ; /* all structures */
extern char *ssdirl; /* source directory search path */
void **resize (void **, int );
char  *alloccpy(char *,int );
char *gc_strdup(const char *s);
srcLine **loadFile (char *name, int *nlines);

extern short fullname;
extern int srcMode;
extern char contsim;
char *searchDirsFname (char *);
char *getNextCmdLine(void);
void setCmdLine(char *);
void stopCommandList(void);

char *argsToCmdLine(char **args, int nargs);

/* trimming functions */
extern char *trim_left(char *s);
extern char *trim_right(char *s);
extern char *trim(char *s);

#endif