Some cleanups to various classes, removing some debug print statements.

Partial cleanup of the debugger 'help' command, making the output line
up a little nicer.  More work is required in this area.

Fixed bug in EditableWidget; setEditString now implies that editing will
be started (if it's been enabled).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1987 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-04-03 17:11:23 +00:00
parent 7bd307ebc8
commit 1103f1dfbb
10 changed files with 69 additions and 55 deletions

View File

@ -264,9 +264,6 @@ bool CartDebug::fillDisassemblyList(uInt16 start, bool autocode, uInt16 search)
if(tag.address == search)
found = true;
}
// TODO - look at list, extract address to label mappings
// we need these for label support in the UI and promptwidget
}
return found;
}
@ -418,8 +415,6 @@ string CartDebug::loadSymbolFile(const string& f)
else
file += ".sym";
cerr << "loadSymbolFile: " << file << endl;
int pos = 0, lines = 0, curVal;
string curLabel;
char line[1024];

View File

@ -26,6 +26,7 @@
#include "Version.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "FSNode.hxx"
#include "Settings.hxx"
#include "DebuggerDialog.hxx"
#include "DebuggerParser.hxx"
@ -319,7 +320,9 @@ void Debugger::autoExec()
// autoexec.stella is always run
const string& autoexec = myOSystem->baseDir() + BSPF_PATH_SEPARATOR +
"autoexec.stella";
myPrompt->print("autoExec():\n" + myParser->exec(autoexec) + "\n");
FilesystemNode autoexec_node(autoexec);
if(autoexec_node.exists())
myPrompt->print("autoExec():\n" + myParser->exec(autoexec) + "\n");
// Also, "romname.stella" if present
string file = myOSystem->romFile();
@ -330,20 +333,18 @@ void Debugger::autoExec()
else
file += ".stella";
myPrompt->print("autoExec():\n" + myParser->exec(file) + "\n");
myPrompt->printPrompt();
FilesystemNode romname_node(file);
if(romname_node.exists())
myPrompt->print("autoExec():\n" + myParser->exec(file) + "\n");
// Init builtins
for(int i = 0; builtin_functions[i][0] != ""; i++)
{
// TODO - check this for memory leaks
int res = YaccParser::parse(builtin_functions[i][1].c_str());
if(res != 0)
{
cerr << "ERROR in builtin function!" << endl;
Expression* exp = YaccParser::getResult();
addFunction(builtin_functions[i][0], builtin_functions[i][1], exp, true);
}
if(res != 0) cerr << "ERROR in builtin function!" << endl;
Expression* exp = YaccParser::getResult();
addFunction(builtin_functions[i][0], builtin_functions[i][1], exp, true);
}
}
@ -806,29 +807,38 @@ const FunctionDefMap Debugger::getFunctionDefMap() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::builtinHelp() const
{
string result;
ostringstream buf;
uInt16 len, c_maxlen = 0, i_maxlen = 0;
for(int i=0; builtin_functions[i][0] != ""; i++)
// Get column widths for aligned output
for(int i = 0; builtin_functions[i][0] != ""; ++i)
{
result += builtin_functions[i][0];
result += " {";
result += builtin_functions[i][1];
result += "}\n";
result += " ";
result += builtin_functions[i][2];
result += "\n";
len = builtin_functions[i][0].length();
if(len > c_maxlen) c_maxlen = len;
len = builtin_functions[i][1].length();
if(len > i_maxlen) i_maxlen = len;
}
return result;
for(int i = 0; builtin_functions[i][0] != ""; ++i)
{
buf << setw(c_maxlen) << left << builtin_functions[i][0]
<< setw(2) << right << "{"
<< setw(i_maxlen) << left << builtin_functions[i][1]
<< setw(4) << "}"
<< builtin_functions[i][2]
<< endl;
}
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::saveROM(const string& filename) const
{
// TODO: error checking
ofstream *out = new ofstream(filename.c_str(), ios::out | ios::binary);
bool res = myConsole->cartridge().save(*out);
delete out;
return res;
ofstream out(filename.c_str(), ios::out | ios::binary);
if(out.is_open())
return myConsole->cartridge().save(out);
else
return false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -919,25 +919,34 @@ void DebuggerParser::executeExec()
// "help"
void DebuggerParser::executeHelp()
{
static char buf[256];
ostringstream buf;
// Find length of longest command
uInt16 clen = 0;
for(int i = 0; i < kNumCommands; ++i)
{
BSPF_snprintf(buf, 255, "%13s - %s\n",
commands[i].cmdString.c_str(),
commands[i].description.c_str());
commandResult += buf;
uInt16 len = commands[i].cmdString.length();
if(len > clen) clen = len;
}
commandResult += "\nBuilt-in functions:\n";
commandResult += debugger->builtinHelp();
commandResult += "\nPseudo-registers:\n";
commandResult += "_bank Currently selected bank\n";
commandResult += "_rwport Read from a write port was triggered\n";
commandResult += "_scan Current scanline count\n";
commandResult += "_fcount Number of frames since emulation started\n";
commandResult += "_cclocks Color clocks on current scanline\n";
commandResult += "_vsync Whether vertical sync is enabled (1 or 0)\n";
commandResult += "_vblank Whether vertical blank is enabled (1 or 0)\n";
// TODO - add wraparound for text longer than the output area bounds
for(int i = 0; i < kNumCommands; ++i)
buf << setw(clen) << right << commands[i].cmdString << " - " << commands[i].description << endl;
buf << endl
<< "\nPseudo-registers:" << endl
<< "_bank Currently selected bank" << endl
<< "_rwport Address at which a read from a write port occurred" << endl
<< "_scan Current scanline count" << endl
<< "_fcount Number of frames since emulation started" << endl
<< "_cclocks Color clocks on current scanline" << endl
<< "_vsync Whether vertical sync is enabled (1 or 0)" << endl
<< "_vblank Whether vertical blank is enabled (1 or 0)" << endl
<< endl
<< "Built-in functions:" << endl
<< debugger->builtinHelp();
commandResult = buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -507,7 +507,6 @@ void PromptWidget::loadConfig()
// Display greetings & prompt
string version = string("Stella ") + STELLA_VERSION + "\n";
print(version.c_str());
print("Debugger is ready\n");
print(PROMPT);
_promptStartPos = _promptEndPos = _currentPos;

View File

@ -123,14 +123,12 @@ void RomWidget::loadConfig()
myListIsDirty |= cart.disassemble(myAutocode->getSelectedTag(), myListIsDirty);
if(myListIsDirty)
{
cerr << "list is dirty, re-disassembled\n";
myRomList->setList(cart.disassemblyList(), dbg.breakpoints());
myListIsDirty = false;
}
// Update romlist to point to current PC
int pcline = cart.addressToLine(dbg.cpuDebug().pc());
cerr << "PC = " << hex << dbg.cpuDebug().pc() << ", line = " << dec << pcline << endl;
if(pcline >= 0)
myRomList->setHighlighted(pcline);
@ -166,6 +164,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
if(rmb == "saverom")
{
mySaveRom->show(_x + 50, _y + 80);
mySaveRom->setEditString("");
mySaveRom->setTitle("");
mySaveRom->setEmitSignal(kRomNameEntered);
}

View File

@ -32,7 +32,7 @@ EditableWidget::EditableWidget(GuiObject* boss, const GUI::Font& font,
{
_caretVisible = false;
_caretTime = 0;
_caretPos = 0; // FIXME
_caretPos = 0;
_caretInverse = false;
@ -61,6 +61,9 @@ void EditableWidget::setEditString(const string& str)
if (_editScrollOffset < 0)
_editScrollOffset = 0;
if(_editable)
startEditMode();
// Make sure the new string is seen onscreen
setDirty(); draw();
}

View File

@ -54,9 +54,9 @@ class EditableWidget : public Widget, public CommandSender
virtual bool wantsFocus() { return _editable; }
protected:
virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); _editString = ""; }
virtual void endEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); _editString = ""; }
virtual void abortEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); _editString = ""; }
virtual void startEditMode() { setFlags(WIDGET_WANTS_RAWDATA); }
virtual void endEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); }
virtual void abortEditMode() { clearFlags(WIDGET_WANTS_RAWDATA); }
virtual GUI::Rect getEditRect() const = 0;
virtual int getCaretOffset() const;

View File

@ -76,7 +76,6 @@ int parse(const char *in)
lastExp = 0;
errMsg = "(no error)";
setInput(in);
cerr << "PARSE: " << in << endl;
return yyparse();
}

View File

@ -6,7 +6,7 @@ Expression* lastExp = 0;
#define YYERROR_VERBOSE 1
/* dump Expression stack during parsing? */
#define DEBUG_EXP 1
#define DEBUG_EXP 0
int yylex();
char *yytext;

View File

@ -77,7 +77,7 @@ Expression* lastExp = 0;
#define YYERROR_VERBOSE 1
/* dump Expression stack during parsing? */
#define DEBUG_EXP 1
#define DEBUG_EXP 0
int yylex();
char *yytext;