diff options
| author | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
|---|---|---|
| committer | Xavier ASUS <xavi92psx@gmail.com> | 2019-10-18 00:31:54 +0200 |
| commit | 268a53de823a6750d6256ee1fb1e7707b4b45740 (patch) | |
| tree | 42c1799a9a82b2f7d9790ee9fe181d72a7274751 /src/SDCCdebug.c | |
| download | sdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz | |
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'src/SDCCdebug.c')
| -rw-r--r-- | src/SDCCdebug.c | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/src/SDCCdebug.c b/src/SDCCdebug.c new file mode 100644 index 0000000..adc67d4 --- /dev/null +++ b/src/SDCCdebug.c @@ -0,0 +1,208 @@ +/*------------------------------------------------------------------------- + SDCCdebug.c - source file for debug infrastructure + + Copyright (C) 2003, Lenny Story and Bernhard Held + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +-------------------------------------------------------------------------*/ + +#include "common.h" + +extern DEBUGFILE cdbDebugFile; + +DEBUGFILE *debugFile = &cdbDebugFile; + +void +outputDebugStackSymbols (void) +{ + if (getenv ("SDCC_DEBUG_VAR_STORAGE")) + { + dumpSymInfo ("XStack", xstack); + dumpSymInfo ("IStack", istack); + } + + if (options.debug && debugFile) + { + symbol *sym; + + if (xstack) + { + for (sym = setFirstItem (xstack->syms); sym; sym = setNextItem (xstack->syms)) + debugFile->writeSymbol (sym); + } + + if (istack) + { + for (sym = setFirstItem (istack->syms); sym; sym = setNextItem (istack->syms)) + debugFile->writeSymbol(sym); + } + } +} + + +void +outputDebugSymbols (void) +{ + if (getenv ("SDCC_DEBUG_VAR_STORAGE")) + { + dumpSymInfo ("Initialized", initialized); + dumpSymInfo ("Code", code); + dumpSymInfo ("Data", data); + dumpSymInfo ("PData", pdata); + dumpSymInfo ("XData", xdata); + dumpSymInfo ("XIData", xidata); + dumpSymInfo ("XInit", xinit); + dumpSymInfo ("IData", idata); + dumpSymInfo ("Bit", bit); + dumpSymInfo ("Statics", statsg); + dumpSymInfo ("SFR", sfr); + dumpSymInfo ("SFRBits", sfrbit); + dumpSymInfo ("Reg", reg); + dumpSymInfo ("Generic", generic); + dumpSymInfo ("Overlay", overlay); + dumpSymInfo ("EEProm", eeprom); + dumpSymInfo ("Home", home); + } + + if (options.debug && debugFile) + { + symbol *sym; + + if(initialized) + { + for (sym = setFirstItem (initialized->syms); sym; sym = setNextItem (initialized->syms)) + debugFile->writeSymbol (sym); + } + + if (data) + { + for (sym = setFirstItem (data->syms); sym; sym = setNextItem (data->syms)) + debugFile->writeSymbol (sym); + } + + if (idata) + { + for (sym = setFirstItem (idata->syms); sym; sym = setNextItem (idata->syms)) + debugFile->writeSymbol (sym); + } + + if (bit) + { + for (sym = setFirstItem (bit->syms); sym; sym = setNextItem (bit->syms)) + debugFile->writeSymbol (sym); + } + + if (pdata) + { + for (sym = setFirstItem (pdata->syms); sym; sym = setNextItem (pdata->syms)) + debugFile->writeSymbol (sym); + } + + if (xdata) + { + for (sym = setFirstItem (xdata->syms); sym; sym = setNextItem (xdata->syms)) + debugFile->writeSymbol (sym); + } + + if (port->genXINIT && xidata) + { + for (sym = setFirstItem (xidata->syms); sym; sym = setNextItem (xidata->syms)) + debugFile->writeSymbol (sym); + } + + if (sfr) + { + for (sym = setFirstItem (sfr->syms); sym; sym = setNextItem (sfr->syms)) + debugFile->writeSymbol (sym); + } + + if (sfrbit) + { + for (sym = setFirstItem (sfrbit->syms); sym; sym = setNextItem (sfrbit->syms)) + debugFile->writeSymbol (sym); + } + + if (home) + { + for (sym = setFirstItem (home->syms); sym; sym = setNextItem (home->syms)) + debugFile->writeSymbol (sym); + } + + if (code) + { + for (sym = setFirstItem (code->syms); sym; sym = setNextItem (code->syms)) + debugFile->writeSymbol (sym); + } + + if (statsg) + { + for (sym = setFirstItem (statsg->syms); sym; sym = setNextItem (statsg->syms)) + debugFile->writeSymbol (sym); + } + + if (port->genXINIT && xinit) + { + for (sym = setFirstItem (xinit->syms); sym; sym = setNextItem (xinit->syms)) + debugFile->writeSymbol (sym); + } + } + + return; +} + + +void +dumpSymInfo(const char *pcName, memmap *memItem) +{ + symbol *sym; + + if (!memItem) + return; + + printf ("--------------------------------------------\n"); + printf (" %s\n", pcName); + + for (sym = setFirstItem (memItem->syms); sym; sym = setNextItem (memItem->syms)) + { + printf (" %s, isReqv:%d, reqv:0x%p, onStack:%d, Stack:%d, nRegs:%d, [", + sym->rname, sym->isreqv, (void*)(sym->reqv), sym->onStack, sym->stack, sym->nRegs); + + if (sym->reqv) + { + int i; + symbol *TempSym = OP_SYMBOL (sym->reqv); + + for (i = 0; i < 4; i++) + if (TempSym->regs[i]) + printf ("%s,", port->getRegName (TempSym->regs[i])); + } + + printf ("]\n"); + } + + printf ("\n"); +} + + +/*------------------------------------------------------------------*/ +/* emitDebuggerSymbol - call the port specific routine to associate */ +/* the current code location with a debugger symbol */ +/*------------------------------------------------------------------*/ +void +emitDebuggerSymbol (const char * debugSym) +{ + if (port->debugger.emitDebuggerSymbol) + port->debugger.emitDebuggerSymbol (debugSym); +} |
