Update svn merge history.
[sdcc.git] / sdcc / src / SDCCdebug.c
blobadc67d4923c0c3fa8e22d8d27e89198a051af38b
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
9 later version.
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 -------------------------------------------------------------------------*/
21 #include "common.h"
23 extern DEBUGFILE cdbDebugFile;
25 DEBUGFILE *debugFile = &cdbDebugFile;
27 void
28 outputDebugStackSymbols (void)
30 if (getenv ("SDCC_DEBUG_VAR_STORAGE"))
32 dumpSymInfo ("XStack", xstack);
33 dumpSymInfo ("IStack", istack);
36 if (options.debug && debugFile)
38 symbol *sym;
40 if (xstack)
42 for (sym = setFirstItem (xstack->syms); sym; sym = setNextItem (xstack->syms))
43 debugFile->writeSymbol (sym);
46 if (istack)
48 for (sym = setFirstItem (istack->syms); sym; sym = setNextItem (istack->syms))
49 debugFile->writeSymbol(sym);
55 void
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)
81 symbol *sym;
83 if(initialized)
85 for (sym = setFirstItem (initialized->syms); sym; sym = setNextItem (initialized->syms))
86 debugFile->writeSymbol (sym);
89 if (data)
91 for (sym = setFirstItem (data->syms); sym; sym = setNextItem (data->syms))
92 debugFile->writeSymbol (sym);
95 if (idata)
97 for (sym = setFirstItem (idata->syms); sym; sym = setNextItem (idata->syms))
98 debugFile->writeSymbol (sym);
101 if (bit)
103 for (sym = setFirstItem (bit->syms); sym; sym = setNextItem (bit->syms))
104 debugFile->writeSymbol (sym);
107 if (pdata)
109 for (sym = setFirstItem (pdata->syms); sym; sym = setNextItem (pdata->syms))
110 debugFile->writeSymbol (sym);
113 if (xdata)
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);
125 if (sfr)
127 for (sym = setFirstItem (sfr->syms); sym; sym = setNextItem (sfr->syms))
128 debugFile->writeSymbol (sym);
131 if (sfrbit)
133 for (sym = setFirstItem (sfrbit->syms); sym; sym = setNextItem (sfrbit->syms))
134 debugFile->writeSymbol (sym);
137 if (home)
139 for (sym = setFirstItem (home->syms); sym; sym = setNextItem (home->syms))
140 debugFile->writeSymbol (sym);
143 if (code)
145 for (sym = setFirstItem (code->syms); sym; sym = setNextItem (code->syms))
146 debugFile->writeSymbol (sym);
149 if (statsg)
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);
162 return;
166 void
167 dumpSymInfo(const char *pcName, memmap *memItem)
169 symbol *sym;
171 if (!memItem)
172 return;
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);
182 if (sym->reqv)
184 int i;
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]));
192 printf ("]\n");
195 printf ("\n");
199 /*------------------------------------------------------------------*/
200 /* emitDebuggerSymbol - call the port specific routine to associate */
201 /* the current code location with a debugger symbol */
202 /*------------------------------------------------------------------*/
203 void
204 emitDebuggerSymbol (const char * debugSym)
206 if (port->debugger.emitDebuggerSymbol)
207 port->debugger.emitDebuggerSymbol (debugSym);