diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-25 01:05:12 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-25 01:05:12 +0200 |
| commit | 4de313f145d3c9bde748306f48443aadef6cf774 (patch) | |
| tree | ba07672dc4d3c59705957d721c5cb1bad95c2cdb /src | |
| parent | 9d2f975be4bd8e9d8f15eb0d013944e46b00c8d2 (diff) | |
| download | sdcc-gas-4de313f145d3c9bde748306f48443aadef6cf774.tar.gz | |
DWARF2 debugging (almost) working
Stack pointer setup is removed since it is already set to 0x3FF
for the STM8S003F3/K3, according to the datasheet.
Diffstat (limited to 'src')
| -rw-r--r-- | src/SDCCasm.c | 6 | ||||
| -rw-r--r-- | src/SDCCdwarf2.c | 50 | ||||
| -rw-r--r-- | src/SDCCglue.c | 15 | ||||
| -rw-r--r-- | src/SDCCsymt.c | 5 | ||||
| -rw-r--r-- | src/stm8/gen.c | 20 |
5 files changed, 47 insertions, 49 deletions
diff --git a/src/SDCCasm.c b/src/SDCCasm.c index ef92103..e6db1c8 100644 --- a/src/SDCCasm.c +++ b/src/SDCCasm.c @@ -402,7 +402,7 @@ err_no_line: static const ASM_MAPPING _gas_mapping[] = { {"labeldef", "%s:"}, - {"slabeldef", "%s:"}, + {"slabeldef", ".%s:"}, {"tlabeldef", "%05d$:"}, {"tlabel", "%05d$"}, {"immed", "#"}, @@ -449,6 +449,7 @@ static const ASM_MAPPING _gas_mapping[] = { {"hihihil", "(%05d$ >> 24)"}, {"equ", "="}, {"org", ".org 0x%04X"}, + {"noload", ", \"\""}, {0} }; @@ -501,6 +502,7 @@ static const ASM_MAPPING _asxxxx_mapping[] = { {"hihihil", "(%05d$ >> 24)"}, {"equ", "="}, {"org", ".org 0x%04X"}, + {"noload", "(NOLOAD)"}, {NULL, NULL} }; @@ -553,6 +555,7 @@ static const ASM_MAPPING _asxxxx_smallpdk_mapping[] = { {"hihihil", "(%05d$ >> 24)"}, {"equ", "="}, {"org", ".org 0x%04X"}, + {"noload", "(NOLOAD)"}, {NULL, NULL} }; @@ -605,6 +608,7 @@ static const ASM_MAPPING _a390_mapping[] = { {"hihihil", "((L%09d / 16777216) & 0FFh)"}, {"equ", " equ"}, {"org", ".org 0x%04X"}, + {"noload", "(NOLOAD)"}, {NULL, NULL} }; diff --git a/src/SDCCdwarf2.c b/src/SDCCdwarf2.c index 7322b4b..25eb4bb 100644 --- a/src/SDCCdwarf2.c +++ b/src/SDCCdwarf2.c @@ -49,6 +49,7 @@ int dwWriteALine (const char *module, int Line); int dwWriteFrameAddress (const char *variable, struct reg_info *reg, int offset); int dwWriteBasicSymbol (symbol *sym, int isStructSym, int isFunc); +#define LOCAL_LABEL(str) "." str DEBUGFILE dwarf2DebugFile = { @@ -101,7 +102,7 @@ dwNewDebugSymbol (void) char debugSym[SDCC_NAME_MAX]; if (options.gasOutput) - sprintf (debugSym, "%s_%s_%d$", dwModuleName, currFunc->name, dwDebugSymbol); + sprintf (debugSym, LOCAL_LABEL("L%s_%s_%d"), dwModuleName, currFunc->name, dwDebugSymbol); else sprintf (debugSym, "S%s$%s$%d", dwModuleName, currFunc->name, dwDebugSymbol); @@ -729,7 +730,7 @@ dwWriteLocLists (void) dwlocregion * lrp; dwloclist * llp; - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_loc (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_loc"); tfprintf (dwarf2FilePtr, "!slabeldef\n", "Ldebug_loc_start"); llp = dwRootLocList; @@ -1007,7 +1008,7 @@ dwWriteAttr (dwattr * ap) break; case DW_AT_location: case DW_AT_frame_base: - dwWriteWord ("Ldebug_loc_start", ap->val.loclist->baseOffset, NULL); + dwWriteWord (LOCAL_LABEL ("Ldebug_loc_start"), ap->val.loclist->baseOffset, NULL); break; default: dwWriteWord (NULL, ap->val.data, NULL); @@ -1345,7 +1346,7 @@ dwWriteAbbrevs (void) dwattr * ap; int key; - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_abbrev (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_abbrev"); tfprintf (dwarf2FilePtr, "!slabeldef\n", "Ldebug_abbrev"); tp = hTabFirstItem (dwAbbrevTable, &key); @@ -1411,15 +1412,15 @@ dwWriteTag (dwtag *tp, void *info) static void dwWriteTags (void) { - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_info (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_info"); - dwWriteWordDelta ("Ldebug_info_end", "Ldebug_info_start"); + dwWriteWordDelta (LOCAL_LABEL ("Ldebug_info_end"), LOCAL_LABEL ("Ldebug_info_start")); tfprintf (dwarf2FilePtr, "!slabeldef\n", "Ldebug_info_start"); dwWriteHalf (NULL, 2, NULL); /* DWARF version */ - dwWriteWord ("Ldebug_abbrev", 0, NULL); + dwWriteWord (LOCAL_LABEL ("Ldebug_abbrev"), 0, NULL); dwWriteByte (NULL, port->debugger.dwarf.addressSize, NULL); @@ -1528,16 +1529,15 @@ dwWritePubnames (void) dwattr * ap1; dwattr * ap2; - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_pubnames (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_pubnames"); - dwWriteWordDelta ("Ldebug_pubnames_end", "Ldebug_pubnames_start"); + dwWriteWordDelta (LOCAL_LABEL ("Ldebug_pubnames_end"), LOCAL_LABEL ("Ldebug_pubnames_start")); tfprintf (dwarf2FilePtr, "!slabeldef\n", "Ldebug_pubnames_start"); dwWriteHalf (NULL, 2, NULL); /* DWARF version */ - - dwWriteWord ("Ldebug_info_start-4", 0, NULL); - dwWriteWordDelta ("4+Ldebug_info_end", "Ldebug_info_start"); + dwWriteWord (LOCAL_LABEL ("Ldebug_info_start")"-4", 0, NULL); + dwWriteWordDelta ("4+"LOCAL_LABEL ("Ldebug_info_end"), LOCAL_LABEL ("Ldebug_info_start")); if (dwRootTag && dwRootTag->firstChild) { @@ -1754,15 +1754,15 @@ dwWriteLineNumbers (void) dwfile * srcfile; dwline * lp; - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_line (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_line"); - dwWriteWordDelta ("Ldebug_line_end", "Ldebug_line_start"); + dwWriteWordDelta (LOCAL_LABEL ("Ldebug_line_end"), LOCAL_LABEL ("Ldebug_line_start")); tfprintf (dwarf2FilePtr, "!slabeldef\n", "Ldebug_line_start"); dwWriteHalf (NULL, 2, NULL); /* DWARF version */ - dwWriteWordDelta ("Ldebug_line_stmt-6", "Ldebug_line_start"); + dwWriteWordDelta (LOCAL_LABEL ("Ldebug_line_stmt") "-6", LOCAL_LABEL ("Ldebug_line_start")); dwWriteByte (NULL, 1, NULL); /* we track everything in 1 byte increments */ @@ -1974,12 +1974,13 @@ dwGenCFIins (int callsize, int id) int i; char s[32]; - tfprintf (dwarf2FilePtr, "\n\t!area\n", ".debug_frame (NOLOAD)"); + tfprintf (dwarf2FilePtr, "\n\t!area!noload\n", ".debug_frame"); /* FIXME: these two dw should be combined into a dd */ tfprintf (dwarf2FilePtr, "\t!dw\t0\n"); tfprintf (dwarf2FilePtr, "\t!dw\t"); - tfprintf (dwarf2FilePtr, "Ldebug_CIE%d_end-Ldebug_CIE%d_start\n", id, id); + + tfprintf (dwarf2FilePtr, "4+" LOCAL_LABEL ("Ldebug_CIE")"%d_end-" LOCAL_LABEL ("Ldebug_CIE") "%d_start\n", id, id); snprintf(s, sizeof(s), "Ldebug_CIE%d_start", id); tfprintf (dwarf2FilePtr, "!slabeldef\n", s); @@ -2060,7 +2061,7 @@ dwWriteFDE (dwfde * fp, int id) //CIE ptr char s[32]; - snprintf(s, sizeof(s), "Ldebug_CIE%d_start-4", id); + snprintf(s, sizeof(s), LOCAL_LABEL ("Ldebug_CIE") "%d_start-4", id); dwWriteWord (s, 0, NULL); //initial loc @@ -2799,7 +2800,6 @@ dwWriteSymbolInternal (symbol *sym) return 1; } - /*-----------------------------------------------------------------------*/ /* dwWriteFunction - generate a tag for a function. */ /*-----------------------------------------------------------------------*/ @@ -2884,10 +2884,14 @@ dwWriteEndFunction (symbol *sym, iCode *ic, int offset) dwLineLast->end_sequence = 1; } - if (IS_STATIC (sym->etype)) - sprintf (debugSym, "XF%s$%s$0$0", dwModuleName, sym->name); + if (!options.gasOutput) + if (IS_STATIC (sym->etype)) + sprintf (debugSym, "XF%s$%s$0$0", dwModuleName, sym->name); + else + sprintf (debugSym, "XG$%s$0$0", sym->name); else - sprintf (debugSym, "XG$%s$0$0", sym->name); + sprintf (debugSym, LOCAL_LABEL("L%s_%sendf"), dwModuleName, sym->name); + emitDebuggerSymbol (debugSym); dwAddTagAttr (dwFuncTag, dwNewAttrAddrLabel (DW_AT_high_pc, @@ -3035,7 +3039,7 @@ dwWriteModule (const char *name) dwAddTagAttr (tp, dwNewAttrString (DW_AT_name, fullSrcFileName)); dwAddTagAttr (tp, dwNewAttrLabelRef (DW_AT_stmt_list, - "Ldebug_line_start", -4)); + LOCAL_LABEL ("Ldebug_line_start"), -4)); dwRootTag = tp; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 9255137..a2ed613 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -2512,26 +2512,15 @@ glue (void) /* create the stack segment MOF */ if (mainf && IFFUNC_HASBODY (mainf->type)) { - const char *const start_stack = "__start__stack"; const unsigned int size = 1; fprintf (asmFile, "%s", iComments2); fprintf (asmFile, "; Stack segment in internal ram \n"); fprintf (asmFile, "%s", iComments2); - if (options.gasOutput) - { - char section_name[100]; - - snprintf( section_name, sizeof section_name / sizeof *section_name, - ".%s", start_stack); - /* Set alloc/write flags. */ - tfprintf(asmFile, "\t!area , \"aw\"\n", section_name); - tfprintf(asmFile, "\t!local\n", start_stack); - tfprintf(asmFile, "\t!comm\n\n", start_stack, size, 1); - } - else + if (!options.gasOutput) { + const char *const start_stack = "__start__stack"; tfprintf(asmFile, "\t!area\n", "SSEG"); tfprintf(asmFile, "\t!labeldef\n", start_stack); tfprintf(asmFile, "\t!ds\n\n", size); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index ec45d1a..5215a8f 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -334,7 +334,8 @@ newSymbol (const char *name, long scope) sym->for_newralloc = 0; sym->isinscope = 1; sym->usl.spillLoc = 0; - sym->funcDivFlagSafe = 0; +#warning Please check this + sym->funcDivFlagSafe = 1; sym->funcUsesVolatile = 1; return sym; @@ -4407,7 +4408,7 @@ initCSupport (void) dbuf_init (&dbuf, 128); dbuf_printf (&dbuf, "_%s%s%s", srlrr[slsr], ssu[su * 3], sbwd[bwd]); rlrr[slsr][bwd][su] = sym = - funcOfTypeVarg (_mangleFunctionName (dbuf_c_str (&dbuf)), + funcOfTypeVarg (_mangleFunctionName (dbuf_c_str (&dbuf)), sbwdCodes[bwd + 4*su], 2, ¶ms[0]); FUNC_ISREENT (sym->type) = options.intlong_rent ? 1 : 0; FUNC_NONBANKED (sym->type) = 1; diff --git a/src/stm8/gen.c b/src/stm8/gen.c index 7dd5101..91dd7c7 100644 --- a/src/stm8/gen.c +++ b/src/stm8/gen.c @@ -3385,16 +3385,6 @@ genFunction (iCode *ic) emit2 (";", " function %s", sym->name); emit2 (";", "-----------------------------------------"); - /* Place each new function into its own section so GNU ld - * can perform dead code elimination via --gc-sections. */ - if (options.function_sections && options.gasOutput) - { - char name[256]; - - snprintf(name, sizeof name, "%s.%s", CODE_NAME, sym->name); - emit2(".section", " %s", name); - } - D (emit2 (";", stm8_assignment_optimal ? "Register assignment is optimal." : "Register assignment might be sub-optimal.")); D (emit2 (";", "Stack space usage: %d bytes.", sym->stack)); @@ -8200,6 +8190,16 @@ genSTM8Code (iCode *lic) int cln = 0; regalloc_dry_run = FALSE; + /* Place each new function into its own section so GNU ld + * can perform dead code elimination via --gc-sections. */ + if (options.function_sections && options.gasOutput && currFunc) + { + char name[256]; + + snprintf(name, sizeof name, "%s.%s", CODE_NAME, currFunc->rname); + emit2(".section", " %s", name); + } + /* if debug information required */ if (options.debug && currFunc && !regalloc_dry_run) debugFile->writeFunction (currFunc, lic); |
