2003-03-23 Bernhard Held <bernhard@bernhardheld.de>
* doc/cdbfile.html: removed, replaced by cdbfileformat.lyx
+ Added Lenny Story's debug infrastructure changes:
+ * src/Makefile.in: added new files cdbFile.c and SDCCdebug.c
+ * src/Makefile.bcc: added new files cdbFile.c and SDCCdebug.c
+ * src/cdbFile.c: added
+ * src/SDCCdebug.c: added
+ * src/SDCCdebug.h: added
+ * src/SDCCast.c (createFunction)
+ * src/SDCCglue.c (emitRegularMap, emitStaticSeg, emitOverlay, glue)
+ * src/SDCCmain.c (parseCmdLine, main)
+ * src/SDCCmem.c (redoStackOffsets)
+ * src/SDCCsymt.c (cdbStructBlock, cdbTypeInfo, cdbSymbol, cdbStruct, cdbStructBlock)
+ * src/SDCCsymt.h
+ * src/common.h
+ * src/avr/gen.c (genAVRCode)
+ * src/ds390/gen.c (gen390Code)
+ * src/mcs51/gen.c (gen51Code)
+ * src/pic/gen.c (genpic14Code)
+ * src/pic/glue.c (pic14emitRegularMap, pic14emitStaticSeg, pic14emitOverlay, picglue)
+ * src/xa51/gen.c (genXA51Code)
2003-03-22 Frieder Ferlemann <Frieder.Ferlemann@web.de>
SDCCicode.obj SDCCbitv.obj SDCCset.obj SDCClabel.obj \
SDCCBBlock.obj SDCCloop.obj SDCCcse.obj SDCCcflow.obj SDCCdflow.obj \
SDCClrange.obj SDCCptropt.obj SDCCpeeph.obj SDCCglue.obj \
- asm.obj SDCCutil.obj SDCCmacro.obj
+ asm.obj SDCCutil.obj SDCCmacro.obj SDCCdebug.obj cdbFile.obj
SLIBOBJS = $(SLIB)/SDCCerr.obj $(SLIB)/NewAlloc.obj $(SLIB)/MySystem.obj $(SLIB)/BuildCmd.obj
SDCCicode.o SDCCbitv.o SDCCset.o SDCClabel.o \
SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \
SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o \
- asm.o SDCCmacro.o SDCCutil.o
+ asm.o SDCCmacro.o SDCCutil.o SDCCdebug.o cdbFile.o
SPECIAL = SDCCy.h
ifeq ($(USE_ALT_LEX), 1)
ast *autoInit;
if (action == ALLOCATE)
- {
+ {
*stack += allocVariables (tree->values.sym);
autoInit = gatherAutoInit (tree->values.sym);
-
+
/* if there are auto inits then do them */
if (autoInit)
tree->left = newNode (NULLOP, autoInit, tree->left);
- }
+ }
else /* action is deallocate */
deallocLocal (tree->values.sym);
}
ex = newNode (BLOCK, NULL, body);
ex->values.sym = decl;
-
+
ex->right = ex->right;
ex->level++;
ex->lineno = 0;
/* dealloc the block variables */
processBlockVars (body, &stack, DEALLOCATE);
+ outputDebugStackSymbols();
/* deallocate paramaters */
deallocParms (FUNC_ARGS(name->type));
addSet (&operKeyReset, name);
applyToSet (operKeyReset, resetParmKey);
- if (options.debug)
- cdbStructBlock (1, cdbFile);
+ if (options.debug)
+ cdbStructBlock(1);
cleanUpLevel (LabelTab, 0);
cleanUpBlock (StructTab, 1);
--- /dev/null
+
+#include "common.h"
+
+extern DEBUGFILE cdbDebugFile;
+
+DEBUGFILE *debugFile = &cdbDebugFile;
+
+void outputDebugStackSymbols(void)
+{
+ if(getenv("SDCC_DEBUG_VAR_STORAGE"))
+ {
+ dumpSymInfo("XStack", xstack);
+ dumpSymInfo("IStack", istack);
+ }
+
+ if(options.debug && debugFile)
+ {
+ symbol *sym;
+
+ for (sym = setFirstItem (xstack->syms); sym; sym = setNextItem (xstack->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (istack->syms); sym; sym = setNextItem (istack->syms))
+ debugFile->writeSymbol(sym);
+ }
+
+}
+
+
+void outputDebugSymbols(void)
+{
+ if(getenv("SDCC_DEBUG_VAR_STORAGE"))
+ {
+ dumpSymInfo("Code", code);
+ dumpSymInfo("Data", data);
+ dumpSymInfo("XData", xdata);
+ dumpSymInfo("XIData", xidata);
+ dumpSymInfo("XInit", xinit);
+ dumpSymInfo("IData", idata);
+ dumpSymInfo("Bit", bit);
+ dumpSymInfo("Statics", statsg);
+ dumpSymInfo("SFR", sfr);
+ dumpSymInfo("SFRBits", sfrbit);
+ dumpSymInfo("Reg", reg);
+ dumpSymInfo("Generic", generic);
+ dumpSymInfo("Overlay", overlay);
+ dumpSymInfo("EEProm", eeprom);
+ dumpSymInfo("Home", home);
+ }
+
+ if(options.debug && debugFile)
+ {
+ symbol *sym;
+
+ for (sym = setFirstItem (data->syms); sym; sym = setNextItem (data->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (idata->syms); sym; sym = setNextItem (idata->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (bit->syms); sym; sym = setNextItem (bit->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (xdata->syms); sym; sym = setNextItem (xdata->syms))
+ debugFile->writeSymbol(sym);
+
+ if(port->genXINIT) {
+ for (sym = setFirstItem (xidata->syms); sym; sym = setNextItem (xidata->syms))
+ debugFile->writeSymbol(sym);
+ }
+
+ for (sym = setFirstItem (sfr->syms); sym; sym = setNextItem (sfr->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (sfrbit->syms); sym; sym = setNextItem (sfrbit->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (home->syms); sym; sym = setNextItem (home->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (code->syms); sym; sym = setNextItem (code->syms))
+ debugFile->writeSymbol(sym);
+
+ for (sym = setFirstItem (statsg->syms); sym; sym = setNextItem (statsg->syms))
+ debugFile->writeSymbol(sym);
+
+ if(port->genXINIT) {
+ for (sym = setFirstItem (xinit->syms); sym; sym = setNextItem (xinit->syms))
+ debugFile->writeSymbol(sym);
+ }
+ }
+
+ return;
+}
+
+
+void dumpSymInfo(char *pcName, memmap *memItem)
+{
+ symbol *sym;
+
+ printf("--------------------------------------------\n");
+ printf(" %s\n", pcName);
+
+ for(sym = setFirstItem(memItem->syms);
+ sym; sym = setNextItem(memItem->syms))
+ {
+ printf(" %s, isReqv:%d, reqv:0x%p, onStack:%d, Stack:%d, nRegs:%d, [",
+ sym->rname, sym->isreqv, sym->reqv, sym->onStack, sym->stack, sym->nRegs);
+
+ if(sym->reqv)
+ {
+ int i;
+ symbol *TempSym = OP_SYMBOL (sym->reqv);
+
+ for (i = 0; i < 4; i++)
+ if(TempSym->regs[i])
+ printf("%s,", port->getRegName(TempSym->regs[i]));
+ }
+
+ printf("]\n");
+ }
+
+ printf("\n");
+}
+
+
+
+
--- /dev/null
+
+#ifndef _DEBUG_INCLUDE_
+#define _DEBUG_INCLUDE_
+
+typedef struct DebugFile
+{
+ int (*openFile)(char *file);
+ int (*closeFile)(void);
+ int (*writeModule)(char *name);
+ int (*writeFunction)(symbol *pSym);
+ int (*writeSymbol)(symbol *pSym);
+ int (*writeType)(structdef *sdef, int block, int inStruct, char *tag);
+ int (*writeCLine)(char *module, int Line, int Level, int Block);
+ int (*writeALine)(char *module, int Line);
+
+}DEBUGFILE;
+
+extern DEBUGFILE *debugFile;
+
+void outputDebugStackSymbols(void);
+void outputDebugSymbols(void);
+void dumpSymInfo(char *pcName, memmap *memItem);
+
+#endif
continue;
/* print extra debug info if required */
- if (options.debug) {
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
- if (!sym->level) /* global */
- if (IS_STATIC (sym->etype))
- fprintf (map->oFile, "F%s$", moduleName); /* scope is file */
+ if (options.debug)
+ {
+ if (!sym->level) /* global */
+ {
+ if (IS_STATIC (sym->etype))
+ fprintf (map->oFile, "F%s$", moduleName); /* scope is file */
+ else
+ fprintf (map->oFile, "G$"); /* scope is global */
+ }
else
- fprintf (map->oFile, "G$"); /* scope is global */
- else
- /* symbol is local */
- fprintf (map->oFile, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
- fprintf (map->oFile, "%s$%d$%d", sym->name, sym->level, sym->block);
- }
+ {
+ /* symbol is local */
+ fprintf (map->oFile, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
+ }
+ fprintf (map->oFile, "%s$%d$%d", sym->name, sym->level, sym->block);
+ }
/* if it has an initial value then do it only if
it is a global variable */
/* print extra debug info if required */
if (options.debug) {
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
+
if (!sym->level)
{ /* global */
if (IS_STATIC (sym->etype))
/* print extra debug info if required */
if (options.debug)
{
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
if (!sym->level)
{ /* global */
if (IS_STATIC (sym->etype))
addSetHead (&tmpfileSet, ovrFile);
/* print the global struct definitions */
if (options.debug)
- cdbStructBlock (0, cdbFile);
+ cdbStructBlock (0);
vFile = tempfile ();
/* PENDING: this isnt the best place but it will do */
/* do the overlay segments */
emitOverlay (ovrFile);
+ outputDebugSymbols();
+
/* now put it all together into the assembler file */
/* create the assembler file name */
#include "MySystem.h"
#include "SDCCmacro.h"
#include "SDCCutil.h"
+#include "SDCCdebug.h"
#include "SDCCargs.h"
#if NATIVE_WIN32
extern int yyparse ();
FILE *srcFile; /* source file */
-FILE *cdbFile = NULL; /* debugger information output file */
char *fullSrcFileName; /* full name for the source file; */
/* can be NULL while c1mode or linking without compiling */
char *fullDstFileName; /* full name for the output file; */
addToList (preArgv, "-C");
break;
}
+
case 'd':
case 'D':
case 'I':
if (!options.xstack_loc)
options.xstack_loc = options.xdata_loc;
- /* if debug option is set the open the cdbFile */
+ /* if debug option is set then open the cdbFile */
if (options.debug && fullSrcFileName)
{
SNPRINTF (scratchFileName, sizeof(scratchFileName),
"%s.adb", dstFileName); //JCF: Nov 30, 2002
- if ((cdbFile = fopen (scratchFileName, "w")) == NULL)
- werror (E_FILE_OPEN_ERR, scratchFileName);
+ if(debugFile->openFile(scratchFileName))
+ debugFile->writeModule(moduleName);
else
- {
- /* add a module record */
- fprintf (cdbFile, "M:%s\n", moduleName);
- }
+ werror (E_FILE_OPEN_ERR, scratchFileName);
}
return 0;
}
}
closeDumpFiles();
- if (cdbFile)
- fclose (cdbFile);
+ if (options.debug && debugFile)
+ debugFile->closeFile();
if (!options.cc_only &&
!fatalError &&
will remove and put into the 'data' segment if required after
overlay analysis has been done */
if (options.model == MODEL_SMALL) {
- SPEC_OCLS (sym->etype) =
- (options.noOverlay ? port->mem.default_local_map
- : overlay);
+ SPEC_OCLS (sym->etype) =
+ (options.noOverlay ? port->mem.default_local_map
+ : overlay);
} else {
- SPEC_OCLS (sym->etype) = port->mem.default_local_map;
+ SPEC_OCLS (sym->etype) = port->mem.default_local_map;
}
allocIntoSeg (sym);
}
xsPtr += size;
}
- /* if the debug option is set then output the
- symbols to the map file */
- if (options.debug)
- {
- for (sym = setFirstItem (istack->syms); sym;
- sym = setNextItem (istack->syms))
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
- for (sym = setFirstItem (xstack->syms); sym;
- sym = setNextItem (xstack->syms))
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
- }
}
/*-----------------------------------------------------------------*/
return 1;
}
+/*------------------------------------------------------------------*/
+/* cdbStructBlock - calls struct printing for a blcks */
+/*------------------------------------------------------------------*/
+void cdbStructBlock (int block)
+{
+ int i;
+ bucket **table = StructTab;
+ bucket *chain;
+
+ /* go thru the entire table */
+ for (i = 0; i < 256; i++)
+ {
+ for (chain = table[i]; chain; chain = chain->next)
+ {
+ if (chain->block >= block)
+ {
+ if(debugFile)
+ debugFile->writeType((structdef *)chain->sym, chain->block, 0, NULL);
+ }
+ }
+ }
+}
+
/*-----------------------------------------------------------------*/
/* processFuncArgs - does some processing with function args */
/*-----------------------------------------------------------------*/
fprintf (of, "\n");
}
-/*-----------------------------------------------------------------*/
-/* cdbTypeInfo - print the type information for debugger */
-/*-----------------------------------------------------------------*/
-void
-cdbTypeInfo (sym_link * type, FILE * of)
-{
- fprintf (of, "{%d}", getSize (type));
- while (type)
- {
- if (IS_DECL (type))
- {
- switch (DCL_TYPE (type))
- {
- case FUNCTION:
- fprintf (of, "DF,");
- break;
- case GPOINTER:
- fprintf (of, "DG,");
- break;
- case CPOINTER:
- fprintf (of, "DC,");
- break;
- case FPOINTER:
- fprintf (of, "DX,");
- break;
- case POINTER:
- fprintf (of, "DD,");
- break;
- case IPOINTER:
- fprintf (of, "DI,");
- break;
- case PPOINTER:
- fprintf (of, "DP,");
- break;
- case EEPPOINTER:
- fprintf (of, "DA,");
- break;
- case ARRAY:
- fprintf (of, "DA%d,", DCL_ELEM (type));
- break;
- default:
- break;
- }
- }
- else
- {
- switch (SPEC_NOUN (type))
- {
- case V_INT:
- if (IS_LONG (type))
- fprintf (of, "SL");
- else
- fprintf (of, "SI");
- break;
-
- case V_CHAR:
- fprintf (of, "SC");
- break;
-
- case V_VOID:
- fprintf (of, "SV");
- break;
-
- case V_FLOAT:
- fprintf (of, "SF");
- break;
-
- case V_STRUCT:
- fprintf (of, "ST%s", SPEC_STRUCT (type)->tag);
- break;
-
- case V_SBIT:
- fprintf (of, "SX");
- break;
-
- case V_BIT:
- fprintf (of, "SB%d$%d", SPEC_BSTR (type), SPEC_BLEN (type));
- break;
-
- default:
- break;
- }
- fputs (":", of);
- if (SPEC_USIGN (type))
- fputs ("U", of);
- else
- fputs ("S", of);
- }
- type = type->next;
- }
-}
-/*-----------------------------------------------------------------*/
-/* cdbSymbol - prints a symbol & its type information for debugger */
-/*-----------------------------------------------------------------*/
-void
-cdbSymbol (symbol * sym, FILE * of, int isStructSym, int isFunc)
-{
- memmap *map;
-
- if (!sym)
- return;
- if (!of)
- of = stdout;
-
- if (isFunc)
- fprintf (of, "F:");
- else
- fprintf (of, "S:"); /* symbol record */
- /* if this is not a structure symbol then
- we need to figure out the scope information */
- if (!isStructSym)
- {
- if (!sym->level)
- {
- /* global */
- if (IS_STATIC (sym->etype))
- fprintf (of, "F%s$", moduleName); /* scope is file */
- else
- fprintf (of, "G$"); /* scope is global */
- }
- else
- /* symbol is local */
- fprintf (of, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
- }
- else
- fprintf (of, "S$"); /* scope is structure */
-
- /* print the name, & mangled name */
- fprintf (of, "%s$%d$%d(", sym->name,
- sym->level, sym->block);
-
- cdbTypeInfo (sym->type, of);
- fprintf (of, "),");
-
- /* print the address space */
- map = SPEC_OCLS (sym->etype);
- fprintf (of, "%c,%d,%d",
- (map ? map->dbName : 'Z'), sym->onStack, SPEC_STAK (sym->etype));
-
- /* if assigned to registers then output register names */
- /* if this is a function then print
- if is it an interrupt routine & interrupt number
- and the register bank it is using */
- if (isFunc)
- fprintf (of, ",%d,%d,%d", FUNC_ISISR (sym->type),
- FUNC_INTNO (sym->type), FUNC_REGBANK (sym->type));
- /* alternate location to find this symbol @ : eg registers
- or spillication */
-
- if (!isStructSym)
- fprintf (of, "\n");
-}
-
-/*-----------------------------------------------------------------*/
-/* cdbStruct - print a structure for debugger */
-/*-----------------------------------------------------------------*/
-void
-cdbStruct (structdef * sdef, int block, FILE * of,
- int inStruct, char *tag)
-{
- symbol *sym;
-
- fprintf (of, "T:");
- /* if block # then must have function scope */
- fprintf (of, "F%s$", moduleName);
- fprintf (of, "%s[", (tag ? tag : sdef->tag));
- for (sym = sdef->fields; sym; sym = sym->next)
- {
- fprintf (of, "({%d}", sym->offset);
- cdbSymbol (sym, of, TRUE, FALSE);
- fprintf (of, ")");
- }
- fprintf (of, "]");
- if (!inStruct)
- fprintf (of, "\n");
-}
-
-/*------------------------------------------------------------------*/
-/* cdbStructBlock - calls struct printing for a blcks */
-/*------------------------------------------------------------------*/
-void
-cdbStructBlock (int block, FILE * of)
-{
- int i;
- bucket **table = StructTab;
- bucket *chain;
- wassert (of);
-
- /* go thru the entire table */
- for (i = 0; i < 256; i++)
- {
- for (chain = table[i]; chain; chain = chain->next)
- {
- if (chain->block >= block)
- {
- cdbStruct ((structdef *) chain->sym, chain->block, of, 0, NULL);
- }
- }
- }
-}
/*-----------------------------------------------------------------*/
/* powof2 - returns power of two for the number if number is pow 2 */
void initCSupport ();
void initBuiltIns ();
void pointerTypes (sym_link *, sym_link *);
-void cdbTypeInfo (sym_link *, FILE *);
-void cdbSymbol (symbol *, FILE *, int, int);
-void cdbStructBlock (int, FILE *);
+void cdbStructBlock (int);
void initHashT ();
bucket *newBucket ();
void addSym (bucket **, void *, char *, int, int, int checkType);
/* if debug information required */
/* if (options.debug && currFunc) { */
if (currFunc) {
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
/* emitcode ("", ".type %s,@function", currFunc->name); */
_G.debugLine = 0;
--- /dev/null
+
+
+#include "common.h"
+
+
+/*************************************************************
+ *
+ *
+ *
+ *
+ *************************************************************/
+
+int cdbOpenFile(char *file);
+int cdbCloseFile(void);
+int cdbWriteFunction(symbol *pSym);
+int cdbWriteSymbol(symbol *pSym);
+int cdbWriteType(structdef *sdef, int block, int inStruct, char *tag);
+int cdbWriteModule(char *name);
+int cdbWriteCLine(char *module, int Line, int Level, int Block);
+int cdbWriteALine(char *module, int Line);
+int cdbWriteBasicSymbol(symbol *sym, int isStructSym, int isFunc);
+void cdbTypeInfo (sym_link * type);
+
+
+DEBUGFILE cdbDebugFile =
+ {
+ &cdbOpenFile,
+ &cdbCloseFile,
+ &cdbWriteModule,
+ &cdbWriteFunction,
+ &cdbWriteSymbol,
+ &cdbWriteType,
+ &cdbWriteCLine,
+ &cdbWriteALine
+ };
+
+FILE *cdbFilePtr = NULL;
+char *cdbModuleName = NULL;
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbOpenFile(char *file)
+{
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbOpenFile(%s)\n", file);
+
+ return (cdbFilePtr = fopen(file, "w")) ? 1 : 0;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+int cdbCloseFile(void)
+{
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbCloseFile()\n");
+
+ if(!cdbFilePtr) return 0;
+
+ fclose(cdbFilePtr);
+ cdbFilePtr = NULL;
+ cdbModuleName = NULL;
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteFunction(symbol *pSym)
+{
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbWriteFunction()\n");
+
+
+ if(!cdbFilePtr) return 0;
+
+ return cdbWriteBasicSymbol(pSym, FALSE, TRUE);
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteSymbol(symbol *pSym)
+{
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbWriteSymbol()\n");
+
+ if(!cdbFilePtr) return 0;
+
+ return cdbWriteBasicSymbol(pSym, FALSE, FALSE);
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteType(structdef *sdef, int block, int inStruct, char *tag)
+{
+ symbol *sym;
+
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbWriteType()\n");
+
+ if(!cdbFilePtr) return 0;
+
+ fprintf (cdbFilePtr, "T:");
+
+ /* if block # then must have function scope */
+ fprintf (cdbFilePtr, "F%s$", moduleName);
+
+ fprintf (cdbFilePtr, "%s[", (tag ? tag : sdef->tag));
+
+ for (sym = sdef->fields; sym; sym = sym->next)
+ {
+ fprintf (cdbFilePtr, "({%d}", sym->offset);
+ cdbWriteBasicSymbol(sym, TRUE, FALSE);
+ fprintf(cdbFilePtr, ")");
+ }
+
+ fprintf (cdbFilePtr, "]");
+
+ if (!inStruct)
+ fprintf (cdbFilePtr, "\n");
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteModule(char *name)
+{
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbWriteModule()\n");
+
+ if(!cdbFilePtr) return 0;
+ cdbModuleName = name;
+
+ fprintf(cdbFilePtr, "M:%s\n", cdbModuleName);
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+int cdbWriteCLine(char *module, int Line, int Level, int Block)
+{
+ if(!cdbFilePtr) return 0;
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteALine(char *module, int Line)
+{
+ if(!cdbFilePtr) return 0;
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+int cdbWriteBasicSymbol(symbol *sym, int isStructSym, int isFunc)
+{
+ memmap *map;
+
+ if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
+ fprintf (stderr, "cdbFile.c:cdbWriteBasicSymbol()\n");
+
+ if(!cdbFilePtr) return 0;
+
+ if (!sym) return 0;
+
+ /* WRITE HEADER, Function or Symbol */
+ if (isFunc)
+ fprintf (cdbFilePtr, "F:");
+ else
+ fprintf (cdbFilePtr, "S:");
+
+ /* STRUCTS do not have scope info.. */
+
+ if (!isStructSym)
+ {
+ if (!sym->level)
+ {
+ /* global */
+ if (IS_STATIC (sym->etype))
+ fprintf (cdbFilePtr, "F%s$", moduleName); /* scope is file */
+ else
+ fprintf (cdbFilePtr, "G$"); /* scope is global */
+ }
+ else
+ /* symbol is local */
+ fprintf (cdbFilePtr, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
+ }
+ else
+ fprintf (cdbFilePtr, "S$"); /* scope is structure */
+
+ /* print the name, & mangled name */
+ fprintf (cdbFilePtr, "%s$%d$%d(", sym->name,
+ sym->level, sym->block);
+
+ cdbTypeInfo (sym->type);
+
+ fprintf (cdbFilePtr, "),");
+
+ /* CHECK FOR REGISTER SYMBOL... */
+ if(sym->reqv)
+ {
+ int a;
+ symbol *TempSym = OP_SYMBOL (sym->reqv);
+
+ fprintf(cdbFilePtr, "R,0,0,[");
+
+ for(a = 0; a < 4; a++)
+ if(TempSym->regs[a])
+ fprintf(cdbFilePtr, "%s%s", port->getRegName(TempSym->regs[a]),
+ ((a < 3) && (TempSym->regs[a+1])) ? "," : "");
+
+ fprintf(cdbFilePtr, "]");
+ }
+ else
+ {
+ /* print the address space */
+ map = SPEC_OCLS (sym->etype);
+
+ fprintf (cdbFilePtr, "%c,%d,%d",
+ (map ? map->dbName : 'Z'), sym->onStack, SPEC_STAK (sym->etype));
+ }
+
+ /* if assigned to registers then output register names */
+ /* if this is a function then print
+ if is it an interrupt routine & interrupt number
+ and the register bank it is using */
+ if (isFunc)
+ fprintf (cdbFilePtr, ",%d,%d,%d", FUNC_ISISR (sym->type),
+ FUNC_INTNO (sym->type), FUNC_REGBANK (sym->type));
+
+
+/* alternate location to find this symbol @ : eg registers
+ or spillication */
+
+ if (!isStructSym)
+ fprintf (cdbFilePtr, "\n");
+
+ return 1;
+}
+
+/******************************************************************
+ *
+ *
+ *
+ *
+ *****************************************************************/
+
+/*-----------------------------------------------------------------*/
+/* cdbTypeInfo - print the type information for debugger */
+/*-----------------------------------------------------------------*/
+void cdbTypeInfo (sym_link * type)
+{
+ fprintf (cdbFilePtr, "{%d}", getSize (type));
+
+ while (type)
+ {
+ if (IS_DECL (type))
+ {
+ switch (DCL_TYPE (type))
+ {
+ case FUNCTION: fprintf (cdbFilePtr, "DF,"); break;
+ case GPOINTER: fprintf (cdbFilePtr, "DG,"); break;
+ case CPOINTER: fprintf (cdbFilePtr, "DC,"); break;
+ case FPOINTER: fprintf (cdbFilePtr, "DX,"); break;
+ case POINTER: fprintf (cdbFilePtr, "DD,"); break;
+ case IPOINTER: fprintf (cdbFilePtr, "DI,"); break;
+ case PPOINTER: fprintf (cdbFilePtr, "DP,"); break;
+ case EEPPOINTER: fprintf (cdbFilePtr, "DA,"); break;
+ case ARRAY: fprintf (cdbFilePtr, "DA%d,", DCL_ELEM (type)); break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (SPEC_NOUN (type))
+ {
+ case V_INT:
+ if (IS_LONG (type))
+ fprintf (cdbFilePtr, "SL");
+ else
+ fprintf (cdbFilePtr, "SI");
+ break;
+
+ case V_CHAR: fprintf (cdbFilePtr, "SC"); break;
+ case V_VOID: fprintf (cdbFilePtr, "SV"); break;
+ case V_FLOAT: fprintf (cdbFilePtr, "SF"); break;
+ case V_STRUCT:
+ fprintf (cdbFilePtr, "ST%s", SPEC_STRUCT (type)->tag);
+ break;
+
+ case V_SBIT: fprintf (cdbFilePtr, "SX"); break;
+ case V_BIT:
+ fprintf (cdbFilePtr, "SB%d$%d", SPEC_BSTR (type),
+ SPEC_BLEN (type));
+ break;
+
+ default:
+ break;
+ }
+ fputs (":", cdbFilePtr);
+ if (SPEC_USIGN (type))
+ fputs ("U", cdbFilePtr);
+ else
+ fputs ("S", cdbFilePtr);
+ }
+ type = type->next;
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#include "SDCCopt.h"
#include "SDCCglue.h"
#include "SDCCpeeph.h"
+#include "SDCCdebug.h"
#include "SDCCutil.h"
#include "asm.h"
/* if debug information required */
if (options.debug && currFunc)
{
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
/* if debug information required */
if (options.debug && currFunc)
{
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
/* if debug information required */
if (options.debug && currFunc) {
if (currFunc) {
- cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC(currFunc->etype)) {
pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__);
/* print extra debug info if required */
if (options.debug || sym->level == 0)
{
-
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
if (!sym->level) /* global */
if (IS_STATIC (sym->etype))
fprintf (map->oFile, "F%s_", moduleName); /* scope is file */
/* print extra debug info if required */
if (options.debug || sym->level == 0)
{
- /* NOTE to me - cdbFile may be null in which case,
- * the sym name will be printed to stdout. oh well */
- if(cdbFile)
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
if (!sym->level)
{ /* global */
if (IS_STATIC (sym->etype))
/* print extra debug info if required */
if (options.debug || sym->level == 0)
{
-
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
if (!sym->level)
{ /* global */
if (IS_STATIC (sym->etype))
/* print the global struct definitions */
if (options.debug)
- cdbStructBlock (0,cdbFile);
+ cdbStructBlock (0);
vFile = tempfile();
/* PENDING: this isnt the best place but it will do */
/* if debug information required */
if (options.debug && currFunc)
{
- cdbSymbol (currFunc, cdbFile, FALSE, TRUE);
+ debugFile->writeFunction(currFunc);
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);