+2004-05-13 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/hc08/gen.c (hc08_emitDebuggerSymbol),
+ * src/hc08/main.c,
+ * src/mcs51/gen.c (mcs51_emitDebuggerSymbol),
+ * src/mcs51/main.c,
+ * src/ds390/gen.c (ds390_emitDebuggerSymbol),
+ * src/ds390/main.c,
+ * src/z80/gen.c (z80_emitDebuggerSymbol),
+ * src/z80/main.c,
+ * src/pic/gen.c (pic14_emitDebuggerSymbol),
+ * src/pic/main.c,
+ * src/pic16/gen.c (pic14_emitDebuggerSymbol),
+ * src/pic16/main.c,
+ * src/avr/gen.c (avr_emitDebuggerSymbol),
+ * src/avr/main.c,
+ * src/xa51/gen.c (xa51_emitDebuggerSymbol),
+ * src/xa51/main.c,
+ * src/SDCCdebug.c (emitDebuggerSymbol),
+ * src/SDCCdebug.h,
+ * src/port.h: added a debugger struct to the port struct. Added a
+ callback for defining debugger symbols
+
+ * src/SDCCast.c (createLabel),
+ * src/SDCC.y (labeled_statement): mark all compiler generated labels
+ with isitmp = 1
+ * src/SDCCicode.h,
+ * src/SDCCicode.c (geniCodeFunctionBody): added a link from the FUNCTION
+ iCode back to the ast for the function
+
+ * src/hc08/ralloc.c (hc08_assignRegisters),
+ * src/hc08/ralloc.h: define a regs struct for the stack pointer. Removed
+ unneeded fields from the regs struct.
+ * src/hc08/gen.c (transferRegReg, genFunction, genEndFunction): use the
+ pushReg() & pullReg() functions instead of emitcode()
+
+ * src/hc08/gen.c (genLabel, genhc08Code),
+ * src/SDCCdebug.h: Added additional debugger hooks needed for DWARF
+
+ * src/cdbFile.c (cdbWriteLabel, cdbWriteScope): Added stubs for unneeded
+ debugger hooks
+
+ * src/hc08/gen.c (genEndFunction, genhc08Code),
+ * src/hc08/gen.h,
+ * src/mcs51/gen.c (genEndFunction, gen51Code),
+ * src/mcs51/gen.h,
+ * src/ds390/gen.c (genEndFunction, gen390Code),
+ * src/ds390/gen.h,
+ * src/z80/gen.c (genEndFunction, genZ80Code),
+ * src/z80/gen.h,
+ * src/z80/z80.h,
+ * src/pic/gen.c (genEndFunction, genpic14Code),
+ * src/pic/gen.h,
+ * src/pic16/gen.c (genEndFunction, genpic16Code),
+ * src/pic16/gen.h,
+ * src/avr/gen.c (genEndFunction, genAVRCode),
+ * src/avr/gen.h,
+ * src/xa51/gen.c (genEndFunction, genXA51Code),
+ * src/xa51/gen.h,
+ * src/cdbFile.c (cdbWriteFunction, cdbWriteEndFunction): moved cdb
+ specific code to cdbFile.c and out of the backend code generators
+
+ * as/hc08/lkmain.c (main): removed OMF51 support from link-hc08
+ * as/hc08/lkarea.c (lnkarea): areas with NOLOAD attribute default
+ starting address is now 0
+
+ * as/hc08/asm.h,
+ * as/hc08/m08pst.c,
+ * as/hc08/asmain.c (asmbl): implemented the .sleb128 and .uleb128
+ assembler directive for DWARF support
+ * as/hc08/lkelf.c (elf): only increment address when rtflg[] set
+
+ * src/src.dsp,
+ * src/Makefile.in,
+ * src/SDCCdwarf2.c: preliminary DWARF (ver 2) debugger data generator
+
2004-05-04 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
* src/hc08/gen.c (genJumpTab, emitcode, genhc08code): fixed stack error
}
-
-
+/*------------------------------------------------------------------*/
+/* emitDebuggerSymbol - call the port specific routine to associate */
+/* the current code location with a debugger symbol */
+/*------------------------------------------------------------------*/
+void
+emitDebuggerSymbol (char * debugSym)
+{
+ if (port->debugger.emitDebuggerSymbol)
+ port->debugger.emitDebuggerSymbol (debugSym);
+}
int (*openFile)(char *file);
int (*closeFile)(void);
int (*writeModule)(char *name);
- int (*writeFunction)(symbol *pSym);
+ int (*writeFunction)(symbol *pSym, iCode *ic);
+ int (*writeEndFunction)(symbol *pSym, iCode *ic, int offset);
+ int (*writeLabel)(symbol *pSym, iCode *ic);
+ int (*writeScope)(iCode *ic);
int (*writeSymbol)(symbol *pSym);
int (*writeType)(structdef *sdef, int block, int inStruct, char *tag);
- int (*writeCLine)(char *module, int Line, int Level, int Block);
+ int (*writeCLine)(iCode *ic);
int (*writeALine)(char *module, int Line);
-
+ int (*writeFrameAddress)(char *variable, struct regs *reg, int offset);
}DEBUGFILE;
extern DEBUGFILE *debugFile;
void outputDebugStackSymbols(void);
void outputDebugSymbols(void);
void dumpSymInfo(char *pcName, memmap *memItem);
+void emitDebuggerSymbol (char * debugSym);
#endif
va_end (ap);
}
+/*-----------------------------------------------------------------*/
+/* avr_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+avr_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
/*-----------------------------------------------------------------*/
/* hasInc - operand is incremented before any other use */
/*-----------------------------------------------------------------*/
if (IFFUNC_ISCRITICAL (sym->type))
emitcode ("sti", "");
+ if (options.debug && currFunc) {
+ debugFile->writeEndFunction (currFunc, ic, 1);
+ }
+
if (IFFUNC_ISISR (sym->type)) {
emitcode ("rti", "");
}
if (allocInfo)
printAllocInfo (currFunc, codeOutFile);
/* if debug information required */
- /* if (options.debug && currFunc) { */
- if (currFunc) {
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
-/* emitcode ("", ".type %s,@function", currFunc->name); */
- _G.debugLine = 0;
+ if (options.debug && currFunc) {
+ debugFile->writeFunction (currFunc, lic);
}
/* stack pointer name */
spname = "sp";
if (cln != ic->lineno) {
if (options.debug) {
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename),
- ic->lineno, ic->level, ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
emitcode (";", "%s %d", ic->filename, ic->lineno);
cln = ic->lineno;
{
1, -1
},
+ {
+ avr_emitDebuggerSymbol
+ },
"_",
_avr_init,
_avr_parseOptions,
va_end (ap);
}
+/*-----------------------------------------------------------------*/
+/* ds390_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+ds390_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
//
// Move the passed value into A unless it is already there.
//
if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
+ if (options.debug && currFunc)
+ debugFile->writeEndFunction (currFunc, ic, 0);
return;
}
/* if debug then send end of function */
if (options.debug && currFunc) {
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("reti", "");
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("ret", "");
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "G$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeFunction (currFunc, lic);
}
/* stack pointer name */
if (options.useXstack)
{
if (options.debug)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), ic->lineno,
- ic->level, ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
if (!options.noCcodeInAsm) {
emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno,
{
2, -1
},
+ {
+ ds390_emitDebuggerSymbol
+ },
"_",
_ds390_init,
_ds390_parseOptions,
{
2, -1
},
+ {
+ ds390_emitDebuggerSymbol
+ },
"",
_tininative_init,
_ds390_parseOptions,
{
2, -1
},
+ {
+ ds390_emitDebuggerSymbol
+ },
"_",
_ds390_init,
_ds390_parseOptions,
char *aopLiteral (value * val, int offset);
char *aopLiteralLong (value * val, int offset, int size);
extern int allocInfo;
+static int pushReg (regs *reg, bool freereg);
+static void pullReg (regs *reg);
static char *zero = "#0x00";
static char *one = "#0x01";
emitcode ("", "%05d$:", (tlbl->key +100));
}
+/*-----------------------------------------------------------------*/
+/* hc08_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+hc08_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
/*--------------------------------------------------------------------------*/
switch (srcidx)
{
case H_IDX: /* H to A */
- emitcode ("pshh", "");
- emitcode ("pula", "");
+ pushReg (hc08_reg_h, FALSE);
+ pullReg (hc08_reg_a);
break;
case X_IDX: /* X to A */
emitcode ("txa", "");
switch (srcidx)
{
case A_IDX: /* A to H */
- emitcode ("psha", "");
- emitcode ("pulh", "");
+ pushReg (hc08_reg_a, FALSE);
+ pullReg (hc08_reg_h);
break;
case X_IDX: /* X to H */
- emitcode ("pshx", "");
- emitcode ("pulh", "");
+ pushReg (hc08_reg_x, FALSE);
+ pullReg (hc08_reg_h);
break;
default:
error=1;
emitcode ("tax", "");
break;
case H_IDX: /* H to X */
- emitcode ("pshh", "");
- emitcode ("pulx", "");
+ pushReg (hc08_reg_h, FALSE);
+ pullReg (hc08_reg_x);
break;
default:
error=1;
switch (srcidx)
{
case XA_IDX: /* XA to HX */
- emitcode ("pshx", "");
- emitcode ("pulh", "");
+ pushReg (hc08_reg_x, FALSE);
+ pullReg (hc08_reg_h);
emitcode ("tax", "");
break;
default:
{
case HX_IDX: /* HX to XA */
emitcode ("txa", "");
- emitcode ("pshh", "");
- emitcode ("pulx", "");
+ pushReg (hc08_reg_h, FALSE);
+ pullReg (hc08_reg_x);
break;
default:
error=1;
hc08_useReg(dreg);
}
+/*--------------------------------------------------------------------------*/
+/* updateCFA - update the debugger information to reflect the current */
+/* connonical frame address relative to the stack pointer */
+/*--------------------------------------------------------------------------*/
+static void
+updateCFA(void)
+{
+ /* there is no frame unless there is a function */
+ if (!currFunc)
+ return;
+
+ debugFile->writeFrameAddress (NULL, hc08_reg_sp,
+ 1 + _G.stackOfs + _G.stackPushes);
+}
+
/*--------------------------------------------------------------------------*/
/* pushReg - Push register reg onto the stack. If freereg is true, reg is */
/* marked free and available for reuse. */
case A_IDX:
emitcode ("psha", "");
_G.stackPushes++;
+ updateCFA();
break;
case X_IDX:
emitcode ("pshx", "");
_G.stackPushes++;
+ updateCFA();
break;
case H_IDX:
emitcode ("pshh", "");
_G.stackPushes++;
+ updateCFA();
break;
case HX_IDX:
emitcode ("pshx", "");
+ _G.stackPushes++;
+ updateCFA();
emitcode ("pshh", "");
- _G.stackPushes += 2;
+ _G.stackPushes++;
+ updateCFA();
break;
case XA_IDX:
emitcode ("psha", "");
+ updateCFA();
+ _G.stackPushes++;
emitcode ("pshx", "");
- _G.stackPushes += 2;
+ updateCFA();
+ _G.stackPushes++;
break;
default:
break;
case A_IDX:
emitcode ("pula", "");
_G.stackPushes--;
+ updateCFA();
break;
case X_IDX:
emitcode ("pulx", "");
_G.stackPushes--;
+ updateCFA();
break;
case H_IDX:
emitcode ("pulh", "");
_G.stackPushes--;
+ updateCFA();
break;
case HX_IDX:
emitcode ("pulx", "");
+ _G.stackPushes--;
+ updateCFA();
emitcode ("pulh", "");
- _G.stackPushes -= 2;
+ _G.stackPushes--;
+ updateCFA();
break;
case XA_IDX:
emitcode ("pula", "");
+ _G.stackPushes--;
+ updateCFA();
emitcode ("pulx", "");
- _G.stackPushes -= 2;
+ _G.stackPushes--;
+ updateCFA();
break;
default:
break;
{
emitcode("ais","#%d",n);
_G.stackPushes -= n;
+ updateCFA();
}
}
static void
adjustStack (int n)
{
- _G.stackPushes -= n;
while (n)
{
if (n>127)
{
emitcode ("ais","#127");
n -= 127;
+ _G.stackPushes -= 127;
+ updateCFA();
}
else if (n<-128)
{
emitcode ("ais","#-128");
n += 128;
+ _G.stackPushes += 128;
+ updateCFA();
}
else
{
emitcode ("ais", "#%d", n);
+ _G.stackPushes -= n;
n = 0;
+ updateCFA();
}
}
}
emitcode ("", "%s:", sym->rname);
ftype = operandType (IC_LEFT (ic));
+
+ _G.stackOfs = 0;
+ _G.stackPushes = 0;
+ debugFile->writeFrameAddress (NULL, hc08_reg_sp, 0);
if (IFFUNC_ISNAKED(ftype))
{
{
if (!inExcludeList ("h"))
- emitcode ("pshh", "");
+ pushReg (hc08_reg_h, FALSE);
}
else
{
if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
+ if (options.debug && currFunc)
+ debugFile->writeEndFunction (currFunc, ic, 0);
return;
}
{
if (!inExcludeList ("h"))
- emitcode ("pulh", "");
+ pullReg (hc08_reg_h);
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("rti", "");
{
if (bitVectBitValue (sym->regsUsed, i) ||
(hc08_ptrRegReq && (i == HX_IDX || i == HX_IDX)))
- emitcode ("pop", "%s", hc08_regWithIdx (i)->dname);
+ emitcode ("pop", "%s", hc08_regWithIdx (i)->name);
}
}
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("rts", "");
/* special case never generate */
if (IC_LABEL (ic) == entryLabel)
return;
+
+ debugFile->writeLabel(IC_LABEL (ic), ic);
emitcode ("", "%05d$:", (IC_LABEL (ic)->key + 100));
}
+
/*-----------------------------------------------------------------*/
/* genhc08Code - generate code for HC08 based controllers */
/*-----------------------------------------------------------------*/
{
iCode *ic;
int cln = 0;
+ int clevel = 0;
+ int cblock = 0;
lineHead = lineCurr = NULL;
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
+ debugFile->writeFunction (currFunc, lic);
+ #if 0
_G.debugLine = 1;
if (IS_STATIC (currFunc->etype))
emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
else
emitcode ("", "G$%s$0$0 ==.", currFunc->name);
_G.debugLine = 0;
+ #endif
}
/* stack pointer name */
if (options.useXstack)
spname = "_spx";
else
spname = "sp";
+
+ debugFile->writeFrameAddress (NULL, NULL, 0); /* have no idea where frame is now */
hc08_aop_pass[0] = newAsmop (AOP_REG);
hc08_aop_pass[0]->size=1;
for (ic = lic; ic; ic = ic->next)
{
+
_G.current_iCode = ic;
+ if (ic->level != clevel || ic->block != cblock)
+ {
+ if (options.debug)
+ {
+ debugFile->writeScope(ic);
+ }
+ clevel = ic->level;
+ cblock = ic->block;
+ }
+
if (ic->lineno && cln != ic->lineno)
{
if (options.debug)
{
+ debugFile->writeCLine(ic);
+ #if 0
_G.debugLine = 1;
emitcode ("", "C$%s$%d$%d$%d ==.",
FileBaseName (ic->filename), ic->lineno,
ic->level, ic->block);
_G.debugLine = 0;
+ #endif
}
if (!options.noCcodeInAsm) {
emitcode ("", ";%s:%d: %s", ic->filename, ic->lineno,
D(emitcode("","; forgot to free xa"));
}
+ debugFile->writeFrameAddress (NULL, NULL, 0); /* have no idea where frame is now */
+
/* now we are ready to call the
peep hole optimizer */
void copyFile(FILE *dest, FILE *src);
extern char * iComments2;
+extern FILE * dwarf2FilePtr;
+extern DEBUGFILE dwarf2DebugFile;
+extern int dwarf2FinalizeFile(void);
static char _defaultRules[] =
{
if (!strcmp (argv[*i], "--out-fmt-elf"))
{
options.out_fmt = 2;
+ debugFile = &dwarf2DebugFile;
return TRUE;
}
}
}
+static void
+_hc08_genAssemblerEnd (FILE * of)
+{
+ if (options.out_fmt == 2 && options.debug)
+ {
+ dwarf2FinalizeFile();
+ copyFile(of, dwarf2FilePtr);
+ }
+}
+
static void
_hc08_genExtraAreas (FILE * asmFile, bool mainExists)
{
}
+/*----------------------------------------------------------------------*/
+/* hc08_dwarfRegNum - return the DWARF register number for a register. */
+/* These are defined for the HC08 in "Motorola 8- and 16-bit Embedded */
+/* Application Binary Interface (M8/16EABI)" */
+/*----------------------------------------------------------------------*/
+static int
+hc08_dwarfRegNum (regs * reg)
+{
+ switch (reg->rIdx)
+ {
+ case A_IDX: return 0;
+ case H_IDX: return 1;
+ case X_IDX: return 2;
+ case CND_IDX: return 17;
+ case SP_IDX: return 15;
+ }
+ return -1;
+}
+
+
/** $1 is always the basename.
$2 is always the output file.
{ _hc08_genExtraAreas,
NULL },
{
- -1, 0, 4, 2, 0, 0
+ -1, /* direction (-1 = stack grows down) */
+ 0, /* bank_overhead (switch between register banks) */
+ 4, /* isr_overhead */
+ 2, /* call_overhead */
+ 0, /* reent_overhead */
+ 0 /* banked_overhead (switch between code banks) */
},
/* hc08 has an 8 bit mul */
{
1, -1
},
+ {
+ hc08_emitDebuggerSymbol,
+ {
+ hc08_dwarfRegNum,
+ NULL,
+ NULL,
+ 4, /* addressSize */
+ 14, /* regNumRet */
+ 15, /* regNumSP */
+ -1, /* regNumBP */
+ 1, /* offsetSP */
+ },
+ },
"_",
_hc08_init,
_hc08_parseOptions,
_hc08_getRegName,
_hc08_keywords,
_hc08_genAssemblerPreamble,
- NULL, /* no genAssemblerEnd */
+ _hc08_genAssemblerEnd, /* no genAssemblerEnd */
_hc08_genIVT,
_hc08_genXINIT,
NULL, /* genInitStartup */
va_end (ap);
}
+/*-----------------------------------------------------------------*/
+/* mcs51_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+mcs51_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
/*-----------------------------------------------------------------*/
/* mova - moves specified value into accumulator */
/*-----------------------------------------------------------------*/
if (IFFUNC_ISNAKED(sym->type))
{
emitcode(";", "naked function: no epilogue.");
+ if (options.debug && currFunc)
+ debugFile->writeEndFunction (currFunc, ic, 0);
return;
}
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("reti", "");
/* if debug then send end of function */
if (options.debug && currFunc)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "XF%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "XG$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
emitcode ("ret", "");
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "G$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeFunction (currFunc, lic);
}
/* stack pointer name */
if (options.useXstack)
{
if (options.debug)
{
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), ic->lineno,
- ic->level, ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine(ic);
}
if (!options.noCcodeInAsm) {
emitcode ("", ";%s:%d: %s", ic->filename, ic->lineno,
{
1, -1
},
+ {
+ mcs51_emitDebuggerSymbol
+ },
"_",
_mcs51_init,
_mcs51_parseOptions,
va_end(ap);
}
+/*-----------------------------------------------------------------*/
+/* pic14_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+pic14_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ pic14_emitcode ("", ";%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
/*-----------------------------------------------------------------*/
/* getFreePtr - returns r0 or r1 whichever is free or can be pushed*/
/* if debug then send end of function */
/* if (options.debug && currFunc) { */
if (currFunc) {
- _G.debugLine = 1;
- pic14_emitcode(";","C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),currFunc->lastLine,
- ic->level,ic->block);
- if (IS_STATIC(currFunc->etype))
- pic14_emitcode(";","XF%s$%s$0$0 ==.",moduleName,currFunc->name);
- else
- pic14_emitcode(";","XG$%s$0$0 ==.",currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
pic14_emitcode ("reti","");
/* if debug then send end of function */
if (currFunc) {
- _G.debugLine = 1;
- pic14_emitcode(";","C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),currFunc->lastLine,
- ic->level,ic->block);
- if (IS_STATIC(currFunc->etype))
- pic14_emitcode(";","XF%s$%s$0$0 ==.",moduleName,currFunc->name);
- else
- pic14_emitcode(";","XG$%s$0$0 ==.",currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
pic14_emitcode ("return","");
/* if debug information required */
if (options.debug && currFunc) {
if (currFunc) {
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
- if (IS_STATIC(currFunc->etype)) {
- pic14_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__);
- //addpCode2pBlock(pb,newpCodeLabel(moduleName,currFunc->name));
- } else {
- pic14_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__);
- //addpCode2pBlock(pb,newpCodeLabel(NULL,currFunc->name));
- }
- _G.debugLine = 0;
+ debugFile->writeFunction (currFunc, lic);
}
}
DEBUGpic14_emitcode(";ic","");
if ( cln != ic->lineno ) {
if ( options.debug ) {
- _G.debugLine = 1;
- pic14_emitcode("",";C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),ic->lineno,
- ic->level,ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
/*
pic14_emitcode("#CSRC","%s %d",FileBaseName(ic->filename),ic->lineno);
void pic14_assignRegisters (eBBlock ** ebbs, int count);
+/* Also defined in gen.h, but the #include is commented out */
+/* for an unknowned reason. - EEP */
+void pic14_emitDebuggerSymbol (char *);
+
static int regParmFlg = 0; /* determine if we can register a parameter */
static void
{
1, -1
},
+ {
+ pic14_emitDebuggerSymbol
+ },
"_",
_pic14_init,
_pic14_parseOptions,
}
#endif
+/*-----------------------------------------------------------------*/
+/* pic16_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+pic16_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ pic16_emitcode (";", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
/*-----------------------------------------------------------------*/
/* getFreePtr - returns r0 or r1 whichever is free or can be pushed*/
/* if debug then send end of function */
/* if (options.debug && currFunc) */
if (currFunc) {
- _G.debugLine = 1;
- pic16_emitcode(";","C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),currFunc->lastLine,
- ic->level,ic->block);
- if (IS_STATIC(currFunc->etype))
- pic16_emitcode(";","XF%s$%s$0$0 ==.",moduleName,currFunc->name);
- else
- pic16_emitcode(";","XG$%s$0$0 ==.",currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
pic16_emitpcodeNULLop(POC_RETFIE);
pic16_emitpcomment("%s: _G.nRegsSaved upon exit from function: %d\n", __FUNCTION__, _G.nRegsSaved);
/* if debug then send end of function */
if (currFunc) {
- _G.debugLine = 1;
- pic16_emitcode(";","C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),currFunc->lastLine,
- ic->level,ic->block);
- if (IS_STATIC(currFunc->etype))
- pic16_emitcode(";","XF%s$%s$0$0 ==.",moduleName,currFunc->name);
- else
- pic16_emitcode(";","XG$%s$0$0 ==.",currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
/* insert code to restore stack frame, if user enabled it
if (options.debug && currFunc) {
if (currFunc) {
cdbSymbol(currFunc,cdbFile,FALSE,TRUE);
- _G.debugLine = 1;
- if (IS_STATIC(currFunc->etype)) {
- pic16_emitcode("",";F%s$%s$0$0 %d",moduleName,currFunc->name,__LINE__);
- //pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(moduleName,currFunc->name));
- } else {
- pic16_emitcode("",";G$%s$0$0 %d",currFunc->name,__LINE__);
- //pic16_addpCode2pBlock(pb,pic16_newpCodeLabel(NULL,currFunc->name));
- }
- _G.debugLine = 0;
}
}
#endif
DEBUGpic16_emitcode(";ic ", "\t%c 0x%x",ic->op, ic->op);
if ( cln != ic->lineno ) {
if ( options.debug ) {
- _G.debugLine = 1;
- pic16_emitcode("",";C$%s$%d$%d$%d ==.",
- FileBaseName(ic->filename),ic->lineno,
- ic->level,ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
if(!options.noCcodeInAsm) {
pic16_options_t pic16_options;
+/* Also defined in gen.h, but the #include is commented out */
+/* for an unknowned reason. - EEP */
+void pic16_emitDebuggerSymbol (char *);
+
static void
_pic16_init (void)
{
{
1, -1
},
+ {
+ pic16_emitDebuggerSymbol
+ },
"_",
_pic16_init,
_pic16_parseOptions,
}
support;
+ struct
+ {
+ void (*emitDebuggerSymbol) (char *);
+ struct
+ {
+ int (*regNum) (struct regs *);
+ bitVect * cfiSame;
+ bitVect * cfiUndef;
+ int addressSize;
+ int regNumRet;
+ int regNumSP;
+ int regNumBP;
+ int offsetSP;
+ }
+ dwarf;
+ }
+ debugger;
+
/** Prefix to add to a C function (eg "_") */
const char *fun_prefix;
va_end (ap);
}
+/*-----------------------------------------------------------------*/
+/* xa51_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+xa51_emitDebuggerSymbol (char * debugSym)
+{
+ _G.debugLine = 1;
+ emitcode ("", "%s ==.", debugSym);
+ _G.debugLine = 0;
+}
+
+
char *getStackOffset(int stack) {
static char gsoBuf[1024];
sprintf (gsoBuf, "r7+(%d%+d%+d)", stack,
if (IFFUNC_ISNAKED(sym->type)) {
emitcode(";", "naked function: no epilogue.");
+ if (options.debug && currFunc)
+ debugFile->writeEndFunction (currFunc, ic, 0);
return;
}
emitcode ("add", "r7,#%d\t; release stack space for locals", sym->stack);
}
+ if (options.debug && currFunc) {
+ debugFile->writeEndFunction (currFunc, ic, 1);
+ }
+
if (IFFUNC_ISISR(sym->type)) {
emitcode ("reti", "");
} else {
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
- _G.debugLine = 1;
- if (IS_STATIC (currFunc->etype))
- emitcode ("", "F%s$%s$0$0 ==.", moduleName, currFunc->name);
- else
- emitcode ("", "G$%s$0$0 ==.", currFunc->name);
- _G.debugLine = 0;
+ debugFile->writeFunction (currFunc, lic);
}
for (ic = lic; ic; ic = ic->next) {
if (ic->lineno && cln != ic->lineno) {
if (options.debug) {
- _G.debugLine = 1;
- emitcode ("", "C$%s$%d$%d$%d ==.",
- FileBaseName (ic->filename), ic->lineno,
- ic->level, ic->block);
- _G.debugLine = 0;
+ debugFile->writeCLine (ic);
}
if (!options.noCcodeInAsm) {
emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno,
{
2, -2
},
+ {
+ xa51_emitDebuggerSymbol
+ },
"_",
_xa51_init,
_xa51_parseOptions,
}
}
+/*-----------------------------------------------------------------*/
+/* z80_emitDebuggerSymbol - associate the current code location */
+/* with a debugger symbol */
+/*-----------------------------------------------------------------*/
+void
+z80_emitDebuggerSymbol (char * debugSym)
+{
+ _G.lines.isDebug = 1;
+ emit2 ("%s !equ .", debugSym);
+ emit2 ("!global", debugSym);
+ _G.lines.isDebug = 0;
+}
+
/*-----------------------------------------------------------------*/
/* emit2 - writes the code into a file : for now it is simple */
/*-----------------------------------------------------------------*/
if (options.debug && currFunc)
{
- _G.lines.isDebug = 1;
- sprintf (buffer, "C$%s$%d$%d$%d",
- FileBaseName (ic->filename), currFunc->lastLine,
- ic->level, ic->block);
- emit2 ("!labeldef", buffer);
- if (IS_STATIC (currFunc->etype))
- sprintf (buffer, "XF%s$%s$0$0", moduleName, currFunc->name);
- else
- sprintf (buffer, "XG$%s$0$0", currFunc->name);
- emit2 ("!labeldef", buffer);
- _G.lines.isDebug = 0;
+ debugFile->writeEndFunction (currFunc, ic, 1);
}
/* Both banked and non-banked just ret */
/* if debug information required */
if (options.debug && currFunc)
{
- debugFile->writeFunction(currFunc);
- _G.lines.isDebug = 1;
- if (IS_STATIC (currFunc->etype))
- sprintf (buffer, "F%s$%s$0$0", moduleName, currFunc->name);
- else
- sprintf (buffer, "G$%s$0$0", currFunc->name);
- emit2 ("!labeldef", buffer);
- _G.lines.isDebug = 0;
+ debugFile->writeFunction (currFunc, lic);
}
for (ic = lic; ic; ic = ic->next)
{
if (options.debug)
{
- _G.lines.isDebug = 1;
- sprintf (buffer, "C$%s$%d$%d$%d",
- FileBaseName (ic->filename), ic->lineno,
- ic->level, ic->block);
- emit2 ("%s !equ .", buffer);
- emit2 ("!global", buffer);
- _G.lines.isDebug = 0;
+ debugFile->writeCLine (ic);
}
if (!options.noCcodeInAsm) {
emit2 (";%s:%d: %s", ic->filename, ic->lineno,
{
0, 2
},
+ {
+ z80_emitDebuggerSymbol
+ },
"_",
_z80_init,
_parseOptions,
{
0, 2
},
+ {
+ z80_emitDebuggerSymbol
+ },
"_",
_gbz80_init,
_parseOptions,