diff --git a/stella/src/build/makefile b/stella/src/build/makefile index cee5a86a7..df03a3cd9 100644 --- a/stella/src/build/makefile +++ b/stella/src/build/makefile @@ -13,7 +13,7 @@ ## See the file "license" for information on usage and redistribution of ## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## -## $Id: makefile,v 1.98 2005-06-16 01:11:26 stephena Exp $ +## $Id: makefile,v 1.99 2005-06-16 02:16:25 urchlay Exp $ ##============================================================================ ##============================================================================ @@ -164,7 +164,7 @@ GUI_OBJS = Font.o Menu.o Launcher.o \ ProgressDialog.o \ DebuggerDialog.o PromptWidget.o CheatWidget.o -DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o +DBG_OBJS = Debugger.o DebuggerParser.o EquateList.o PackedBitArray.o CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \ CartE0.o CartE7.o CartF4.o CartF4SC.o CartF6.o CartF6SC.o \ @@ -479,3 +479,6 @@ DebuggerParser.o: $(DBG)/DebuggerParser.cxx $(DBG)/DebuggerParser.hxx EquateList.o: $(DBG)/EquateList.cxx $(DBG)/EquateList.hxx $(DBG)/Equate.hxx $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/EquateList.cxx + +PackedBitArray.o: $(DBG)/PackedBitArray.cxx $(DBG)/PackedBitArray.hxx + $(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(DBG)/PackedBitArray.cxx diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index 86c1b6433..a52ad3f62 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.9 2005-06-16 00:55:57 stephena Exp $ +// $Id: Debugger.cxx,v 1.10 2005-06-16 02:16:25 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -44,6 +44,7 @@ Debugger::Debugger(OSystem* osystem) // Init parser myParser = new DebuggerParser(this); equateList = new EquateList(); + breakPoints = new PackedBitArray(0xffff); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -51,7 +52,8 @@ Debugger::~Debugger() { delete myParser; delete myDebugger; - // delete equateList; + delete equateList; + delete breakPoints; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -277,6 +279,8 @@ void Debugger::step() // to share between stack and variables, I doubt any 2600 games will ever // use recursion... +// FIXME: TIA framebuffer should be updated during tracing! + void Debugger::trace() { // 32 is the 6502 JSR instruction: @@ -345,3 +349,13 @@ EquateList *Debugger::equates() { return equateList; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Debugger::toggleBreakPoint(int bp) { + mySystem->m6502().setBreakPoints(breakPoints); + breakPoints->toggle(bp); +} + +bool Debugger::breakPoint(int bp) { + return breakPoints->isSet(bp) != 0; +} + diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index 33e67eb1b..e58f0b087 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.6 2005-06-16 00:20:11 stephena Exp $ +// $Id: Debugger.hxx,v 1.7 2005-06-16 02:16:25 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -29,6 +29,7 @@ class D6502; #include "DialogContainer.hxx" #include "M6502.hxx" #include "EquateList.hxx" +#include "PackedBitArray.hxx" #include "bspf.hxx" enum { @@ -47,7 +48,7 @@ enum { for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.6 2005-06-16 00:20:11 stephena Exp $ + @version $Id: Debugger.hxx,v 1.7 2005-06-16 02:16:25 urchlay Exp $ */ class Debugger : public DialogContainer { @@ -94,6 +95,9 @@ class Debugger : public DialogContainer return out; } + void toggleBreakPoint(int bp); + bool breakPoint(int bp); + public: /** Run the debugger command and return the result. @@ -144,7 +148,8 @@ class Debugger : public DialogContainer DebuggerParser* myParser; D6502* myDebugger; - EquateList *equateList; + EquateList *equateList; + PackedBitArray *breakPoints; }; #endif diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 40043d66b..46658af84 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.6 2005-06-15 23:45:04 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.7 2005-06-16 02:16:25 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -33,7 +33,6 @@ enum { DebuggerParser::DebuggerParser(Debugger* d) : debugger(d) { - equateList = d->equates(); done = false; } @@ -63,7 +62,7 @@ int DebuggerParser::conv_hex_digit(char d) { // the hex to an int. Returns -1 on error. int DebuggerParser::decipher_arg(string &arg) { const char *a = arg.c_str(); - int address = equateList->getAddress(a); + int address = debugger->equateList->getAddress(a); // cerr << "decipher_arg: equateList->getAddress(" << a << ") == " << address << endl; if(address >= 0) return address; @@ -91,7 +90,7 @@ bool DebuggerParser::getArgs(const string& command) { // cerr << "Parsing \"" << command << "\"" << endl; while(*c != '\0') { - // cerr << "State " << state << ", *c " << *c << endl; + // cerr << "State " << state << ", *c '" << *c << "'" << endl; switch(state) { case kIN_COMMAND: if(*c == ' ') @@ -266,13 +265,23 @@ string DebuggerParser::run(const string& command) { result = debugger->dumpTIA(); } else if(subStringMatch(verb, "reset")) { debugger->reset(); + } else if(subStringMatch(verb, "break")) { + if(argCount == 1) { + debugger->toggleBreakPoint(args[0]); + if(debugger->breakPoint(args[0])) + return "Set breakpoint"; + else + return "Cleared breakpoint"; + } else { + return "one argument required"; + } } else if(subStringMatch(verb, "help") || verb == "?") { // please leave each option on its own line so they're // easy to sort - bkw return "a xx - Set Accumulator to xx\n" // "break - Show all breakpoints\n" - // "break xx - Set/clear breakpoint at address xx\n" + "break xx - Set/clear breakpoint at address xx\n" "c - Toggle Carry Flag\n" "d - Toggle Decimal Flag\n" "loadsym f - Load DASM symbols from file f\n" diff --git a/stella/src/debugger/EquateList.cxx b/stella/src/debugger/EquateList.cxx index df5685945..b16ef5ae9 100644 --- a/stella/src/debugger/EquateList.cxx +++ b/stella/src/debugger/EquateList.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EquateList.cxx,v 1.6 2005-06-16 00:20:11 stephena Exp $ +// $Id: EquateList.cxx,v 1.7 2005-06-16 02:16:26 urchlay Exp $ //============================================================================ #include @@ -100,8 +100,10 @@ static struct Equate hardCodedEquates[] = { EquateList::EquateList() { // cerr << sizeof(hardCodedEquates)/sizeof(struct Equate) << endl; - ourVcsEquates = new Equate[ sizeof(hardCodedEquates)/sizeof(struct Equate) ]; - for(int i=0; hardCodedEquates[i].label != NULL; i++) + int size = sizeof(hardCodedEquates)/sizeof(struct Equate) + 1; + ourVcsEquates = new Equate[ size ]; + // for(int i=0; hardCodedEquates[i].label != NULL; i++) + for(int i=0; iisSet(PC)) + cerr << "hit breakpoint at " << PC << endl; + } + #ifdef DEBUG debugStream << "PC=" << hex << setw(4) << PC << " "; #endif diff --git a/stella/src/emucore/m6502/src/M6502Low.cxx b/stella/src/emucore/m6502/src/M6502Low.cxx index 024ed33a7..e056ce89f 100644 --- a/stella/src/emucore/m6502/src/M6502Low.cxx +++ b/stella/src/emucore/m6502/src/M6502Low.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: M6502Low.cxx,v 1.3 2005-06-16 01:11:29 stephena Exp $ +// $Id: M6502Low.cxx,v 1.4 2005-06-16 02:16:26 urchlay Exp $ //============================================================================ #include "M6502Low.hxx" @@ -59,6 +59,12 @@ bool M6502Low::execute(uInt32 number) uInt16 operandAddress = 0; uInt8 operand = 0; + if(breakPoints != NULL) + { + if(breakPoints->isSet(PC)) + cerr << "hit breakpoint at " << PC << endl; + } + #ifdef DEBUG debugStream << "PC=" << hex << setw(4) << PC << " "; #endif