Fixed debugger issue where a sym file loaded from a previous ROM load

was still being used for the next ROM.  It makes me wonder how many
people use this feature, since this problem was never reported before.

Some general cleanup of the Debugger API.  I generally don't like
pointers, and use (const) references whenever possible.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1440 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-03-23 17:43:22 +00:00
parent ee08e375b5
commit bb8ebc853e
13 changed files with 269 additions and 283 deletions

View File

@ -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.119 2008-02-24 16:51:52 stephena Exp $
// $Id: Debugger.cxx,v 1.120 2008-03-23 17:43:21 stephena Exp $
//============================================================================
#include "bspf.hxx"
@ -100,10 +100,10 @@ Debugger::Debugger(OSystem* osystem)
myTiaOutput(NULL),
myTiaZoom(NULL),
myRom(NULL),
equateList(NULL),
breakPoints(NULL),
readTraps(NULL),
writeTraps(NULL),
myEquateList(NULL),
myBreakPoints(NULL),
myReadTraps(NULL),
myWriteTraps(NULL),
myWidth(1030),
myHeight(690)
{
@ -118,10 +118,10 @@ Debugger::Debugger(OSystem* osystem)
// Init parser
myParser = new DebuggerParser(this);
equateList = new EquateList();
breakPoints = new PackedBitArray(0x10000);
readTraps = new PackedBitArray(0x10000);
writeTraps = new PackedBitArray(0x10000);
myEquateList = new EquateList();
myBreakPoints = new PackedBitArray(0x10000);
myReadTraps = new PackedBitArray(0x10000);
myWriteTraps = new PackedBitArray(0x10000);
// Allow access to this object from any class
// Technically this violates pure OO programming, but since I know
@ -139,10 +139,10 @@ Debugger::~Debugger()
delete myRamDebug;
delete myTiaDebug;
delete equateList;
delete breakPoints;
delete readTraps;
delete writeTraps;
delete myEquateList;
delete myBreakPoints;
delete myReadTraps;
delete myWriteTraps;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -191,6 +191,12 @@ void Debugger::setConsole(Console* console)
delete myTiaDebug;
myTiaDebug = new TIADebug(this, myConsole);
// Initialize equates and breakpoints to known state
delete myEquateList;
myEquateList = new EquateList();
clearAllBreakPoints();
clearAllTraps();
autoLoadSymbols(myOSystem->romFile());
loadListFile();
@ -221,17 +227,18 @@ void Debugger::quit()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::autoLoadSymbols(string fileName) {
string file = fileName;
void Debugger::autoLoadSymbols(string fileName)
{
string file = fileName;
string::size_type pos;
if( (pos = file.find_last_of('.')) != string::npos ) {
file.replace(pos, file.size(), ".sym");
} else {
file += ".sym";
}
string ret = equateList->loadFile(file);
// cerr << "loading syms from file " << file << ": " << ret << endl;
string::size_type pos;
if( (pos = file.find_last_of('.')) != string::npos )
file.replace(pos, file.size(), ".sym");
else
file += ".sym";
string ret = myEquateList->loadFile(file);
// cerr << "loading syms from file " << file << ": " << ret << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -289,7 +296,7 @@ string Debugger::loadListFile(string f)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::getSourceLines(int addr)
string Debugger::getSourceLines(int addr) const
{
if(sourceLines.size() == 0)
return "";
@ -452,140 +459,115 @@ const string Debugger::cpuState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* The timers, joysticks, and switches can be read via peeks, so
I didn't write a separate RIOTDebug class. */
const string Debugger::riotState() {
string ret;
const string Debugger::riotState()
{
string ret;
// TODO: inverse video for changed regs. Core needs to track this.
// TODO: keyboard controllers?
// TODO: inverse video for changed regs. Core needs to track this.
// TODO: keyboard controllers?
for(int i=0x280; i<0x284; i++) {
ret += valueToString(i);
ret += "/";
ret += equates()->getFormatted(i, 2);
ret += "=";
ret += valueToString(mySystem->peek(i));
ret += " ";
}
ret += "\n";
for(int i=0x280; i<0x284; i++)
{
ret += valueToString(i);
ret += "/";
ret += equates().getFormatted(i, 2);
ret += "=";
ret += valueToString(mySystem->peek(i));
ret += " ";
}
ret += "\n";
// These are squirrely: some symbol files will define these as
// 0x284-0x287. Doesn't actually matter, these registers repeat
// every 16 bytes.
ret += valueToString(0x294);
ret += "/TIM1T=";
ret += valueToString(mySystem->peek(0x294));
ret += " ";
// These are squirrely: some symbol files will define these as
// 0x284-0x287. Doesn't actually matter, these registers repeat
// every 16 bytes.
ret += valueToString(0x294);
ret += "/TIM1T=";
ret += valueToString(mySystem->peek(0x294));
ret += " ";
ret += valueToString(0x295);
ret += "/TIM8T=";
ret += valueToString(mySystem->peek(0x295));
ret += " ";
ret += valueToString(0x295);
ret += "/TIM8T=";
ret += valueToString(mySystem->peek(0x295));
ret += " ";
ret += valueToString(0x296);
ret += "/TIM64T=";
ret += valueToString(mySystem->peek(0x296));
ret += " ";
ret += valueToString(0x296);
ret += "/TIM64T=";
ret += valueToString(mySystem->peek(0x296));
ret += " ";
ret += valueToString(0x297);
ret += "/TIM1024T=";
ret += valueToString(mySystem->peek(0x297));
ret += "\n";
ret += valueToString(0x297);
ret += "/TIM1024T=";
ret += valueToString(mySystem->peek(0x297));
ret += "\n";
ret += "Left/P0diff: ";
ret += (mySystem->peek(0x282) & 0x40) ? "hard/A" : "easy/B";
ret += " ";
ret += "Left/P0diff: ";
ret += (mySystem->peek(0x282) & 0x40) ? "hard/A" : "easy/B";
ret += " ";
ret += "Right/P1diff: ";
ret += (mySystem->peek(0x282) & 0x80) ? "hard/A" : "easy/B";
ret += "\n";
ret += "Right/P1diff: ";
ret += (mySystem->peek(0x282) & 0x80) ? "hard/A" : "easy/B";
ret += "\n";
ret += "TVType: ";
ret += (mySystem->peek(0x282) & 0x8) ? "Color" : "B&W";
ret += " Switches: ";
ret += (mySystem->peek(0x282) & 0x2) ? "-" : "+";
ret += "select ";
ret += (mySystem->peek(0x282) & 0x1) ? "-" : "+";
ret += "reset";
ret += "\n";
ret += "TVType: ";
ret += (mySystem->peek(0x282) & 0x8) ? "Color" : "B&W";
ret += " Switches: ";
ret += (mySystem->peek(0x282) & 0x2) ? "-" : "+";
ret += "select ";
ret += (mySystem->peek(0x282) & 0x1) ? "-" : "+";
ret += "reset";
ret += "\n";
// Yes, the fire buttons are in the TIA, but we might as well
// show them here for convenience.
ret += "Left/P0 stick: ";
ret += (mySystem->peek(0x280) & 0x80) ? "" : "right ";
ret += (mySystem->peek(0x280) & 0x40) ? "" : "left ";
ret += (mySystem->peek(0x280) & 0x20) ? "" : "down ";
ret += (mySystem->peek(0x280) & 0x10) ? "" : "up ";
ret += ((mySystem->peek(0x280) & 0xf0) == 0xf0) ? "(no directions) " : "";
ret += (mySystem->peek(0x03c) & 0x80) ? "" : "(button) ";
ret += "\n";
ret += "Right/P1 stick: ";
ret += (mySystem->peek(0x280) & 0x08) ? "" : "right ";
ret += (mySystem->peek(0x280) & 0x04) ? "" : "left ";
ret += (mySystem->peek(0x280) & 0x02) ? "" : "down ";
ret += (mySystem->peek(0x280) & 0x01) ? "" : "up ";
ret += ((mySystem->peek(0x280) & 0x0f) == 0x0f) ? "(no directions) " : "";
ret += (mySystem->peek(0x03d) & 0x80) ? "" : "(button) ";
// Yes, the fire buttons are in the TIA, but we might as well
// show them here for convenience.
ret += "Left/P0 stick: ";
ret += (mySystem->peek(0x280) & 0x80) ? "" : "right ";
ret += (mySystem->peek(0x280) & 0x40) ? "" : "left ";
ret += (mySystem->peek(0x280) & 0x20) ? "" : "down ";
ret += (mySystem->peek(0x280) & 0x10) ? "" : "up ";
ret += ((mySystem->peek(0x280) & 0xf0) == 0xf0) ? "(no directions) " : "";
ret += (mySystem->peek(0x03c) & 0x80) ? "" : "(button) ";
ret += "\n";
ret += "Right/P1 stick: ";
ret += (mySystem->peek(0x280) & 0x08) ? "" : "right ";
ret += (mySystem->peek(0x280) & 0x04) ? "" : "left ";
ret += (mySystem->peek(0x280) & 0x02) ? "" : "down ";
ret += (mySystem->peek(0x280) & 0x01) ? "" : "up ";
ret += ((mySystem->peek(0x280) & 0x0f) == 0x0f) ? "(no directions) " : "";
ret += (mySystem->peek(0x03d) & 0x80) ? "" : "(button) ";
//ret += "\n"; // caller will add
//ret += "\n"; // caller will add
return ret;
return ret;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::reset() {
int pc = myCpuDebug->dPeek(0xfffc);
myCpuDebug->setPC(pc);
void Debugger::reset()
{
int pc = myCpuDebug->dPeek(0xfffc);
myCpuDebug->setPC(pc);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::formatFlags(BoolArray& b, char *out) {
// NV-BDIZC
if(myCpuDebug->n())
out[0] = 'N';
else
out[0] = 'n';
if(myCpuDebug->v())
out[1] = 'V';
else
out[1] = 'v';
out[2] = '-';
if(myCpuDebug->b())
out[3] = 'B';
else
out[3] = 'b';
if(myCpuDebug->d())
out[4] = 'D';
else
out[4] = 'd';
if(myCpuDebug->i())
out[5] = 'I';
else
out[5] = 'i';
if(myCpuDebug->z())
out[6] = 'Z';
else
out[6] = 'z';
if(myCpuDebug->c())
out[7] = 'C';
else
out[7] = 'c';
out[8] = '\0';
void Debugger::formatFlags(BoolArray& b, char *out)
{
// NV-BDIZC
out[0] = myCpuDebug->n() ? 'N' : 'n';
out[1] = myCpuDebug->v() ? 'V' : 'v';
out[2] = '-';
out[3] = myCpuDebug->b() ? 'B' : 'b';
out[4] = myCpuDebug->d() ? 'D' : 'd';
out[5] = myCpuDebug->i() ? 'I' : 'i';
out[6] = myCpuDebug->z() ? 'Z' : 'z';
out[7] = myCpuDebug->c() ? 'C' : 'c';
out[8] = '\0';
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* Element 0 of args is the address. The remaining elements are the data
to poke, starting at the given address.
*/
const string Debugger::setRAM(IntArray& args) {
const string Debugger::setRAM(IntArray& args)
{
char buf[10];
int count = args.size();
@ -729,80 +711,84 @@ int Debugger::trace()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EquateList *Debugger::equates() {
return equateList;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleBreakPoint(int bp) {
mySystem->m6502().setBreakPoints(breakPoints);
void Debugger::toggleBreakPoint(int bp)
{
mySystem->m6502().setBreakPoints(myBreakPoints);
if(bp < 0) bp = myCpuDebug->pc();
breakPoints->toggle(bp);
myBreakPoints->toggle(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setBreakPoint(int bp, bool set)
{
mySystem->m6502().setBreakPoints(breakPoints);
mySystem->m6502().setBreakPoints(myBreakPoints);
if(bp < 0) bp = myCpuDebug->pc();
if(set)
breakPoints->set(bp);
myBreakPoints->set(bp);
else
breakPoints->clear(bp);
myBreakPoints->clear(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::breakPoint(int bp) {
bool Debugger::breakPoint(int bp)
{
if(bp < 0) bp = myCpuDebug->pc();
return breakPoints->isSet(bp) != 0;
return myBreakPoints->isSet(bp) != 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleReadTrap(int t) {
mySystem->m6502().setTraps(readTraps, writeTraps);
readTraps->toggle(t);
void Debugger::toggleReadTrap(int t)
{
mySystem->m6502().setTraps(myReadTraps, myWriteTraps);
myReadTraps->toggle(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleWriteTrap(int t) {
mySystem->m6502().setTraps(readTraps, writeTraps);
writeTraps->toggle(t);
void Debugger::toggleWriteTrap(int t)
{
mySystem->m6502().setTraps(myReadTraps, myWriteTraps);
myWriteTraps->toggle(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleTrap(int t) {
void Debugger::toggleTrap(int t)
{
toggleReadTrap(t);
toggleWriteTrap(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::readTrap(int t) {
return readTraps->isSet(t) != 0;
bool Debugger::readTrap(int t)
{
return myReadTraps->isSet(t) != 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::writeTrap(int t) {
return writeTraps->isSet(t) != 0;
bool Debugger::writeTrap(int t)
{
return myWriteTraps->isSet(t) != 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::cycles() {
int Debugger::cycles()
{
return mySystem->cycles();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& Debugger::disassemble(int start, int lines) {
const string& Debugger::disassemble(int start, int lines)
{
char buf[255], bbuf[255];
static string result;
result = "";
do {
const char *label = equateList->getFormatted(start, 4);
const char *label = myEquateList->getFormatted(start, 4);
result += label;
result += ": ";
int count = myCpuDebug->disassemble(start, buf, equateList);
int count = myCpuDebug->disassemble(start, buf, myEquateList);
for(int i=0; i<count; i++) {
sprintf(bbuf, "%02x ", peek(start++));
@ -830,11 +816,11 @@ void Debugger::disassemble(IntArray& addr, StringList& addrLabel,
do
{
tmp = equateList->getFormatted(start, 4);
tmp = myEquateList->getFormatted(start, 4);
addrLabel.push_back(tmp + ":");
addr.push_back(start);
int count = myCpuDebug->disassemble(start, buf, equateList);
int count = myCpuDebug->disassemble(start, buf, myEquateList);
tmp = "";
for(int i=0; i<count; i++) {
@ -873,18 +859,18 @@ void Debugger::nextFrame(int frames)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::clearAllBreakPoints()
{
delete breakPoints;
breakPoints = new PackedBitArray(0x10000);
delete myBreakPoints;
myBreakPoints = new PackedBitArray(0x10000);
mySystem->m6502().setBreakPoints(NULL);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::clearAllTraps()
{
delete readTraps;
delete writeTraps;
readTraps = new PackedBitArray(0x10000);
writeTraps = new PackedBitArray(0x10000);
delete myReadTraps;
delete myWriteTraps;
myReadTraps = new PackedBitArray(0x10000);
myWriteTraps = new PackedBitArray(0x10000);
mySystem->m6502().setTraps(NULL, NULL);
}
@ -909,7 +895,7 @@ string Debugger::showWatches()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addLabel(string label, int address)
{
equateList->addEquate(label, address);
myEquateList->addEquate(label, address);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -944,10 +930,9 @@ int Debugger::bankCount()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char *Debugger::getCartType()
string Debugger::getCartType()
{
return myConsole->cartridge().name().c_str();
// FIXME - maybe whatever is calling this should use a string instead
return myConsole->cartridge().name();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -982,7 +967,7 @@ void Debugger::setQuitState()
// execute one instruction on quit. If we're
// sitting at a breakpoint/trap, this will get us past it.
// Somehow this feels like a hack to me, but I don't know why
// if(breakPoints->isSet(myCpuDebug->pc()))
// if(myBreakPoints->isSet(myCpuDebug->pc()))
mySystem->m6502().execute(1);
}
@ -1055,8 +1040,8 @@ GUI::Rect Debugger::getTabBounds() const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addFunction(string name, string definition,
Expression *exp, bool builtin)
void Debugger::addFunction(const string& name, const string& definition,
Expression* exp, bool builtin)
{
functions.insert(make_pair(name, exp));
if(!builtin)
@ -1064,7 +1049,7 @@ void Debugger::addFunction(string name, string definition,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::delFunction(string name)
void Debugger::delFunction(const string& name)
{
FunctionMap::iterator iter = functions.find(name);
if(iter == functions.end())
@ -1081,7 +1066,7 @@ void Debugger::delFunction(string name)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expression *Debugger::getFunction(string name)
Expression* Debugger::getFunction(const string& name)
{
FunctionMap::iterator iter = functions.find(name);
if(iter == functions.end())
@ -1091,7 +1076,7 @@ Expression *Debugger::getFunction(string name)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Debugger::getFunctionDef(string name)
string Debugger::getFunctionDef(const string& name)
{
FunctionDefMap::iterator iter = functionDefs.find(name);
if(iter == functionDefs.end())
@ -1101,13 +1086,13 @@ string Debugger::getFunctionDef(string name)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FunctionDefMap Debugger::getFunctionDefMap()
const FunctionDefMap Debugger::getFunctionDefMap() const
{
return functionDefs;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::builtinHelp()
const string Debugger::builtinHelp() const
{
string result;
@ -1125,7 +1110,7 @@ const string Debugger::builtinHelp()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::saveROM(string filename)
bool Debugger::saveROM(const string& filename) const
{
// TODO: error checking
ofstream *out = new ofstream(filename.c_str(), ios::out | ios::binary);

View File

@ -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.91 2008-02-06 13:45:19 stephena Exp $
// $Id: Debugger.hxx,v 1.92 2008-03-23 17:43:21 stephena Exp $
//============================================================================
#ifndef DEBUGGER_HXX
@ -69,10 +69,13 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)();
for all debugging operations in Stella (parser, 6502 debugger, etc).
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.91 2008-02-06 13:45:19 stephena Exp $
@version $Id: Debugger.hxx,v 1.92 2008-03-23 17:43:21 stephena Exp $
*/
class Debugger : public DialogContainer
{
// Make these friend classes, to ease communications with the debugger
// Although it isn't enforced, these classes should use accessor methods
// directly, and not touch the instance variables
friend class DebuggerDialog;
friend class DebuggerParser;
friend class EventHandler;
@ -121,12 +124,14 @@ class Debugger : public DialogContainer
*/
void quit();
void addFunction(string name, string def, Expression *exp, bool builtin=false);
string getFunctionDef(string name);
void delFunction(string name);
Expression *getFunction(string name);
const FunctionDefMap getFunctionDefMap();
const string builtinHelp();
void addFunction(const string& name, const string& def,
Expression* exp, bool builtin = false);
void delFunction(const string& name);
Expression* getFunction(const string& name);
string getFunctionDef(const string& name);
const FunctionDefMap getFunctionDefMap() const;
const string builtinHelp() const;
/**
The debugger subsystem responsible for all CPU state
@ -146,13 +151,12 @@ class Debugger : public DialogContainer
/**
List of English-like aliases for 6502 opcodes and operands.
*/
EquateList *equates();
EquateList& equates() const { return *myEquateList; }
DebuggerParser *parser() { return myParser; }
PackedBitArray *breakpoints() { return breakPoints; }
PackedBitArray *readtraps() { return readTraps; }
PackedBitArray *writetraps() { return writeTraps; }
DebuggerParser& parser() const { return *myParser; }
PackedBitArray& breakpoints() const { return *myBreakPoints; }
PackedBitArray& readtraps() const { return *myReadTraps; }
PackedBitArray& writetraps() const { return *myWriteTraps; }
/**
Run the debugger command and return the result.
@ -274,10 +278,10 @@ class Debugger : public DialogContainer
void setBreakPoint(int bp, bool set);
string loadListFile(string f = "");
const string getSourceLines(int addr);
bool haveListFile() { return sourceLines.size() > 0; }
string getSourceLines(int addr) const;
bool haveListFile() const { return sourceLines.size() > 0; }
bool saveROM(string filename);
bool saveROM(const string& filename) const;
bool setBank(int bank);
bool patchROM(int addr, int value);
@ -336,7 +340,7 @@ class Debugger : public DialogContainer
PromptWidget *prompt() { return myPrompt; }
void addLabel(string label, int address);
const char *getCartType();
string getCartType();
void saveState(int state);
void loadState(int state);
@ -347,7 +351,7 @@ class Debugger : public DialogContainer
typedef ListFile::const_iterator ListIter;
Console* myConsole;
System* mySystem;
System* mySystem;
DebuggerParser* myParser;
CpuDebug* myCpuDebug;
@ -360,11 +364,11 @@ class Debugger : public DialogContainer
RomWidget* myRom;
EditTextWidget* myMessage;
EquateList *equateList;
PackedBitArray *breakPoints;
PackedBitArray *readTraps;
PackedBitArray *writeTraps;
PromptWidget *myPrompt;
EquateList* myEquateList;
PackedBitArray* myBreakPoints;
PackedBitArray* myReadTraps;
PackedBitArray* myWriteTraps;
PromptWidget* myPrompt;
ListFile sourceLines;

View File

@ -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: DebuggerExpressions.hxx,v 1.3 2008-02-06 13:45:20 stephena Exp $
// $Id: DebuggerExpressions.hxx,v 1.4 2008-03-23 17:43:21 stephena Exp $
//============================================================================
#ifndef DEBUGGER_EXPRESSIONS_HXX
@ -123,7 +123,7 @@ class EquateExpression : public Expression
{
public:
EquateExpression(const string& label) : Expression(0, 0), myLabel(label) {}
uInt16 evaluate() { return Debugger::debugger().equates()->getAddress(myLabel); }
uInt16 evaluate() { return Debugger::debugger().equates().getAddress(myLabel); }
private:
string myLabel;

View File

@ -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.102 2008-02-06 13:45:20 stephena Exp $
// $Id: DebuggerParser.cxx,v 1.103 2008-03-23 17:43:21 stephena Exp $
//============================================================================
#include <fstream>
@ -265,7 +265,7 @@ int DebuggerParser::decipher_arg(const string &str)
else if(arg == "pc" || arg == ".") result = state.PC;
else { // Not a special, must be a regular arg: check for label first
const char *a = arg.c_str();
result = debugger->equateList->getAddress(arg);
result = debugger->equates().getAddress(arg);
if(result < 0) { // if not label, must be a number
if(bin) { // treat as binary
@ -559,7 +559,7 @@ string DebuggerParser::eval()
char buf[50];
string ret;
for(int i=0; i<argCount; i++) {
string label = debugger->equates()->getLabel(args[i]);
string label = debugger->equates().getLabel(args[i]);
if(label != "") {
ret += label;
ret += ": ";
@ -598,7 +598,7 @@ string DebuggerParser::trapStatus(int addr)
else
result += " none ";
string l = debugger->equateList->getLabel(addr);
string l = debugger->equates().getLabel(addr);
if(l != "") {
result += " (";
result += l;
@ -978,8 +978,8 @@ void DebuggerParser::executeListbreaks()
int count = 0;
for(unsigned int i=0; i<0x10000; i++) {
if(debugger->breakPoints->isSet(i)) {
sprintf(buf, "%s ", debugger->equateList->getFormatted(i, 4));
if(debugger->breakpoints().isSet(i)) {
sprintf(buf, "%s ", debugger->equates().getFormatted(i, 4));
commandResult += buf;
if(! (++count % 8) ) commandResult += "\n";
}
@ -1057,7 +1057,7 @@ void DebuggerParser::executeLoadlist()
// "loadsym"
void DebuggerParser::executeLoadsym()
{
commandResult = debugger->equateList->loadFile(argStrings[0]);
commandResult = debugger->equates().loadFile(argStrings[0]);
debugger->myRom->invalidate();
}
@ -1221,7 +1221,7 @@ void DebuggerParser::executeSavestate()
// "savesym"
void DebuggerParser::executeSavesym()
{
if(debugger->equateList->saveFile(argStrings[0]))
if(debugger->equates().saveFile(argStrings[0]))
commandResult = "saved symbols to file " + argStrings[0];
else
commandResult = red("I/O error");
@ -1296,7 +1296,7 @@ void DebuggerParser::executeTrapwrite()
// "undef"
void DebuggerParser::executeUndef()
{
if(debugger->equateList->undefine(argStrings[0]))
if(debugger->equates().undefine(argStrings[0]))
{
debugger->myRom->invalidate();
commandResult = argStrings[0] + " now undefined";

View File

@ -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: CpuWidget.cxx,v 1.10 2008-02-06 13:45:20 stephena Exp $
// $Id: CpuWidget.cxx,v 1.11 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -281,5 +281,5 @@ void CpuWidget::fillGrid()
changed.push_back(state.PSbits[i] != oldstate.PSbits[i]);
myPSRegister->setState(state.PSbits, changed);
myPCLabel->setEditString(dbg.equates()->getLabel(state.PC, EQF_ROM));
myPCLabel->setEditString(dbg.equates().getLabel(state.PC, EQF_ROM));
}

View File

@ -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: DebuggerDialog.cxx,v 1.22 2008-02-06 13:45:20 stephena Exp $
// $Id: DebuggerDialog.cxx,v 1.23 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -271,29 +271,29 @@ void DebuggerDialog::addRomArea()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doStep()
{
instance()->debugger().parser()->run("step");
instance()->debugger().parser().run("step");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doTrace()
{
instance()->debugger().parser()->run("trace");
instance()->debugger().parser().run("trace");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doAdvance()
{
instance()->debugger().parser()->run("frame #1");
instance()->debugger().parser().run("frame #1");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doScanlineAdvance()
{
instance()->debugger().parser()->run("scanline #1");
instance()->debugger().parser().run("scanline #1");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerDialog::doExit()
{
instance()->debugger().parser()->run("run");
instance()->debugger().parser().run("run");
}

View File

@ -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: PromptWidget.cxx,v 1.22 2008-02-06 13:45:20 stephena Exp $
// $Id: PromptWidget.cxx,v 1.23 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -239,30 +239,30 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
if(lastDelimPos < 0)
{
// no delimiters, do command completion:
DebuggerParser *parser = instance()->debugger().parser();
possibilities = parser->countCompletions(str);
DebuggerParser& parser = instance()->debugger().parser();
possibilities = parser.countCompletions(str);
if(possibilities < 1) {
delete[] str;
break;
}
completionList = parser->getCompletions();
prefix = parser->getCompletionPrefix();
completionList = parser.getCompletions();
prefix = parser.getCompletionPrefix();
}
else
{
// we got a delimiter, so this must be a label:
EquateList *equates = instance()->debugger().equates();
possibilities = equates->countCompletions(str + lastDelimPos + 1);
EquateList& equates = instance()->debugger().equates();
possibilities = equates.countCompletions(str + lastDelimPos + 1);
if(possibilities < 1) {
delete[] str;
break;
}
completionList = equates->getCompletions();
prefix = equates->getCompletionPrefix();
completionList = equates.getCompletions();
prefix = equates.getCompletionPrefix();
}
if(possibilities == 1)

View File

@ -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: RamWidget.cxx,v 1.15 2008-02-24 16:51:52 stephena Exp $
// $Id: RamWidget.cxx,v 1.16 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -177,7 +177,7 @@ void RamWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
value = myRamGrid->getSelectedValue();
myLabel->setEditString(
instance()->debugger().equates()->getLabel(addr+kRamStart, EQF_RAM));
instance()->debugger().equates().getLabel(addr+kRamStart, EQF_RAM));
myDecValue->setEditString(instance()->debugger().valueToString(value, kBASE_10));
myBinValue->setEditString(instance()->debugger().valueToString(value, kBASE_2));
break;

View File

@ -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: RomWidget.cxx,v 1.23 2008-02-06 13:45:20 stephena Exp $
// $Id: RomWidget.cxx,v 1.24 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -217,7 +217,7 @@ void RomWidget::loadConfig()
void RomWidget::initialUpdate()
{
Debugger& dbg = instance()->debugger();
PackedBitArray* bp = dbg.breakpoints();
PackedBitArray& bp = dbg.breakpoints();
// Reading from ROM might trigger a bankswitch, so save the current bank
myCurrentBank = dbg.getBank();
@ -238,7 +238,7 @@ void RomWidget::initialUpdate()
dbg.disassemble(myAddrList, label, data, disasm, 0xf000, 4096);
for(unsigned int i = 0; i < data.size(); ++i)
{
if(bp && bp->isSet(myAddrList[i]))
if(bp.isSet(myAddrList[i]))
state.push_back(true);
else
state.push_back(false);
@ -285,14 +285,14 @@ void RomWidget::patchROM(int data, const string& bytes)
// Temporarily set to base 16, since that's the format the disassembled
// byte string is in. This eliminates the need to prefix each byte with
// a '$' character
BaseFormat oldbase = instance()->debugger().parser()->base();
instance()->debugger().parser()->setBase(kBASE_16);
BaseFormat oldbase = instance()->debugger().parser().base();
instance()->debugger().parser().setBase(kBASE_16);
command << "rom #" << myAddrList[data] << " " << bytes;
instance()->debugger().run(command.str());
// Restore previous base
instance()->debugger().parser()->setBase(oldbase);
instance()->debugger().parser().setBase(oldbase);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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: TiaOutputWidget.cxx,v 1.14 2008-02-06 13:45:20 stephena Exp $
// $Id: TiaOutputWidget.cxx,v 1.15 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -118,7 +118,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
if(lines > 0)
{
command << "scanline #" << lines;
instance()->debugger().parser()->run(command.str());
instance()->debugger().parser().run(command.str());
}
break;
}
@ -128,7 +128,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
ostringstream command;
int scanline = myClickY + ystart;
command << "breakif _scan==#" << scanline;
instance()->debugger().parser()->run(command.str());
instance()->debugger().parser().run(command.str());
break;
}

View File

@ -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: TiaWidget.cxx,v 1.9 2008-02-06 13:45:20 stephena Exp $
// $Id: TiaWidget.cxx,v 1.10 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -800,7 +800,7 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
addr = myRamGrid->getSelectedAddr();
value = myRamGrid->getSelectedValue();
myLabel->setEditString(dbg.equates()->getLabel(addr));
myLabel->setEditString(dbg.equates().getLabel(addr));
myDecValue->setEditString(dbg.valueToString(value, kBASE_10));
myBinValue->setEditString(dbg.valueToString(value, kBASE_2));

View File

@ -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: FileSnapDialog.cxx,v 1.16 2008-03-23 16:22:46 stephena Exp $
// $Id: FileSnapDialog.cxx,v 1.17 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -41,17 +41,13 @@ FileSnapDialog::FileSnapDialog(
myIsGlobal(boss != 0)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
buttonWidth = font.getStringWidth("Defaults") + 20,
buttonWidth = font.getStringWidth("Properties file:") + 20,
buttonHeight = font.getLineHeight() + 4;
const int vBorder = 8;
int xpos, ypos, bwidth, bheight;
int xpos, ypos;
WidgetArray wid;
ButtonWidget* b;
bwidth = font.getStringWidth("Properties file:") + 20;
bheight = font.getLineHeight() + 4;
// Set real dimensions
// _w = 50 * fontWidth + 10;
// _h = 11 * (lineHeight + 4) + 10;
@ -60,62 +56,62 @@ FileSnapDialog::FileSnapDialog(
// ROM path
ButtonWidget* romButton =
new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Rom path:",
kChooseRomDirCmd);
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Rom path:", kChooseRomDirCmd);
wid.push_back(romButton);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
myRomPath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(myRomPath);
// State directory
xpos = vBorder; ypos += romButton->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "State path:",
kChooseStateDirCmd);
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"State path:", kChooseStateDirCmd);
wid.push_back(b);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
myStatePath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(myStatePath);
// Cheat file
xpos = vBorder; ypos += b->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Cheat file:",
kChooseCheatFileCmd);
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Cheat file:", kChooseCheatFileCmd);
wid.push_back(b);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
myCheatFile = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(myCheatFile);
// Palette file
xpos = vBorder; ypos += b->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Palette file:",
kChoosePaletteFileCmd);
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Palette file:", kChoosePaletteFileCmd);
wid.push_back(b);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
myPaletteFile = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(myPaletteFile);
// Properties file
xpos = vBorder; ypos += b->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Properties file:",
kChoosePropsFileCmd);
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Properties file:", kChoosePropsFileCmd);
wid.push_back(b);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
myPropsFile = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(myPropsFile);
// Snapshot path
xpos = vBorder; ypos += b->getHeight() + 3;
b = new ButtonWidget(this, font, xpos, ypos, bwidth, bheight, "Snapshot path:",
kChooseSnapDirCmd);
b = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Snapshot path:", kChooseSnapDirCmd);
wid.push_back(b);
xpos += bwidth + 10;
xpos += buttonWidth + 10;
mySnapPath = new EditTextWidget(this, font, xpos, ypos + 2,
_w - xpos - 10, font.getLineHeight(), "");
_w - xpos - 10, lineHeight, "");
wid.push_back(mySnapPath);
// Snapshot single or multiple saves
@ -126,7 +122,8 @@ FileSnapDialog::FileSnapDialog(
// Add Defaults, OK and Cancel buttons
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
buttonWidth, buttonHeight, "Defaults", kDefaultsCmd);
font.getStringWidth("Defaults") + 20, buttonHeight,
"Defaults", kDefaultsCmd);
wid.push_back(b);
addOKCancelBGroup(wid, font);

View File

@ -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: YaccParser.cxx,v 1.23 2008-02-06 13:45:24 stephena Exp $
// $Id: YaccParser.cxx,v 1.24 2008-03-23 17:43:22 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -102,7 +102,7 @@ inline bool is_operator(char x) {
// responsibility, not the lexer's
int const_to_int(char *c) {
// what base is the input in?
BaseFormat base = Debugger::debugger().parser()->base();
BaseFormat base = Debugger::debugger().parser().base();
switch(*c) {
case '\\':
@ -261,7 +261,7 @@ int yylex() {
// happen if the user defines a label that matches one of
// the specials. Who would do that, though?
if(Debugger::debugger().equates()->getAddress(idbuf) > -1) {
if(Debugger::debugger().equates().getAddress(idbuf) > -1) {
yylval.equate = idbuf;
return EQUATE;
} else if( (cpuMeth = getCpuSpecial(idbuf)) ) {