{
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);
}
break;
case DW_AT_location:
case DW_AT_frame_base:
- dwWriteWord (NULL, ap->val.loclist->baseOffset, NULL);
+ dwWriteWord ("Ldebug_loc_start", ap->val.loclist->baseOffset, NULL);
break;
default:
dwWriteWord (NULL, ap->val.data, NULL);
if (!strncmp (includeDir, filename, strlen (includeDir))
&& strlen (filename) > strlen (includeDir))
{
- if (*(filename+strlen (includeDir)) == DIR_SEPARATOR_CHAR)
+ if (IS_DIR_SEPARATOR(filename[strlen (includeDir)]))
break;
}
}
curOffset = lp->offset;
dwWriteByte (NULL, DW_LNS_advance_line, NULL);
- dwWriteULEB128 (NULL, lp->line - 1, NULL);
+ dwWriteSLEB128 (NULL, lp->line - 1, NULL);
curLine = lp->line;
dwWriteByte (NULL, DW_LNS_copy, NULL);
curOffset = lp->offset;
dwWriteByte (NULL, DW_LNS_advance_line, NULL);
- dwWriteULEB128 (NULL, deltaLine, NULL);
+ dwWriteSLEB128 (NULL, deltaLine, NULL);
curLine = lp->line;
dwWriteByte (NULL, DW_LNS_copy, NULL);
{
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))
dwtag * modtp;
dwtag * subtp;
int key;
+ int tableUpdated = 0;
key = dwHashType (type) % dwTypeTagTable->size;
oldtp = hTabFindByKey (dwTypeTagTable, key, type, dwMatchTypes);
/* 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)
{
dwtag * memtp;
dwloc * lp;
-
+
+ if (IS_BITFIELD (field->type) && !SPEC_BLEN(field->type))
+ {
+ field = field->next;
+ continue;
+ }
+
memtp = dwNewTag (DW_TAG_member);
if (*(field->name))
dwAddTagAttr (memtp, dwNewAttrString (DW_AT_name,
field->name));
- subtp = dwTagFromType (field->type, tp);
- dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp));
- if (!subtp->parent)
- dwAddTagChild (parent, subtp);
+ if (IS_BITFIELD (field->type))
+ {
+ int blen = SPEC_BLEN (field->type);
+ int bstr = SPEC_BSTR (field->type);
+ sym_link * type;
+
+ dwAddTagAttr (memtp,
+ dwNewAttrConst (DW_AT_byte_size,
+ (blen+7)/8));
+ dwAddTagAttr (memtp,
+ dwNewAttrConst (DW_AT_bit_size, blen));
+ dwAddTagAttr (memtp,
+ dwNewAttrConst (DW_AT_bit_offset,
+ ((blen+7) & ~7)
+ - (blen+bstr)));
+ if (blen < 8)
+ type = typeFromStr ("uc");
+ else
+ type = typeFromStr ("ui");
+ subtp = dwTagFromType (type, tp);
+ dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp));
+ }
+ else
+ {
+ subtp = dwTagFromType (field->type, tp);
+ dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp));
+ if (!subtp->parent)
+ dwAddTagChild (parent, subtp);
+ }
lp = dwNewLoc (DW_OP_plus_uconst, NULL, field->offset);
dwAddTagAttr (memtp,
getSize (type)));
dwAddTagChild (dwRootTag, tp);
break;
+
+ case V_FIXED16X16:
+ tp = dwNewTag (DW_TAG_base_type);
+ dwAddTagAttr (tp, dwNewAttrConst (DW_AT_encoding,
+ DW_ATE_float));
+ dwAddTagAttr (tp, dwNewAttrString (DW_AT_name, "fixed16x16"));
+ dwAddTagAttr (tp, dwNewAttrConst (DW_AT_byte_size,
+ getSize (type)));
+ dwAddTagChild (dwRootTag, tp);
+ break;
case V_CHAR:
tp = dwNewTag (DW_TAG_base_type);
}
}
- hTabAddItemLong (&dwTypeTagTable, key, type, tp);
+ if (!tableUpdated)
+ hTabAddItemLong (&dwTypeTagTable, key, type, tp);
+ if (!tp->parent)
+ dwAddTagChild (parent, tp);
return tp;
}
/*------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
-/* dwOpenFile - opens a temporary file for debugging information */
+/* dwOpenFile - open the debugging file (just initialize, since all */
+/* DWARF data goes into the assembly output file) */
/*-----------------------------------------------------------------------*/
int dwOpenFile(char *file)
{
- dwarf2FilePtr = tempfile();
- if(!dwarf2FilePtr) return 0;
-
dwTypeTagTable = newHashTable (128);
return 1;
}
/*-----------------------------------------------------------------------*/
-/* dwCloseFile - close (and deletes) the temporary file for debugging */
-/* information */
+/* dwCloseFile - close the debugging file (do nothing, since all DWARF */
+/* data goes into the assembly output file) */
/*-----------------------------------------------------------------------*/
int dwCloseFile(void)
{
- if(!dwarf2FilePtr) return 0;
-
- fclose(dwarf2FilePtr);
-
return 1;
}
dwattr * funcap;
int inregs = 0;
- if (!sym->level)
+ if (!sym->level || IS_EXTERN (sym->etype))
scopetp = dwRootTag;
else
{
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. */
dwtag * tp;
value * args;
- if(!dwarf2FilePtr) return 0;
-
dwFuncTag = tp = dwNewTag (DW_TAG_subprogram);
dwAddTagAttr (dwFuncTag, dwNewAttrString (DW_AT_name, sym->name));
/*-----------------------------------------------------------------------*/
int dwWriteEndFunction(symbol *sym, iCode *ic, int offset)
{
- char debugSym[SDCC_NAME_MAX];
+ char debugSym[SDCC_NAME_MAX + 1];
if (ic)
{
}
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);
/*-----------------------------------------------------------------------*/
int dwWriteLabel(symbol *sym, iCode *ic)
{
- char debugSym[SDCC_NAME_MAX];
+ char debugSym[SDCC_NAME_MAX + 1];
dwtag * tp;
/* ignore the compiler generated labels */
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);
int dwWriteModule(char *name)
{
dwtag * tp;
+ char verid[125];
- if(!dwarf2FilePtr) return 0;
+ dwModuleName = Safe_strdup (name);
+ sprintf(verid, "SDCC version %s #%s", SDCC_VERSION_STR, getBuildNumber());
+
tp = dwNewTag (DW_TAG_compile_unit);
- dwAddTagAttr (tp, dwNewAttrString (DW_AT_producer, "SDCC version "
- SDCC_VERSION_STR));
+ dwAddTagAttr (tp, dwNewAttrString (DW_AT_producer, verid));
+
dwAddTagAttr (tp, dwNewAttrConst (DW_AT_language, DW_LANG_C89));
dwAddTagAttr (tp, dwNewAttrString (DW_AT_name, fullSrcFileName));
dwline * lp;
char * debugSym;
- if(!dwarf2FilePtr) return 0;
-
lp = Safe_alloc (sizeof (dwline));
lp->line = ic->lineno;
dwloc * lp;
int regNum;
- if(!dwarf2FilePtr) return 0;
-
/* If there was a region open, close it */
if (dwFrameLastLoc)
{
/*-----------------------------------------------------------------------*/
int dwWriteALine(char *module, int Line)
{
- if(!dwarf2FilePtr) return 0;
-
return 1;
}
/* debug file */
/*-----------------------------------------------------------------------*/
int
-dwarf2FinalizeFile(void)
+dwarf2FinalizeFile(FILE *of)
{
int tagAddress = 11;
int abbrevNum = 0;
int attr;
-
- if(!dwarf2FilePtr) return 1;
+ dwarf2FilePtr = of;
+
/* Write the .debug_line section */
dwWriteLineNumbers ();