* support/scripts/sdcc.nsi: added asranlib.exe to the install package
[fw/sdcc] / debugger / mcs51 / sdcdb.h
index ad535b2c1dba5861433b2cc458b5ef44c5c63be5..b286ac161d12cd32ff58a82d33bb2af2d8b4b365 100644 (file)
@@ -1,49 +1,51 @@
 /*-------------------------------------------------------------------------
   sdcdb.h - Header file used by ALL source files for the debugger
 /*-------------------------------------------------------------------------
   sdcdb.h - Header file used by ALL source files for the debugger
-             Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)
+        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 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.
    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.
    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
    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!  
+   what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
 #ifndef  SDCDB_H
 #define  SDCDB_H
 
 -------------------------------------------------------------------------*/
 
 #ifndef  SDCDB_H
 #define  SDCDB_H
 
-/* #define SDCDB_DEBUG */
+#define SDCDB_DEBUG
 
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include "sdccconf.h"
-#ifdef _NO_GC
+#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
 
 
-#define GC_malloc malloc
-#define GC_free free
-#define GC_realloc realloc
+extern int sdcdbDebug;
 
 
+#define Dprintf(f, fs) {if (f & sdcdbDebug) printf fs ; }
 #else
 #else
-
-#include "gc/gc.h"
-
+#define Dprintf(f, fs) { }
 #endif
 
 #endif
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include "config.h"
 #include "src/SDCCset.h"
 #include "src/SDCChasht.h"
 
 #include "src/SDCCset.h"
 #include "src/SDCChasht.h"
 
@@ -60,13 +62,22 @@ typedef short bool;
 #define min(a,b) (a < b ? a : b)
 #endif
 
 #define min(a,b) (a < b ? a : b)
 #endif
 
-#ifndef ALLOC
-#define  ALLOC(x,sz) if (!(x = GC_malloc(sz)))                          \
-         {                                                           \
-            fprintf(stderr,"sdcdb: out of memory\n"); \
-            exit (1);                                                \
-         }
-#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)                   \
 
 /* generalpurpose stack related macros */
 #define  STACK_DCL(stack,type,size)                   \
@@ -84,7 +95,7 @@ typedef short bool;
 
 #define  STACK_FULL(stack)    ((p_##stack) <= stack )
 #define  STACK_EMPTY(stack)   ((p_##stack) >= (stack +      \
 
 #define  STACK_FULL(stack)    ((p_##stack) <= stack )
 #define  STACK_EMPTY(stack)   ((p_##stack) >= (stack +      \
-                              sizeof(stack)/sizeof(*stack)) )  
+                              sizeof(stack)/sizeof(*stack)) )
 
 #define  STACK_PUSH_(stack,x) (*--p_##stack = (x))
 #define  STACK_POP_(stack)    (*p_##stack++)
 
 #define  STACK_PUSH_(stack,x) (*--p_##stack = (x))
 #define  STACK_POP_(stack)    (*p_##stack++)
@@ -94,7 +105,7 @@ typedef short bool;
                               : STACK_PUSH_(stack,x)              )
 
 #define  STACK_POP(stack)     (STACK_EMPTY(stack)                 \
                               : STACK_PUSH_(stack,x)              )
 
 #define  STACK_POP(stack)     (STACK_EMPTY(stack)                 \
