X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FcdbFile.c;h=149fac225d7592f8c302b35ea6e6343ef95be93e;hb=5a1d5e778e85664f4e6657019348b4756b16eacb;hp=ea9e55598254bcbafff8af7439165dbc8a7fa81b;hpb=c4864c92486eda75766c5a0d29fe7edd07147e74;p=fw%2Fsdcc diff --git a/src/cdbFile.c b/src/cdbFile.c index ea9e5559..149fac22 100644 --- a/src/cdbFile.c +++ b/src/cdbFile.c @@ -12,12 +12,16 @@ int cdbOpenFile(char *file); int cdbCloseFile(void); -int cdbWriteFunction(symbol *pSym); +int cdbWriteFunction(symbol *pSym, iCode *ic); +int cdbWriteEndFunction(symbol *pSym, iCode *ic, int offset); +int cdbWriteLabel(symbol *pSym, iCode *ic); +int cdbWriteScope(iCode *ic); 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 cdbWriteCLine(iCode *ic); int cdbWriteALine(char *module, int Line); +int cdbWriteFrameAddress(char *variable, struct regs *reg, int offset); int cdbWriteBasicSymbol(symbol *sym, int isStructSym, int isFunc); void cdbTypeInfo (sym_link * type); @@ -28,15 +32,46 @@ DEBUGFILE cdbDebugFile = &cdbCloseFile, &cdbWriteModule, &cdbWriteFunction, + &cdbWriteEndFunction, + &cdbWriteLabel, + &cdbWriteScope, &cdbWriteSymbol, &cdbWriteType, &cdbWriteCLine, - &cdbWriteALine + &cdbWriteALine, + &cdbWriteFrameAddress }; FILE *cdbFilePtr = NULL; char *cdbModuleName = NULL; +/****************************************************************** + * spacesToUnderscores - replace all non alpha-numerics with + * underscores + * + * + *****************************************************************/ + +static char * +spacesToUnderscores (char *dest, const char *src, size_t len) +{ + unsigned int i; + char *p; + + assert(dest != NULL); + assert(src != NULL); + assert(len > 0); + + --len; + for (p = dest, i = 0; *src != '\0' && i < len; ++src, ++i) { + *p++ = (isspace((unsigned char)*src) || (*src == '-')) ? '_' : *src; + } + *p = '\0'; + + return dest; +} + + /****************************************************************** * * @@ -79,17 +114,93 @@ int cdbCloseFile(void) * *****************************************************************/ -int cdbWriteFunction(symbol *pSym) +int cdbWriteFunction(symbol *pSym, iCode *ic) { + char debugSym[INITIAL_INLINEASM]; + if (getenv("SDCC_DEBUG_FUNCTION_POINTERS")) fprintf (stderr, "cdbFile.c:cdbWriteFunction()\n"); if(!cdbFilePtr) return 0; + if (IS_STATIC (pSym->etype)) + sprintf (debugSym, "F%s$%s$0$0", moduleName, pSym->name); + else + sprintf (debugSym, "G$%s$0$0", pSym->name); + emitDebuggerSymbol (debugSym); + return cdbWriteBasicSymbol(pSym, FALSE, TRUE); } +/****************************************************************** + * + * + * + * + *****************************************************************/ + +int cdbWriteEndFunction(symbol *pSym, iCode *ic, int offset) +{ + char debugSym[INITIAL_INLINEASM]; + + if (getenv("SDCC_DEBUG_FUNCTION_POINTERS")) + fprintf (stderr, "cdbFile.c:cdbWriteEndFunction()\n"); + + if(!cdbFilePtr) return 0; + + if (ic) + { + sprintf (debugSym, "C$%s$%d$%d$%d", + FileBaseName (ic->filename), pSym->lastLine, + ic->level, ic->block); + spacesToUnderscores (debugSym, debugSym, sizeof (debugSym)); + emitDebuggerSymbol (debugSym); + } + + if (IS_STATIC (pSym->etype)) + sprintf (debugSym, "XF%s$%s$0$0", moduleName, pSym->name); + else + sprintf (debugSym, "XG$%s$0$0", pSym->name); + emitDebuggerSymbol (debugSym); + + return 1; +} + +/****************************************************************** + * + * + * + * + *****************************************************************/ + +int cdbWriteLabel(symbol *pSym, iCode *ic) +{ + if (getenv("SDCC_DEBUG_FUNCTION_POINTERS")) + fprintf (stderr, "cdbFile.c:cdbWriteLabel()\n"); + + if(!cdbFilePtr) return 0; + + return 1; +} + +/****************************************************************** + * + * + * + * + *****************************************************************/ + +int cdbWriteScope(iCode *ic) +{ + if (getenv("SDCC_DEBUG_FUNCTION_POINTERS")) + fprintf (stderr, "cdbFile.c:cdbWriteScope()\n"); + + if(!cdbFilePtr) return 0; + + return 1; +} + /****************************************************************** * * @@ -171,9 +282,17 @@ int cdbWriteModule(char *name) * * *****************************************************************/ -int cdbWriteCLine(char *module, int Line, int Level, int Block) +int cdbWriteCLine(iCode *ic) { + char debugSym[INITIAL_INLINEASM]; + if(!cdbFilePtr) return 0; + + sprintf (debugSym, "C$%s$%d$%d$%d", + FileBaseName (ic->filename), ic->lineno, + ic->level, ic->block); + spacesToUnderscores (debugSym, debugSym, sizeof (debugSym)); + emitDebuggerSymbol (debugSym); return 1; } @@ -192,6 +311,23 @@ int cdbWriteALine(char *module, int Line) return 1; } +/****************************************************************** + * + * + * + * + *****************************************************************/ + +int cdbWriteFrameAddress(char *variable, struct regs *reg, int offset) +{ + if (getenv("SDCC_DEBUG_FUNCTION_POINTERS")) + fprintf (stderr, "cdbFile.c:cdbWriteFrameAddress()\n"); + + if(!cdbFilePtr) return 0; + + return 1; +} + /****************************************************************** * * @@ -244,7 +380,7 @@ int cdbWriteBasicSymbol(symbol *sym, int isStructSym, int isFunc) fprintf (cdbFilePtr, "),"); /* CHECK FOR REGISTER SYMBOL... */ - if(sym->reqv) + if (!sym->allocreq && sym->reqv) { int a; symbol *TempSym = OP_SYMBOL (sym->reqv); @@ -332,6 +468,7 @@ void cdbTypeInfo (sym_link * type) case V_CHAR: fprintf (cdbFilePtr, "SC"); break; case V_VOID: fprintf (cdbFilePtr, "SV"); break; case V_FLOAT: fprintf (cdbFilePtr, "SF"); break; + case V_FIXED16X16: fprintf(cdbFilePtr, "SQ"); break; case V_STRUCT: fprintf (cdbFilePtr, "ST%s", SPEC_STRUCT (type)->tag); break;