Some updates to the PromptWidget and DebuggerParser.

The descriptions for the debugger commands are more streamlined
and better explained, and are neater when output.

Added 'cls' debugger command, which actually isn't for the debugger
at all, but for the prompt.  This erases all showing text and history.

Removed 'bank' debugger command, since it was already removed from
the RomWidget UI.

Removed 'listwatches' debugger command, since it wasn't implemented
anyway.  Besides, any watches are printed on every command access,
so it was pointless to have another function to do it.

Removed 'poke' debugger command; 'ram' and 'rom' do the same thing.

Fixed bugs in 'function' debugger command; it now correctly adds
functions without crashing.  Related to this, added 'listfunctions'
and 'delfunction' debugger commands for user-defined commands.

Fixed bug in completions for functions; it was including user-defined
functions twice.

Some general code cleanups in DebuggerParser (use ostringstream
instead of constantly creating new strings) and Expression
classes (make some methods const, for safety).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1998 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-04-10 00:52:47 +00:00
parent 10c82a9457
commit b781611925
10 changed files with 428 additions and 398 deletions

View File

@ -69,6 +69,16 @@
given program counter. This is also available in the ROM disassembly given program counter. This is also available in the ROM disassembly
UI. UI.
* Added 'listfunctions' and 'delfunction' debugger commands to
access/remove user-defined functions. Related to this, fixed a bug
in 'function' command that could cause a program crash.
* Added 'cls' debugger command, used to erase the text and history
from the debugger prompt.
* Removed the 'listwatches' and 'poke' debugger commands, as they
were redundant.
* Removed the 'loadlst' debugger command and the ability to use a * Removed the 'loadlst' debugger command and the ability to use a
DASM .lst file. With the recent disassembler improvements, this DASM .lst file. With the recent disassembler improvements, this
support is no longer feasible. support is no longer feasible.

View File

