* src/hc08/gen.c (hc08_emitDebuggerSymbol),
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 13 May 2004 21:51:54 +0000 (21:51 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 13 May 2004 21:51:54 +0000 (21:51 +0000)
* 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

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3304 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
ChangeLog
src/SDCCdebug.c
src/SDCCdebug.h
src/avr/gen.c
src/avr/main.c
src/ds390/gen.c
src/ds390/main.c
src/hc08/gen.c
src/hc08/main.c
src/mcs51/gen.c
src/mcs51/main.c
src/pic/gen.c
src/pic/main.c
src/pic16/gen.c
src/pic16/main.c
src/port.h
src/xa51/gen.c
src/xa51/main.c
src/z80/gen.c
src/z80/main.c

index 1520e3115e6a31190e48e0dea6727f1a26d3d86c..523204848aa0b4265afee13ad2caf2af8538b856 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,79 @@
+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
index b07aaf2ecd1f3a6399e8de83ada1d8c6bb9549c3..8885d7ca01ae6354f56b904a00b8d46cd0fb29bf 100644 (file)
@@ -149,5 +149,13 @@ void dumpSymInfo(char *pcName, memmap *memItem)
 }
 
 
-
-
+/*------------------------------------------------------------------*/
+/* 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);
+}
index cd4b5bf933bedd97de393474e677b39797143c86..24fb826359a11f0b67496ccb916ec9de19e796c5 100644 (file)
@@ -7,12 +7,15 @@ typedef struct DebugFile
   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;
@@ -20,5 +23,6 @@ extern DEBUGFILE *debugFile;
 void outputDebugStackSymbols(void);
 void outputDebugSymbols(void);
 void dumpSymInfo(char *pcName, memmap *memItem);
+void emitDebuggerSymbol (char * debugSym);
 
 #endif
index 68eca463be1d66aa408c97230b59cff87579db25..5993a46c7f2aaa02915370ac52bd9b4d7799a293 100644 (file)
@@ -261,6 +261,18 @@ emitcode (char *inst, char *fmt, ...)
        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            */
 /*-----------------------------------------------------------------*/
@@ -1815,6 +1827,10 @@ genEndFunction (iCode * ic)
        if (IFFUNC_ISCRITICAL (sym->type))
                emitcode ("sti", "");
 
+       if (options.debug && currFunc) {
+               debugFile->writeEndFunction (currFunc, ic, 1);
+       }
+
        if (IFFUNC_ISISR (sym->type)) {
                emitcode ("rti", "");
        }
@@ -5113,12 +5129,8 @@ genAVRCode (iCode * lic)
        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";
@@ -5128,11 +5140,7 @@ genAVRCode (iCode * lic)
 
                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;
