* src/SDCCdwarf2.c (dwMatchTypes): structs must have matching
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 14 May 2004 06:30:27 +0000 (06:30 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 14 May 2004 06:30:27 +0000 (06:30 +0000)
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

ChangeLog
src/SDCCdwarf2.c

index 523204848aa0b4265afee13ad2caf2af8538b856..b4bcdbd53c1cff158ae102ff4d593c46500064b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-05-14 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * 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 <epetrich AT ivorytower.norman.ok.us>
 
        * src/hc08/gen.c (hc08_emitDebuggerSymbol),
index 5a9c22c80c2a0b234ca4d624e85e6d5a84f7734b..50c24ab35ec7a22aca0b94146d029151b2208d95 100644 (file)
@@ -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));