1 /*-------------------------------------------------------------------------
2 SDCCdebug.c - source file for debug infrastructure
4 Copyright (C) 2003, Lenny Story and Bernhard Held
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 -------------------------------------------------------------------------*/
23 extern DEBUGFILE cdbDebugFile
;
25 DEBUGFILE
*debugFile
= &cdbDebugFile
;
28 outputDebugStackSymbols (void)
30 if (getenv ("SDCC_DEBUG_VAR_STORAGE"))
32 dumpSymInfo ("XStack", xstack
);
33 dumpSymInfo ("IStack", istack
);
36 if (options
.debug
&& debugFile
)
42 for (sym
= setFirstItem (xstack
->syms
); sym
; sym
= setNextItem (xstack
->syms
))
43 debugFile
->writeSymbol (sym
);
48 for (sym
= setFirstItem (istack
->syms
); sym
; sym
= setNextItem (istack
->syms
))
49 debugFile
->writeSymbol(sym
);
56 outputDebugSymbols (void)
58 if (getenv ("SDCC_DEBUG_VAR_STORAGE"))
60 dumpSymInfo ("Initialized", initialized
);
61 dumpSymInfo ("Code", code
);
62 dumpSymInfo ("Data", data
);
63 dumpSymInfo ("PData", pdata
);
64 dumpSymInfo ("XData", xdata
);
65 dumpSymInfo ("XIData", xidata
);
66 dumpSymInfo ("XInit", xinit
);
67 dumpSymInfo ("IData", idata
);
68 dumpSymInfo ("Bit", bit
);
69 dumpSymInfo ("Statics", statsg
);
70 dumpSymInfo ("SFR", sfr
);
71 dumpSymInfo ("SFRBits", sfrbit
);
72 dumpSymInfo ("Reg", reg
);
73 dumpSymInfo ("Generic", generic
);
74 dumpSymInfo ("Overlay", overlay
);
75 dumpSymInfo ("EEProm", eeprom
);
76 dumpSymInfo ("Home", home
);
79 if (options
.debug
&& debugFile
)
85 for (sym
= setFirstItem (initialized
->syms
); sym
; sym
= setNextItem (initialized
->syms
))
86 debugFile
->writeSymbol (sym
);
91 for (sym
= setFirstItem (data
->syms
); sym
; sym
= setNextItem (data
->syms
))
92 debugFile
->writeSymbol (sym
);
97 for (sym
= setFirstItem (idata
->syms
); sym
; sym
= setNextItem (idata
->syms
))
98 debugFile
->writeSymbol (sym
);
103 for (sym
= setFirstItem (bit
->syms
); sym
; sym
= setNextItem (bit
->syms
))
104 debugFile
->writeSymbol (sym
);
109 for (sym
= setFirstItem (pdata
->syms
); sym
; sym
= setNextItem (pdata
->syms
))
110 debugFile
->writeSymbol (sym
);
115 for (sym
= setFirstItem (xdata
->syms
); sym
; sym
= setNextItem (xdata
->syms
))
116 debugFile
->writeSymbol (sym
);
119 if (port
->genXINIT
&& xidata
)
121 for (sym
= setFirstItem (xidata
->syms
); sym
; sym
= setNextItem (xidata
->syms
))
122 debugFile
->writeSymbol (sym
);
127 for (sym
= setFirstItem (sfr
->syms
); sym
; sym
= setNextItem (sfr
->syms
))
128 debugFile
->writeSymbol (sym
);
133 for (sym
= setFirstItem (sfrbit
->syms
); sym
; sym
= setNextItem (sfrbit
->syms
))
134 debugFile
->writeSymbol (sym
);
139 for (sym
= setFirstItem (home
->syms
); sym
; sym
= setNextItem (home
->syms
))
140 debugFile
->writeSymbol (sym
);
145 for (sym
= setFirstItem (code
->syms
); sym
; sym
= setNextItem (code
->syms
))
146 debugFile
->writeSymbol (sym
);
151 for (sym
= setFirstItem (statsg
->syms
); sym
; sym
= setNextItem (statsg
->syms
))
152 debugFile
->writeSymbol (sym
);
155 if (port
->genXINIT
&& xinit
)
157 for (sym
= setFirstItem (xinit
->syms
); sym
; sym
= setNextItem (xinit
->syms
))
158 debugFile
->writeSymbol (sym
);
167 dumpSymInfo(const char *pcName
, memmap
*memItem
)
174 printf ("--------------------------------------------\n");
175 printf (" %s\n", pcName
);
177 for (sym
= setFirstItem (memItem
->syms
); sym
; sym
= setNextItem (memItem
->syms
))
179 printf (" %s, isReqv:%d, reqv:0x%p, onStack:%d, Stack:%d, nRegs:%d, [",
180 sym
->rname
, sym
->isreqv
, (void*)(sym
->reqv
), sym
->onStack
, sym
->stack
, sym
->nRegs
);
185 symbol
*TempSym
= OP_SYMBOL (sym
->reqv
);
187 for (i
= 0; i
< 4; i
++)
188 if (TempSym
->regs
[i
])
189 printf ("%s,", port
->getRegName (TempSym
->regs
[i
]));
199 /*------------------------------------------------------------------*/
200 /* emitDebuggerSymbol - call the port specific routine to associate */
201 /* the current code location with a debugger symbol */
202 /*------------------------------------------------------------------*/
204 emitDebuggerSymbol (const char * debugSym
)
206 if (port
->debugger
.emitDebuggerSymbol
)
207 port
->debugger
.emitDebuggerSymbol (debugSym
);