From 60dd213a0a966b86b3de2cc8562680c0749e3b40 Mon Sep 17 00:00:00 2001
From: stephena
Remember, you can use arbitrarily complex expressions with any - command that takes arguments (except the ones that take filenames, - like "loadsym").
+ command that takes arguments. @@ -653,7 +656,6 @@ listfunctions - List user-defined functions listtraps - List traps loadconfig - Load Distella config file loadstate - Load emulator state xx (0-9) - loadsym - Load symbol file n - Negative Flag: set (0 or 1), or toggle (no arg) pc - Set Program Counter to address xx pgfx - Mark 'PGFX' range in disassembly diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 6c628a9c3..5218eab99 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -114,6 +114,8 @@ CartDebug::~CartDebug() { myUserLabels.clear(); myUserAddresses.clear(); + myUserCLabels.clear(); + // myUserCAddresses.clear(); mySystemAddresses.clear(); for(uInt32 i = 0; i < myBankInfo.size(); ++i) @@ -587,6 +589,7 @@ bool CartDebug::removeLabel(const string& label) { // Erase the label myUserAddresses.erase(iter); + mySystem.setDirtyPage(iter->second); // And also erase the address assigned to it AddrToLabel::iterator iter2 = myUserLabels.find(iter->second); @@ -718,6 +721,65 @@ int CartDebug::getAddress(const string& label) const return -1; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartDebug::loadListFile() +{ + // Currently, the default naming/location for list files is: + // 1) ROM dir based on properties entry name + + if(myListFile == "") + { + const string& propsname = + myConsole.properties().get(Cartridge_Name) + ".lst"; + + FilesystemNode case1(myOSystem.romFile().getParent().getPath() + propsname); + if(case1.isFile() && case1.isReadable()) + myListFile = case1.getPath(); + else + return DebuggerParser::red("list file not found in:\n " + case1.getShortPath()); + } + + FilesystemNode node(myListFile); + ifstream in(node.getPath().c_str()); + if(!in.is_open()) + return DebuggerParser::red("list file '" + node.getShortPath() + "' not readable"); + + myUserCLabels.clear(); + + while(!in.eof()) + { + string line, addr1; + int value = -1; + + getline(in, line); + + if(line.length() == 0 || line[0] == '-') + continue; + else // Search for constants + { + stringstream buf(line); + + // Swallow first value + buf >> value >> addr1; + + // Search for lines containing Uxxxx + if(addr1.length() > 0 && toupper(addr1[0]) == 'U') + { + // Search for pattern 'xx yy CONSTANT =' + int xx = -1, yy = -1; + char eq = '\0'; + buf >> hex >> xx >> hex >> yy >> line >> eq; + if(xx == 0 && yy >= 0 && eq == '=') + myUserCLabels.insert(make_pair(yy, line)); + } + } + } + in.close(); + myDebugger.rom().invalidate(); + + return "loaded " + node.getShortPath() + " OK"; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string CartDebug::loadSymbolFile() { @@ -750,12 +812,17 @@ string CartDebug::loadSymbolFile() int value = -1; getline(in, label); - stringstream buf; - buf << label; + stringstream buf(label); buf >> label >> hex >> value; if(label.length() > 0 && label[0] != '-' && value >= 0) - addLabel(label, value); + { + // Make sure the value doesn't represent a constant + // For now, we simply ignore constants completely + AddrToLabel::const_iterator iter = myUserCLabels.find(value); + if(iter == myUserCLabels.end() || !BSPF_equalsIgnoreCase(label, iter->second)) + addLabel(label, value); + } } in.close(); myDebugger.rom().invalidate(); diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 5cd2b5819..ed4529107 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -231,6 +231,11 @@ class CartDebug : public DebuggerSystem string getLabel(uInt16 addr, bool isRead, int places = -1) const; int getAddress(const string& label) const; + /** + Load constants from list file (as generated by DASM). + */ + string loadListFile(); + /** Load user equates from symbol file (as generated by DASM). */ @@ -363,11 +368,16 @@ class CartDebug : public DebuggerSystem bool myAddrToLineIsROM; // Mappings from label to address (and vice versa) for items - // defined by the user (either through a symbol file or manually + // defined by the user (either through a DASM symbol file or manually // from the commandline in the debugger) AddrToLabel myUserLabels; LabelToAddr myUserAddresses; + // Mappings from label to address (and vice versa) for constants + // defined through a DASM lst file + AddrToLabel myUserCLabels; + // LabelToAddr myUserCAddresses; + // Mappings for labels to addresses for system-defined equates // Because system equate addresses can have different names // (depending on access in read vs. write mode), we can only create @@ -383,7 +393,7 @@ class CartDebug : public DebuggerSystem uInt16 myLabelLength; // Filenames to use for various I/O (currently these are hardcoded) - string mySymbolFile, myCfgFile, myDisasmFile, myRomFile; + string myListFile, mySymbolFile, myCfgFile, myDisasmFile, myRomFile; /// Table of instruction mnemonics static const char* ourTIAMnemonicR[16]; // read mode diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index dae6e1fa4..bddae36f7 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -1169,13 +1169,6 @@ void DebuggerParser::executeLoadstate() commandResult << red("invalid slot (must be 0-9)"); } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// "loadsym" -void DebuggerParser::executeLoadsym() -{ - commandResult << debugger.cartDebug().loadSymbolFile(); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // "n" void DebuggerParser::executeN() @@ -1925,15 +1918,6 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = { &DebuggerParser::executeLoadstate }, - { - "loadsym", - "Load symbol file", - false, - true, - { kARG_END_ARGS }, - &DebuggerParser::executeLoadsym - }, - { "n", "Negative Flag: set (0 or 1), or toggle (no arg)", diff --git a/src/debugger/DebuggerParser.hxx b/src/debugger/DebuggerParser.hxx index 32054dad6..266dce4fc 100644 --- a/src/debugger/DebuggerParser.hxx +++ b/src/debugger/DebuggerParser.hxx @@ -72,7 +72,7 @@ class DebuggerParser private: enum { - kNumCommands = 71, + kNumCommands = 70, kMAX_ARG_TYPES = 10 }; @@ -160,7 +160,6 @@ class DebuggerParser void executeListtraps(); void executeLoadconfig(); void executeLoadstate(); - void executeLoadsym(); void executeN(); void executePc(); void executePGfx(); diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index e094783a1..7174d2db7 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -158,6 +158,47 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd, } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doStep() +{ + instance().debugger().parser().run("step"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doTrace() +{ + instance().debugger().parser().run("trace"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doAdvance() +{ + instance().debugger().parser().run("frame #1"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doScanlineAdvance() +{ + instance().debugger().parser().run("scanline #1"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doRewind() +{ + instance().debugger().parser().run("rewind"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doExitDebugger() +{ + instance().debugger().parser().run("run"); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void DebuggerDialog::doExitRom() +{ + instance().debugger().parser().run("exitrom"); +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DebuggerDialog::createFont() @@ -423,45 +464,3 @@ GUI::Rect DebuggerDialog::getTabBounds() const return r; } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doStep() -{ - instance().debugger().parser().run("step"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doTrace() -{ - instance().debugger().parser().run("trace"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doAdvance() -{ - instance().debugger().parser().run("frame #1"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doScanlineAdvance() -{ - instance().debugger().parser().run("scanline #1"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doRewind() -{ - instance().debugger().parser().run("rewind"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doExitDebugger() -{ - instance().debugger().parser().run("run"); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void DebuggerDialog::doExitRom() -{ - instance().debugger().parser().run("exitrom"); -} diff --git a/src/debugger/gui/PromptWidget.cxx b/src/debugger/gui/PromptWidget.cxx index 2b13a1057..06c3e9cf3 100644 --- a/src/debugger/gui/PromptWidget.cxx +++ b/src/debugger/gui/PromptWidget.cxx @@ -494,6 +494,7 @@ void PromptWidget::loadConfig() // Take care of one-time debugger stuff print(instance().debugger().autoExec().c_str()); print(instance().debugger().cartDebug().loadConfigFile() + "\n"); + print(instance().debugger().cartDebug().loadListFile() + "\n"); print(instance().debugger().cartDebug().loadSymbolFile() + "\n"); print(PROMPT);