@ -571,63 +571,61 @@ can also get rid of all traps at once with the "cleartraps" command.</p>
<pre> <pre>
a - Set Accumulator to value xx a - Set Accumulator to value xx
bank - Show # of banks (with no args), Switch to bank (with 1 arg)
base - Set default base (hex, dec, or bin) base - Set default base (hex, dec, or bin)
break - Set/clear breakpoint at address (default: current pc) break - Set/clear breakpoint at address xx (default=PC)
breakif - Set breakpoint on condition breakif - Set breakpoint on condition xx
c - Carry Flag: set (to 0 or 1), or toggle (no arg) c - Carry Flag: set (0 or 1), or toggle (no arg)
cheat - Use a cheat code (see Stella manual for cheat types) cheat - Use a cheat code (see manual for cheat types)
clearbreaks - Clear all breakpoints clearbreaks - Clear all breakpoints
cleartraps - Clear all traps cleartraps - Clear all traps
clearwatches - Clear all watches clearwatches - Clear all watches
colortest - Color Test cls - Clear prompt area of text and erase history
d - Decimal Flag: set (to 0 or 1), or toggle (no arg) colortest - Show value xx as TIA color
define - Define label d - Decimal Flag: set (0 or 1), or toggle (no arg)
delbreakif - Delete conditional break created with breakif define - Define label xx for address yy
delwatch - Delete watch delbreakif - Delete conditional breakif xx
disasm - Disassemble from address (default=pc) delfunction - Delete function with label xx
dump - Dump 128 bytes of memory at address delwatch - Delete watch xx
exec - Execute script file disasm - Disassemble address xx [yy lines] (default=PC)
dump - Dump 128 bytes of memory at address xx
exec - Execute script file xx
frame - Advance emulation by xx frames (default=1) frame - Advance emulation by xx frames (default=1)
function - Define expression as a function for later use function - Define function name xx for expression yy
help - This cruft help - This cruft
+ list - List source (if loaded with loadlist)
listbreaks - List breakpoints listbreaks - List breakpoints
listfunctions - List user-defined functions
listtraps - List traps listtraps - List traps
listwatches - List watches loadstate - Load emulator state xx (0-9)
+ loadlist - Load DASM listing file loadsym - Load symbol file named xx
loadstate - Load emulator state (0-9) n - Negative Flag: set (0 or 1), or toggle (no arg)
loadsym - Load symbol file pc - Set Program Counter to address xx
n - Negative Flag: set (to 0 or 1), or toggle (no arg) print - Evaluate/print expression xx in hex/dec/binary
pc - Set Program Counter to address ram - Show ZP RAM, or set address xx to yy1 [yy2 ...]
poke - Set address to value. Can give multiple values (for address+1, etc) reset - Reset 6507 to init vector (excluding TIA/RIOT)
print - Evaluate and print expression in hex/dec/binary rewind - Rewind state to last step/trace/scanline/frame
ram - Show RAM contents (no args), or set address xx to value yy
reset - Reset 6507 to init vector (does not reset TIA, RIOT)
rewind - Rewind state to last step/trace/scanline/frame advance
riot - Show RIOT timer/input status riot - Show RIOT timer/input status
rom - Change ROM contents rom - Set ROM address xx to yy1 [yy2 ...]
run - Exit debugger, return to emulator run - Exit debugger, return to emulator
+ runto - Run until first occurrence of string in disassembly runto - Run until string xx in disassembly
runtopc - Run until PC is set to value xx
s - Set Stack Pointer to value xx s - Set Stack Pointer to value xx
save - Save breaks, watches, traps as a .stella script file save - Save breaks, watches, traps to file xx
saverom - Save (possibly patched) ROM to file saverom - Save (possibly patched) ROM to file xx
saveses - Save console session to file saveses - Save console session to file xx
savestate - Save emulator state (valid args 0-9) savestate - Save emulator state xx (valid args 0-9)
savesym - Save symbols to file
scanline - Advance emulation by xx scanlines (default=1) scanline - Advance emulation by xx scanlines (default=1)
step - Single step CPU (optionally, with count) step - Single step CPU [with count xx]
+ tia - Show TIA state (NOT FINISHED YET) tia - Show TIA state (NOT FINISHED YET)
trace - Single step CPU (optionally, with count), subroutines count as one instruction trace - Single step CPU over subroutines [with count xx]
trap - Trap read and write accesses to address trap - Trap read and write accesses to address xx
trapread - Trap read accesses to address trapread - Trap read accesses to address xx
trapwrite - Trap write accesses to address trapwrite - Trap write accesses to address xx
undef - Undefine label (if defined) undef - Undefine label xx (if defined)
v - Overflow Flag: set (to 0 or 1), or toggle (no arg) v - Overflow Flag: set (0 or 1), or toggle (no arg)
watch - Print contents of address before every prompt watch - Print contents of address xx before every prompt
x - Set X Register to value xx x - Set X Register to value xx
y - Set Y Register to value xx y - Set Y Register to value xx
z - Zero Flag: set (to 0 or 1), or toggle (no arg) z - Zero Flag: set (0 or 1), or toggle (no arg)
</pre> </pre>
<!-- <p>Commands marked with a * are unimplemented.</p> --> <!-- <p>Commands marked with a * are unimplemented.</p> -->

View File