index 8b98bae14cfd5777e1fea032d01db35ecdc3ea7a..d0faac3cdc4d01d97b26a6d997ba2fc67da429c7 100644 (file)
@@ -227,6 +227,9 @@ PORT avr_port = {
        {
           1, -1
         },
+       {
+          avr_emitDebuggerSymbol
+       },
        "_",
        _avr_init,
        _avr_parseOptions,
index e5670acc03530c9791114e466cfdc17316beaeed..0e077df19c4891b5118e7dec75a454f30cd16bfb 100644 (file)
@@ -187,6 +187,18 @@ emitcode (char *inst, char *fmt,...)
     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.
 // 
@@ -3254,6 +3266,8 @@ genEndFunction (iCode * ic)
   if (IFFUNC_ISNAKED(sym->type))
   {
       emitcode(";", "naked function: no epilogue.");
+      if (options.debug && currFunc)
+       debugFile->writeEndFunction (currFunc, ic, 0);
       return;
   }
 
@@ -3407,15 +3421,7 @@ genEndFunction (iCode * ic)
 
       /* 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", "");
@@ -3441,15 +3447,7 @@ genEndFunction (iCode * ic)
       /* 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", "");
@@ -13383,13 +13381,7 @@ gen390Code (iCode * lic)
   /* 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)
@@ -13407,11 +13399,7 @@ gen390Code (iCode * lic)
        {
          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, 
index 211e9dc180239627d96e1b8227fb1b48fe5e8c89..2a9889e3a912db974b12504f07fb921c4663057a 100644 (file)
@@ -867,6 +867,9 @@ PORT ds390_port =
   {
     2, -1
   },
+  {
+    ds390_emitDebuggerSymbol
+  },
   "_",
   _ds390_init,
   _ds390_parseOptions,
@@ -1166,6 +1169,9 @@ PORT tininative_port =
   {
     2, -1
   },
+  {
+    ds390_emitDebuggerSymbol
+  },
   "",
   _tininative_init,
   _ds390_parseOptions,
@@ -1380,6 +1386,9 @@ PORT ds400_port =
   {
     2, -1
   },
+  {
+    ds390_emitDebuggerSymbol
+  },
   "_",
   _ds390_init,
   _ds390_parseOptions,
index 68f5ec34181a226e3458a1ba56444aa383ffab87..de90e142ed559077833e28fcfdad4fdce9e9965d 100644 (file)
@@ -45,6 +45,8 @@
 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";
@@ -187,6 +189,17 @@ emitLabel (symbol *tlbl)
   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;
+}
 
 
 /*--------------------------------------------------------------------------*/
@@ -228,8 +241,8 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
         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", "");
@@ -242,12 +255,12 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
         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;
@@ -260,8 +273,8 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
               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;
@@ -271,8 +284,8 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
         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:
@@ -284,8 +297,8 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
           {
             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;
@@ -306,6 +319,21 @@ transferRegReg (regs *sreg, regs *dreg, bool freesrc)
   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.                           */
@@ -320,24 +348,33 @@ pushReg (regs *reg, bool freereg)
       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;
@@ -360,24 +397,33 @@ pullReg (regs *reg)
       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;
@@ -396,6 +442,7 @@ pullNull (int n)
     {
       emitcode("ais","#%d",n);
       _G.stackPushes -= n;
+      updateCFA();
     }
 }
 
@@ -434,23 +481,28 @@ pullOrFreeReg (regs *reg, bool needpull)
 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();
         }
     }    
 }
@@ -2798,6 +2850,10 @@ genFunction (iCode * ic)
 
   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))
   {
@@ -2813,7 +2869,7 @@ genFunction (iCode * ic)
     {
 
       if (!inExcludeList ("h"))
-       emitcode ("pshh", "");
+        pushReg (hc08_reg_h, FALSE);
     }
   else
     {
@@ -2895,6 +2951,8 @@ genEndFunction (iCode * ic)
   if (IFFUNC_ISNAKED(sym->type))
   {
       emitcode(";", "naked function: no epilogue.");
+      if (options.debug && currFunc)
+        debugFile->writeEndFunction (currFunc, ic, 0);
       return;
   }
 
@@ -2936,21 +2994,13 @@ genEndFunction (iCode * ic)
     {
 
       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", "");
@@ -2969,7 +3019,7 @@ genEndFunction (iCode * ic)
                {
                  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);
                }
            }
 
@@ -2978,15 +3028,7 @@ genEndFunction (iCode * ic)
       /* 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", "");
@@ -3081,6 +3123,8 @@ genLabel (iCode * ic)
   /* special case never generate */
   if (IC_LABEL (ic) == entryLabel)
     return;
+         
+  debugFile->writeLabel(IC_LABEL (ic), ic);
 
   emitcode ("", "%05d$:", (IC_LABEL (ic)->key + 100));
 
@@ -7554,6 +7598,7 @@ genEndCritical (iCode *ic)
 }
 
 
+
 /*-----------------------------------------------------------------*/
 /* genhc08Code - generate code for HC08 based controllers          */
 /*-----------------------------------------------------------------*/