-                              ?((t_##stack)(long)(STACK_ERR(0)))  \
+                              ?((t_##stack) NULL)  \
                               : STACK_POP_(stack)                 )
 
 #define  STACK_PEEK(stack)    (STACK_EMPTY(stack)                 \
                               : STACK_POP_(stack)                 )
 
 #define  STACK_PEEK(stack)    (STACK_EMPTY(stack)                 \
@@ -113,9 +124,9 @@ typedef short bool;
 #define  STACK_STARTWALK(stack)   (w_##stack = p_##stack)
 
 #define  STACK_WALK(stack)    (w_##stack >= (stack + sizeof(stack)/sizeof(*stack)) \
 #define  STACK_STARTWALK(stack)   (w_##stack = p_##stack)
 
 #define  STACK_WALK(stack)    (w_##stack >= (stack + sizeof(stack)/sizeof(*stack)) \
-                              ? NULL : *w_##stack++ )
+                               ? NULL : *w_##stack++ )
 
 
-#include "../sdcc.src/SDCCbitv.h"
+#include "src/SDCCbitv.h"
 
 enum {
     SYM_REC = 1,
 
 enum {
     SYM_REC = 1,
@@ -125,6 +136,14 @@ enum {
     MOD_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 };
 
 /*-----------------------------------------------------------------*/
 enum { SRC_CMODE = 1, SRC_AMODE };
 
 /*-----------------------------------------------------------------*/
@@ -137,14 +156,14 @@ typedef struct srcLine
     char     *src ;
 
 } srcLine ;
     char     *src ;
 
 } srcLine ;
-    
+
 /*-----------------------------------------------------------------*/
 /*                     structure for cdb record                    */
 /*-----------------------------------------------------------------*/
 typedef struct  cdbrecs {
     char type ;               /* type of line */
     char *line;               /* contents of line */
 /*-----------------------------------------------------------------*/
 /*                     structure for cdb record                    */
 /*-----------------------------------------------------------------*/
 typedef struct  cdbrecs {
     char type ;               /* type of line */
     char *line;               /* contents of line */
-    struct cdbrecs *next;     /* next in chain */    
+    struct cdbrecs *next;     /* next in chain */
 } cdbrecs ;
 
 /*-----------------------------------------------------------------*/
 } cdbrecs ;
 
 /*-----------------------------------------------------------------*/
@@ -158,8 +177,9 @@ typedef struct module {
     char *asm_name;          /* asm file name  */
     int   ncLines;           /* number of lines in this module */
     int   nasmLines;         /* # of lines in the assembler file */
     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  **cLines;       /* actual source lines */
     srcLine  **asmLines;     /* actual assembler source lines*/
     srcLine  **asmLines;     /* actual assembler source lines*/
+    set       *cfpoints;     /* set of double line execution points */
 } module;
 
 /*-----------------------------------------------------------------*/
 } module;
 
 /*-----------------------------------------------------------------*/
@@ -171,22 +191,24 @@ typedef struct exePoint
     int      line  ;
     short    block , level ;
 } exePoint ;
     int      line  ;
     short    block , level ;
 } exePoint ;
+
 /*-----------------------------------------------------------------*/
 /*                   definition for a function                     */
 /*-----------------------------------------------------------------*/
 typedef struct function {
 /*-----------------------------------------------------------------*/
 /*                   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 */     
+    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    ;
     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       *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                */
     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 ;
 
 /*-----------------------------------------------------------------*/
 } function ;
 
 /*-----------------------------------------------------------------*/
@@ -201,7 +223,7 @@ typedef struct linkrec {
 /*-----------------------------------------------------------------*/
 /*                       program context                           */
 /*-----------------------------------------------------------------*/
 /*-----------------------------------------------------------------*/
 /*                       program context                           */
 /*-----------------------------------------------------------------*/
-typedef struct context {    
+typedef struct context {
     function *func;           /* current function we are in */
     char     *modName;        /* name of the module         */
     unsigned int addr ;       /* current pc                 */
     function *func;           /* current function we are in */
     char     *modName;        /* name of the module         */
     unsigned int addr ;       /* current pc                 */
@@ -211,20 +233,50 @@ typedef struct context {
     int      level ;          /* current level number       */
 } context ;
 
     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 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 );
 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);
 srcLine **loadFile (char *name, int *nlines);
+
 extern short fullname;
 extern int srcMode;
 extern short fullname;
 extern int srcMode;
+extern char contsim;
 char *searchDirsFname (char *);
 char *searchDirsFname (char *);
+char *getNextCmdLine(void );
+void setCmdLine( char * );
+void stopCommandList( void );
+
+/* trimming functions */
+extern char *trim_left(char *s);
+extern char *trim_right(char *s);
+extern char *trim(char *s);
 
 #endif
 
 #endif