From: epetrich Date: Fri, 14 May 2004 06:30:27 +0000 (+0000) Subject: * src/SDCCdwarf2.c (dwMatchTypes): structs must have matching X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=5a40e91827f3aa24cbfbab9b7e68c38d2df90e9d;p=fw%2Fsdcc * src/SDCCdwarf2.c (dwMatchTypes): structs must have matching SPEC_STRUCT * src/SDCCdwarf2.c (dwTagFromType): fix to handle recursive struct definitions * src/SDCCdwarf2.c (dwWriteModule, dwNewDebugSymbol, dwWriteEndFunction, dwWriteLabel): fix to create valid debugger symbols even when the module name has non-alphanumeric symbols in it * src/SDCCdwarf2.c (dwWriteSymbolInternal): better detection for when a variable's allocation has been optimized away git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3306 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 52320484..b4bcdbd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-05-14 Erik Petrich + + * src/SDCCdwarf2.c (dwMatchTypes): structs must have matching + SPEC_STRUCT + * src/SDCCdwarf2.c (dwTagFromType): fix to handle recursive + struct definitions + * src/SDCCdwarf2.c (dwWriteModule, dwNewDebugSymbol, dwWriteEndFunction, + dwWriteLabel): fix to create valid debugger symbols even when + the module name has non-alphanumeric symbols in it + * src/SDCCdwarf2.c (dwWriteSymbolInternal): better detection for + when a variable's allocation has been optimized away + + 2004-05-13 Erik Petrich * src/hc08/gen.c (hc08_emitDebuggerSymbol), diff --git a/src/SDCCdwarf2.c b/src/SDCCdwarf2.c index 5a9c22c8..50c24ab3 100644 --- a/src/SDCCdwarf2.c +++ b/src/SDCCdwarf2.c @@ -98,7 +98,7 @@ dwNewDebugSymbol () { char debugSym[SDCC_NAME_MAX]; - sprintf (debugSym, "S%s$%s$%d", moduleName, currFunc->name, dwDebugSymbol); + sprintf (debugSym, "S%s$%s$%d", dwModuleName, currFunc->name, dwDebugSymbol); dwDebugSymbol++; return Safe_strdup (debugSym); } @@ -2107,6 +2107,9 @@ dwMatchTypes (const void * type1v, const void * type2v) { if (SPEC_NOUN (type1) != SPEC_NOUN (type2)) return 0; + if (SPEC_NOUN (type1) == V_STRUCT + && SPEC_STRUCT (type1) != SPEC_STRUCT (type2)) + return 0; if (SPEC_CONST (type1) != SPEC_CONST (type2)) return 0; if (SPEC_VOLATILE (type1) != SPEC_VOLATILE (type2)) @@ -2163,6 +2166,7 @@ dwTagFromType (sym_link * type, dwtag * parent) dwtag * modtp; dwtag * subtp; int key; + int tableUpdated = 0; key = dwHashType (type) % dwTypeTagTable->size; oldtp = hTabFindByKey (dwTypeTagTable, key, type, dwMatchTypes); @@ -2257,6 +2261,12 @@ dwTagFromType (sym_link * type, dwtag * parent) /* is a complete type */ dwAddTagAttr (tp, dwNewAttrConst (DW_AT_byte_size, getSize (type))); + + /* Must add this before processing the struct fields */ + /* in case there is a recursive definition. */ + hTabAddItemLong (&dwTypeTagTable, key, type, tp); + tableUpdated = 1; + field = sdp->fields; while (field) { @@ -2381,7 +2391,10 @@ dwTagFromType (sym_link * type, dwtag * parent) } } - hTabAddItemLong (&dwTypeTagTable, key, type, tp); + if (!tableUpdated) + hTabAddItemLong (&dwTypeTagTable, key, type, tp); + if (!tp->parent) + dwAddTagChild (parent, tp); return tp; } /*------------------------------------------------------------------------*/ @@ -2595,12 +2608,15 @@ dwWriteSymbolInternal (symbol *sym) else if (symloc->onStack) { /* stack allocation */ - lp = dwNewLoc (DW_OP_fbreg, NULL, sym->stack); + lp = dwNewLoc (DW_OP_fbreg, NULL, symloc->stack); } else { /* global allocation */ - lp = dwNewLoc (DW_OP_addr, sym->rname, 0); + if (sym->level && !sym->allocreq) + lp = NULL; + else + lp = dwNewLoc (DW_OP_addr, symloc->rname, 0); } /* Only create the DW_AT_location if a known location exists. */ @@ -2700,7 +2716,7 @@ int dwWriteEndFunction(symbol *sym, iCode *ic, int offset) } if (IS_STATIC (sym->etype)) - sprintf (debugSym, "XF%s$%s$0$0", moduleName, sym->name); + sprintf (debugSym, "XF%s$%s$0$0", dwModuleName, sym->name); else sprintf (debugSym, "XG$%s$0$0", sym->name); emitDebuggerSymbol (debugSym); @@ -2735,7 +2751,7 @@ int dwWriteLabel(symbol *sym, iCode *ic) if (sym->isitmp) return 1; - sprintf (debugSym, "L%s$%s$%s", moduleName, currFunc->name, sym->name); + sprintf (debugSym, "L%s$%s$%s", dwModuleName, currFunc->name, sym->name); emitDebuggerSymbol (debugSym); tp = dwNewTag (DW_TAG_label); @@ -2827,9 +2843,15 @@ int dwWriteType(structdef *sdef, int block, int inStruct, char *tag) int dwWriteModule(char *name) { dwtag * tp; + char * s; if(!dwarf2FilePtr) return 0; + dwModuleName = Safe_strdup (name); + for (s = dwModuleName; *s; s++) + if (ispunct (*s) || isspace (*s)) + *s = '_'; + tp = dwNewTag (DW_TAG_compile_unit); dwAddTagAttr (tp, dwNewAttrString (DW_AT_producer, "SDCC version " SDCC_VERSION_STR));