@@ -7562,6 +7607,8 @@ genhc08Code (iCode * lic)
 {
   iCode *ic;
   int cln = 0;
+  int clevel = 0;
+  int cblock = 0;
 
   lineHead = lineCurr = NULL;
 
@@ -7571,19 +7618,23 @@ genhc08Code (iCode * lic)
   /* 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;
@@ -7600,17 +7651,31 @@ genhc08Code (iCode * lic)
 
   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, 
@@ -7898,6 +7963,8 @@ genhc08Code (iCode * lic)
         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 */
index 16761b6ebdf744bc2de62629f724b7db60c7b4af..aa2cbb0cf7cb1b65ed2cddeebba8899812ebba5a 100644 (file)
@@ -12,6 +12,9 @@
 
 void copyFile(FILE *dest, FILE *src);
 extern char * iComments2;
+extern FILE * dwarf2FilePtr;
+extern DEBUGFILE dwarf2DebugFile;
+extern int dwarf2FinalizeFile(void);
 
 static char _defaultRules[] =
 {
@@ -99,6 +102,7 @@ _hc08_parseOptions (int *pargc, char **argv, int *i)
   if (!strcmp (argv[*i], "--out-fmt-elf"))
     {
       options.out_fmt = 2;
+      debugFile = &dwarf2DebugFile;
       return TRUE;
     }
     
@@ -231,6 +235,16 @@ _hc08_genAssemblerPreamble (FILE * of)
     }
 }
 
+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)
 {
@@ -330,6 +344,26 @@ oclsExpense (struct memmap *oclass)
 }
 
 
+/*----------------------------------------------------------------------*/
+/* 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.
@@ -406,12 +440,30 @@ PORT hc08_port =
   { _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,
@@ -422,7 +474,7 @@ PORT hc08_port =
   _hc08_getRegName,
   _hc08_keywords,
   _hc08_genAssemblerPreamble,
-  NULL,                                /* no genAssemblerEnd */
+  _hc08_genAssemblerEnd,       /* no genAssemblerEnd */
   _hc08_genIVT,
   _hc08_genXINIT,
   NULL,                        /* genInitStartup */
index 0fb8581b8f4e987ba01af7300448a49c6ade7d4b..861f4fc78377fbf3f57b66e57ad539d83154b606 100644 (file)
@@ -150,6 +150,18 @@ emitcode (char *inst, const char *fmt,...)
   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                   */
 /*-----------------------------------------------------------------*/
@@ -2864,6 +2876,8 @@ genEndFunction (iCode * ic)
   if (IFFUNC_ISNAKED(sym->type))
   {
       emitcode(";", "naked function: no epilogue.");
+      if (options.debug && currFunc)
+       debugFile->writeEndFunction (currFunc, ic, 0);
       return;
   }
 
@@ -2997,15 +3011,7 @@ genEndFunction (iCode * ic)
       /* 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", "");
@@ -3038,15 +3044,7 @@ genEndFunction (iCode * ic)
       /* 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", "");
@@ -9892,13 +9890,7 @@ gen51Code (iCode * lic)
   /* 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)
@@ -9915,11 +9907,7 @@ gen51Code (iCode * lic)
        {
          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,
index c0a49d15374834a5916c68c38d6d42fe79f467e1..d484941277740b3e67c6a56c7d2f0f0371d01fe8 100644 (file)
@@ -712,6 +712,9 @@ PORT mcs51_port =
   {
     1, -1
   },
+  {
+    mcs51_emitDebuggerSymbol
+  },
   "_",
   _mcs51_init,
   _mcs51_parseOptions,
index 89e46791ef2adaa92c7353ad19e29b6c074fd2c1..fb1868b1000048f0a40a558c5c0162e1fd1a7082 100644 (file)
@@ -265,6 +265,18 @@ void pic14_emitcode (char *inst,char *fmt, ...)
   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*/
@@ -2871,15 +2883,7 @@ registers :-) */
     /* 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","");
@@ -2914,15 +2918,7 @@ registers :-) */
     
     /* 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","");
@@ -9875,16 +9871,7 @@ void genpic14Code (iCode *lic)
   /* 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);
     }
   }
   
@@ -9894,11 +9881,7 @@ void genpic14Code (iCode *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);
index a84d1bc8050122c8419d470bd3226677f16db153..2d5fedb5ab9b5836cda4ac5c7fe38be3c4be0b95 100644 (file)
@@ -51,6 +51,10 @@ void  pCodeInitRegisters(void);
 
 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
@@ -453,6 +457,9 @@ PORT pic_port =
        {
                1, -1
        },
+       {
+               pic14_emitDebuggerSymbol
+       },
        "_",
        _pic14_init,
        _pic14_parseOptions,
index dc423a941370b34efdff32b49b27f10dcde90d2b..5ba5432747b5e260276a6d7147f7927c04ee9989 100644 (file)
@@ -330,6 +330,17 @@ void pic16_emitcode (char *inst,char *fmt, ...)
 }
 #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*/