@ -670,35 +670,38 @@ GUI::Rect Debugger::getTabBounds() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addFunction(const string& name, const string& definition, bool Debugger::addFunction(const string& name, const string& definition,
Expression* exp, bool builtin) Expression* exp, bool builtin)
{ {
functions.insert(make_pair(name, exp)); functions.insert(make_pair(name, exp));
if(!builtin) if(!builtin)
functionDefs.insert(make_pair(name, definition)); functionDefs.insert(make_pair(name, definition));
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::delFunction(const string& name) bool Debugger::delFunction(const string& name)
{ {
FunctionMap::iterator iter = functions.find(name); FunctionMap::iterator iter = functions.find(name);
if(iter == functions.end()) if(iter == functions.end())
return; return false;
functions.erase(name); functions.erase(name);
delete iter->second; delete iter->second;
FunctionDefMap::iterator def_iter = functionDefs.find(name); FunctionDefMap::iterator def_iter = functionDefs.find(name);
if(def_iter == functionDefs.end()) if(def_iter == functionDefs.end())
return; return false;
functionDefs.erase(name); functionDefs.erase(name);
return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expression* Debugger::getFunction(const string& name) const Expression* Debugger::getFunction(const string& name) const
{ {
FunctionMap::iterator iter = functions.find(name); FunctionMap::const_iterator iter = functions.find(name);
if(iter == functions.end()) if(iter == functions.end())
return 0; return 0;
else else
@ -706,11 +709,11 @@ Expression* Debugger::getFunction(const string& name)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Debugger::getFunctionDef(const string& name) const string& Debugger::getFunctionDef(const string& name) const
{ {
FunctionDefMap::iterator iter = functionDefs.find(name); FunctionDefMap::const_iterator iter = functionDefs.find(name);
if(iter == functionDefs.end()) if(iter == functionDefs.end())
return ""; return EmptyString;
else else
return iter->second; return iter->second;
} }
@ -722,7 +725,7 @@ const FunctionDefMap Debugger::getFunctionDefMap() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::builtinHelp() const string Debugger::builtinHelp() const
{ {
ostringstream buf; ostringstream buf;
uInt16 len, c_maxlen = 0, i_maxlen = 0; uInt16 len, c_maxlen = 0, i_maxlen = 0;
@ -751,20 +754,10 @@ const string Debugger::builtinHelp() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::getCompletions(const char* in, StringList& list) const void Debugger::getCompletions(const char* in, StringList& list) const
{ {
// First check built-in functions FunctionMap::const_iterator iter;
FunctionMap::const_iterator iter1; for(iter = functions.begin(); iter != functions.end(); ++iter)
for(iter1 = functions.begin(); iter1 != functions.end(); ++iter1)
{ {
const char* l = iter1->first.c_str(); const char* l = iter->first.c_str();
if(BSPF_strncasecmp(l, in, strlen(in)) == 0)
list.push_back(l);
}
// Now consider user-defined functions
FunctionDefMap::const_iterator iter2;
for(iter2 = functionDefs.begin(); iter2 != functionDefs.end(); ++iter2)
{
const char* l = iter2->first.c_str();
if(BSPF_strncasecmp(l, in, strlen(in)) == 0) if(BSPF_strncasecmp(l, in, strlen(in)) == 0)
list.push_back(l); list.push_back(l);
} }

View File

@ -120,14 +120,14 @@ class Debugger : public DialogContainer
*/ */
void quit(); void quit();
void addFunction(const string& name, const string& def, bool addFunction(const string& name, const string& def,
Expression* exp, bool builtin = false); Expression* exp, bool builtin = false);
void delFunction(const string& name); bool delFunction(const string& name);
Expression* getFunction(const string& name); const Expression* getFunction(const string& name) const;
string getFunctionDef(const string& name); const string& getFunctionDef(const string& name) const;
const FunctionDefMap getFunctionDefMap() const; const FunctionDefMap getFunctionDefMap() const;
const string builtinHelp() const; string builtinHelp() const;
/** /**
Methods used by the command parser for tab-completion Methods used by the command parser for tab-completion

View File

@ -36,7 +36,8 @@ class BinAndExpression : public Expression
{ {
public: public:
BinAndExpression(Expression* left, Expression* right) : Expression(left, right) {} BinAndExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() & myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() & myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -44,7 +45,8 @@ class BinNotExpression : public Expression
{ {
public: public:
BinNotExpression(Expression* left) : Expression(left, 0) {} BinNotExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return ~(myLHS->evaluate()); } uInt16 evaluate() const
{ return ~(myLHS->evaluate()); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -52,7 +54,8 @@ class BinOrExpression : public Expression
{ {
public: public:
BinOrExpression(Expression* left, Expression* right) : Expression(left, right) {} BinOrExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() | myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() | myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -60,7 +63,8 @@ class BinXorExpression : public Expression
{ {
public: public:
BinXorExpression(Expression* left, Expression* right) : Expression(left, right) {} BinXorExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() ^ myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() ^ myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -68,7 +72,8 @@ class ByteDerefExpression : public Expression
{ {
public: public:
ByteDerefExpression(Expression* left): Expression(left, 0) {} ByteDerefExpression(Expression* left): Expression(left, 0) {}
uInt16 evaluate() { return Debugger::debugger().peek(myLHS->evaluate()); } uInt16 evaluate() const
{ return Debugger::debugger().peek(myLHS->evaluate()); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -76,7 +81,8 @@ class ByteDerefOffsetExpression : public Expression
{ {
public: public:
ByteDerefOffsetExpression(Expression* left, Expression* right) : Expression(left, right) {} ByteDerefOffsetExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return Debugger::debugger().peek(myLHS->evaluate() + myRHS->evaluate()); } uInt16 evaluate() const
{ return Debugger::debugger().peek(myLHS->evaluate() + myRHS->evaluate()); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -84,7 +90,8 @@ class ConstExpression : public Expression
{ {
public: public:
ConstExpression(const int value) : Expression(0, 0), myValue(value) {} ConstExpression(const int value) : Expression(0, 0), myValue(value) {}
uInt16 evaluate() { return myValue; } uInt16 evaluate() const
{ return myValue; }
private: private:
int myValue; int myValue;
@ -95,7 +102,8 @@ class CpuMethodExpression : public Expression
{ {
public: public:
CpuMethodExpression(CPUDEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {} CpuMethodExpression(CPUDEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {}
uInt16 evaluate() { return CALL_CPUDEBUG_METHOD(myMethod); } uInt16 evaluate() const
{ return CALL_CPUDEBUG_METHOD(myMethod); }
private: private:
CPUDEBUG_INT_METHOD myMethod; CPUDEBUG_INT_METHOD myMethod;
@ -106,9 +114,9 @@ class DivExpression : public Expression
{ {
public: public:
DivExpression(Expression* left, Expression* right) : Expression(left, right) {} DivExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { int denom = myRHS->evaluate(); uInt16 evaluate() const
return denom == 0 ? 0 : myLHS->evaluate() / denom; { int denom = myRHS->evaluate();
} return denom == 0 ? 0 : myLHS->evaluate() / denom; }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -116,7 +124,8 @@ class EqualsExpression : public Expression
{ {
public: public:
EqualsExpression(Expression* left, Expression* right) : Expression(left, right) {} EqualsExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() == myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() == myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -124,7 +133,8 @@ class EquateExpression : public Expression
{ {
public: public:
EquateExpression(const string& label) : Expression(0, 0), myLabel(label) {} EquateExpression(const string& label) : Expression(0, 0), myLabel(label) {}
uInt16 evaluate() { return Debugger::debugger().cartDebug().getAddress(myLabel); } uInt16 evaluate() const
{ return Debugger::debugger().cartDebug().getAddress(myLabel); }
private: private:
string myLabel; string myLabel;
@ -135,10 +145,11 @@ class FunctionExpression : public Expression
{ {
public: public:
FunctionExpression(const string& label) : Expression(0, 0), myLabel(label) {} FunctionExpression(const string& label) : Expression(0, 0), myLabel(label) {}
uInt16 evaluate() { uInt16 evaluate() const
Expression* exp = Debugger::debugger().getFunction(myLabel); {
if(exp) return exp->evaluate(); const Expression* exp = Debugger::debugger().getFunction(myLabel);
else return 0; if(exp) return exp->evaluate();
else return 0;
} }
private: private:
@ -150,7 +161,8 @@ class GreaterEqualsExpression : public Expression
{ {
public: public:
GreaterEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {} GreaterEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() >= myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() >= myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -158,7 +170,8 @@ class GreaterExpression : public Expression
{ {
public: public:
GreaterExpression(Expression* left, Expression* right) : Expression(left, right) {} GreaterExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() > myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() > myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -166,7 +179,8 @@ class HiByteExpression : public Expression
{ {
public: public:
HiByteExpression(Expression* left) : Expression(left, 0) {} HiByteExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return 0xff & (myLHS->evaluate() >> 8); } uInt16 evaluate() const
{ return 0xff & (myLHS->evaluate() >> 8); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -174,7 +188,8 @@ class LessEqualsExpression : public Expression
{ {
public: public:
LessEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {} LessEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() <= myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() <= myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -182,7 +197,8 @@ class LessExpression : public Expression
{ {
public: public:
LessExpression(Expression* left, Expression* right) : Expression(left, right) {} LessExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() < myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() < myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -190,7 +206,8 @@ class LoByteExpression : public Expression
{ {
public: public:
LoByteExpression(Expression* left) : Expression(left, 0) {} LoByteExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return 0xff & myLHS->evaluate(); } uInt16 evaluate() const
{ return 0xff & myLHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -198,7 +215,8 @@ class LogAndExpression : public Expression
{ {
public: public:
LogAndExpression(Expression* left, Expression* right) : Expression(left, right) {} LogAndExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() && myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() && myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,7 +224,8 @@ class LogNotExpression : public Expression
{ {
public: public:
LogNotExpression(Expression* left) : Expression(left, 0) {} LogNotExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return !(myLHS->evaluate()); } uInt16 evaluate() const
{ return !(myLHS->evaluate()); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -214,7 +233,8 @@ class LogOrExpression : public Expression
{ {
public: public:
LogOrExpression(Expression* left, Expression* right) : Expression(left, right) {} LogOrExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() || myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() || myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -222,7 +242,8 @@ class MinusExpression : public Expression
{ {
public: public:
MinusExpression(Expression* left, Expression* right) : Expression(left, right) {} MinusExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() - myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() - myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -230,9 +251,9 @@ class ModExpression : public Expression
{ {
public: public:
ModExpression(Expression* left, Expression* right) : Expression(left, right) {} ModExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { int rhs = myRHS->evaluate(); uInt16 evaluate() const
return rhs == 0 ? 0 : myLHS->evaluate() % rhs; { int rhs = myRHS->evaluate();
} return rhs == 0 ? 0 : myLHS->evaluate() % rhs; }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -240,7 +261,8 @@ class MultExpression : public Expression
{ {
public: public:
MultExpression(Expression* left, Expression* right) : Expression(left, right) {} MultExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() * myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() * myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -248,7 +270,8 @@ class NotEqualsExpression : public Expression
{ {
public: public:
NotEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {} NotEqualsExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() != myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() != myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -256,7 +279,8 @@ class PlusExpression : public Expression
{ {
public: public:
PlusExpression(Expression* left, Expression* right) : Expression(left, right) {} PlusExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() + myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() + myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -264,7 +288,8 @@ class CartMethodExpression : public Expression
{ {
public: public:
CartMethodExpression(CARTDEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {} CartMethodExpression(CARTDEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {}
uInt16 evaluate() { return CALL_CARTDEBUG_METHOD(myMethod); } uInt16 evaluate() const
{ return CALL_CARTDEBUG_METHOD(myMethod); }
private: private:
CARTDEBUG_INT_METHOD myMethod; CARTDEBUG_INT_METHOD myMethod;
@ -275,7 +300,8 @@ class ShiftLeftExpression : public Expression
{ {
public: public:
ShiftLeftExpression(Expression* left, Expression* right) : Expression(left, right) {} ShiftLeftExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() << myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() << myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -283,7 +309,8 @@ class ShiftRightExpression : public Expression
{ {
public: public:
ShiftRightExpression(Expression* left, Expression* right) : Expression(left, right) {} ShiftRightExpression(Expression* left, Expression* right) : Expression(left, right) {}
uInt16 evaluate() { return myLHS->evaluate() >> myRHS->evaluate(); } uInt16 evaluate() const
{ return myLHS->evaluate() >> myRHS->evaluate(); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -291,7 +318,8 @@ class TiaMethodExpression : public Expression
{ {
public: public:
TiaMethodExpression(TIADEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {} TiaMethodExpression(TIADEBUG_INT_METHOD method) : Expression(0, 0), myMethod(method) {}
uInt16 evaluate() { return CALL_TIADEBUG_METHOD(myMethod); } uInt16 evaluate() const
{ return CALL_TIADEBUG_METHOD(myMethod); }
private: private:
TIADEBUG_INT_METHOD myMethod; TIADEBUG_INT_METHOD myMethod;
@ -302,7 +330,8 @@ class UnaryMinusExpression : public Expression
{ {
public: public:
UnaryMinusExpression(Expression* left) : Expression(left, 0) {} UnaryMinusExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return -(myLHS->evaluate()); } uInt16 evaluate() const
{ return -(myLHS->evaluate()); }
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -310,7 +339,8 @@ class WordDerefExpression : public Expression
{ {
public: public:
WordDerefExpression(Expression* left) : Expression(left, 0) {} WordDerefExpression(Expression* left) : Expression(left, 0) {}
uInt16 evaluate() { return Debugger::debugger().dpeek(myLHS->evaluate()); } uInt16 evaluate() const
{ return Debugger::debugger().dpeek(myLHS->evaluate()); }
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,8 @@
#ifndef DEBUGGER_PARSER_HXX #ifndef DEBUGGER_PARSER_HXX
#define DEBUGGER_PARSER_HXX #define DEBUGGER_PARSER_HXX
#include <sstream>
class Debugger; class Debugger;
struct Command; struct Command;
@ -119,7 +121,7 @@ class DebuggerParser
Debugger* debugger; Debugger* debugger;
// The results of the currently running command // The results of the currently running command
string commandResult; ostringstream commandResult;
// Arguments in 'int' and 'string' format for the currently running command // Arguments in 'int' and 'string' format for the currently running command
IntArray args; IntArray args;
@ -131,7 +133,6 @@ class DebuggerParser
// List of available command methods // List of available command methods
void executeA(); void executeA();
void executeBank();
void executeBase(); void executeBase();
void executeBreak(); void executeBreak();
void executeBreakif(); void executeBreakif();
@ -140,10 +141,12 @@ class DebuggerParser
void executeClearbreaks(); void executeClearbreaks();
void executeCleartraps(); void executeCleartraps();
void executeClearwatches(); void executeClearwatches();
void executeCls();
void executeColortest(); void executeColortest();
void executeD(); void executeD();
void executeDefine(); void executeDefine();
void executeDelbreakif(); void executeDelbreakif();
void executeDelfunction();
void executeDelwatch(); void executeDelwatch();
void executeDisasm(); void executeDisasm();
void executeDump(); void executeDump();
@ -152,14 +155,14 @@ class DebuggerParser
void executeFunction(); void executeFunction();
void executeHelp(); void executeHelp();
void executeListbreaks(); void executeListbreaks();
void executeListfunctions();
void executeListtraps(); void executeListtraps();
void executeListwatches();
void executeLoadstate(); void executeLoadstate();
void executeLoadsym(); void executeLoadsym();
void executeN(); void executeN();
void executePc(); void executePc();
void executePrint(); void executePrint();
void executeRam(); // also implements 'poke' command void executeRam();
void executeReset(); void executeReset();
void executeRewind(); void executeRewind();
void executeRiot(); void executeRiot();

View File

@ -40,7 +40,7 @@ class Expression
Expression(Expression* lhs, Expression* rhs); Expression(Expression* lhs, Expression* rhs);
virtual ~Expression(); virtual ~Expression();
virtual uInt16 evaluate() = 0; virtual uInt16 evaluate() const = 0;
protected: protected:
Expression* myLHS; Expression* myLHS;

View File

@ -59,14 +59,8 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
// Calculate depending values // Calculate depending values
_lineWidth = (_w - kScrollBarWidth - 2) / _kConsoleCharWidth; _lineWidth = (_w - kScrollBarWidth - 2) / _kConsoleCharWidth;
_linesPerPage = (_h - 2) / _kConsoleLineHeight; _linesPerPage = (_h - 2) / _kConsoleLineHeight;
memset(_buffer, 0, kBufferSize * sizeof(int));
_linesInBuffer = kBufferSize / _lineWidth; _linesInBuffer = kBufferSize / _lineWidth;
_currentPos = 0;
_scrollLine = _linesPerPage - 1;
_firstLineInBuffer = 0;
// Add scrollbar // Add scrollbar
_scrollBar = new ScrollBarWidget(boss, font, _x + _w, _y, kScrollBarWidth, _h); _scrollBar = new ScrollBarWidget(boss, font, _x + _w, _y, kScrollBarWidth, _h);
_scrollBar->setTarget(this); _scrollBar->setTarget(this);
@ -74,14 +68,7 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
// Init colors // Init colors
_inverse = false; _inverse = false;
// Init History clearScreen();
_historyIndex = 0;
_historyLine = 0;
_historySize = 0;
for (int i = 0; i < kHistorySize; i++)
_history[i][0] = '\0';
_promptStartPos = _promptEndPos = -1;
addFocusWidget(this); addFocusWidget(this);
} }
@ -908,3 +895,23 @@ string PromptWidget::getCompletionPrefix(const StringList& completions, string p
return prefix; return prefix;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::clearScreen()
{
// Initialize start position and history
_currentPos = 0;
_scrollLine = _linesPerPage - 1;
_firstLineInBuffer = 0;
_promptStartPos = _promptEndPos = -1;
memset(_buffer, 0, kBufferSize * sizeof(int));
_historyIndex = 0;
_historyLine = 0;
_historySize = 0;
for (int i = 0; i < kHistorySize; i++)
_history[i][0] = '\0';
if(!_firstTime)
updateScrollBuffer();
}

View File

@ -46,6 +46,9 @@ class PromptWidget : public Widget, public CommandSender
void printPrompt(); void printPrompt();
bool saveBuffer(string& filename); bool saveBuffer(string& filename);
// Clear screen and erase all history
void clearScreen();
protected: protected:
inline int &buffer(int idx) { return _buffer[idx % kBufferSize]; } inline int &buffer(int idx) { return _buffer[idx % kBufferSize]; }