@@ -3511,15 +3522,7 @@ static void genEndFunction (iCode *ic)
                /* 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);
@@ -3556,15 +3559,7 @@ static void genEndFunction (iCode *ic)
                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
@@ -11237,15 +11232,6 @@ void genpic16Code (iCode *lic)
     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
@@ -11255,11 +11241,7 @@ void genpic16Code (iCode *lic)
       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) {
index 6c98fb22d3934f1f8f29ed09807fe2f92936e905..d295080d1ad48cc608923ccc8a8bec9b50e587fb 100644 (file)
@@ -82,6 +82,10 @@ static int regParmFlg = 0;   /* determine if we can register a parameter */
 
 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)
 {
@@ -806,6 +810,9 @@ PORT pic16_port =
   {
     1, -1
   },
+  {
+    pic16_emitDebuggerSymbol
+  },
   "_",
   _pic16_init,
   _pic16_parseOptions,
index e3c08ae7287575aa952b27fa88a435174039d08c..2005ddfd89a30cd477db76a6f33fdebb7e28f77b 100644 (file)
@@ -195,6 +195,24 @@ typedef struct
       }
     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;
 
index 8a5a2b16bc54c24d1758e5d1423cc188c305f803..f30aed63336070f666a7aa870ab154c5f8ee1d2a 100755 (executable)
@@ -124,6 +124,19 @@ static void emitcode (char *inst, char *fmt,...) {
   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,
@@ -829,6 +842,8 @@ genEndFunction (iCode * ic)
 
   if (IFFUNC_ISNAKED(sym->type)) {
       emitcode(";", "naked function: no epilogue.");
+      if (options.debug && currFunc)
+       debugFile->writeEndFunction (currFunc, ic, 0);
       return;
   }
 
@@ -837,6 +852,10 @@ genEndFunction (iCode * ic)
     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 {
@@ -1912,23 +1931,13 @@ void genXA51Code (iCode * lic) {
   /* 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,
index 51bc27f574d05d898cc0da77a6aaac30e6ff97c8..99f2b902fcbb2bf9ff2e14c39ad93bb7cadfbd84 100755 (executable)
@@ -301,6 +301,9 @@ PORT xa51_port =
   {
     2, -2
   },
+  {
+    xa51_emitDebuggerSymbol
+  },
   "_",
   _xa51_init,
   _xa51_parseOptions,
index 281dc7baf33604390278b63dfe7b4cc5a983d4eb..f61ad62454a34e901d97cd781ea137bfbb74cfe7 100644 (file)
@@ -442,6 +442,19 @@ emitDebug (const char *szFormat,...)
     }
 }
 
+/*-----------------------------------------------------------------*/
+/* 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    */
 /*-----------------------------------------------------------------*/
@@ -3254,17 +3267,7 @@ genEndFunction (iCode * ic)
 
       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 */
@@ -7835,14 +7838,7 @@ genZ80Code (iCode * lic)
   /* 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)
@@ -7853,13 +7849,7 @@ genZ80Code (iCode * lic)
        {
          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,
index d2a21845b73279fa445bc33b892412ccb5141529..55fb58d01a202823fac7a60b35edcb06ab9a2a14 100644 (file)
@@ -623,6 +623,9 @@ PORT z80_port =
   {
     0, 2
   },
+  {
+    z80_emitDebuggerSymbol
+  },
   "_",
   _z80_init,
   _parseOptions,
@@ -724,6 +727,9 @@ PORT gbz80_port =
   {
     0, 2
   },
+  {
+    z80_emitDebuggerSymbol
+  },
   "_",
   _gbz80_init,
   _parseOptions,