Fixed bug in debugger 'run' and 'reload' commands; there's no longer a

segfault.

Fixed segfault with debugger 'runto' command.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1346 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2007-08-14 20:36:18 +00:00
parent d73b834a61
commit aceb1d1513
3 changed files with 26 additions and 32 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: DebuggerParser.cxx,v 1.98 2007-08-14 19:49:20 stephena Exp $ // $Id: DebuggerParser.cxx,v 1.99 2007-08-14 20:36:18 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -111,7 +111,6 @@ string DebuggerParser::run(const string& command)
if(commands[i].refreshRequired) if(commands[i].refreshRequired)
debugger->myBaseDialog->loadConfig(); debugger->myBaseDialog->loadConfig();
cerr << " ==> commandResult = " << commandResult << endl;
return commandResult; return commandResult;
} }
} }
@ -413,7 +412,6 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
argStrings.push_back(curArg); argStrings.push_back(curArg);
argCount = argStrings.size(); argCount = argStrings.size();
cerr << "count = " << argCount << endl;
/* /*
cerr << "verb = " << verb << endl; cerr << "verb = " << verb << endl;
cerr << "arguments (" << argCount << "):\n"; cerr << "arguments (" << argCount << "):\n";
@ -1729,7 +1727,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{ {
"runto", "runto",
"Run until first occurrence of string in disassembly", "Run until first occurrence of string in disassembly",
false, true,
true, true,
{ kARG_LABEL, kARG_END_ARGS }, { kARG_LABEL, kARG_END_ARGS },
&DebuggerParser::executeRunTo &DebuggerParser::executeRunTo

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: PromptWidget.cxx,v 1.19 2007-08-14 19:49:20 stephena Exp $ // $Id: PromptWidget.cxx,v 1.20 2007-08-14 20:36:18 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -49,7 +49,8 @@ PromptWidget::PromptWidget(GuiObject* boss, const GUI::Font& font,
: Widget(boss, font, x, y, w - kScrollBarWidth, h), : Widget(boss, font, x, y, w - kScrollBarWidth, h),
CommandSender(boss), CommandSender(boss),
_makeDirty(false), _makeDirty(false),
_firstTime(true) _firstTime(true),
_exitedEarly(false)
{ {
_flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS | _flags = WIDGET_ENABLED | WIDGET_CLEARBG | WIDGET_RETAIN_FOCUS |
WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA; WIDGET_WANTS_TAB | WIDGET_WANTS_RAWDATA;
@ -194,12 +195,14 @@ bool PromptWidget::handleKeyDown(int ascii, int keycode, int modifiers)
// This is a bit of a hack // This is a bit of a hack
// Certain commands remove the debugger dialog from underneath us, // Certain commands remove the debugger dialog from underneath us,
// so we shouldn't print any messages // so we shouldn't print any messages
// Those commands will return 'EXIT_DEBUGGER' as their result // Those commands will return '_EXIT_DEBUGGER' as their result
//cerr << " ==> result = \'" << result << "\'\n"; if(result == "_EXIT_DEBUGGER")
if(result == "_EXIT_DEBUGGER") {
return true; _exitedEarly = true;
return true;
print(result + "\n"); }
else
print(result + "\n");
} }
printPrompt(); printPrompt();
@ -509,18 +512,6 @@ GUI::Rect PromptWidget::getRect() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptWidget::loadConfig() void PromptWidget::loadConfig()
{ {
cerr << "loadConfig()" << endl
<< "_promptStartPos = " << _promptStartPos << endl
<< "_promptEndPos = " << _promptEndPos << endl
<< "_currentPos = " << _currentPos << endl
<< endl;
if(_promptStartPos != _currentPos)
{
print(PROMPT);
_promptStartPos = _promptEndPos = _currentPos;
}
// See logic at the end of handleKeyDown for an explanation of this // See logic at the end of handleKeyDown for an explanation of this
_makeDirty = true; _makeDirty = true;
@ -539,6 +530,11 @@ cerr << "loadConfig()" << endl
// Take care of one-time debugger stuff // Take care of one-time debugger stuff
instance()->debugger().autoExec(); instance()->debugger().autoExec();
} }
else if(_exitedEarly)
{
printPrompt();
_exitedEarly = false;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: PromptWidget.hxx,v 1.10 2007-08-14 19:49:20 stephena Exp $ // $Id: PromptWidget.hxx,v 1.11 2007-08-14 20:36:18 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -31,13 +31,6 @@ class ScrollBarWidget;
#include "Command.hxx" #include "Command.hxx"
#include "bspf.hxx" #include "bspf.hxx"
enum {
kBufferSize = 32768,
kLineBufferSize = 256,
kHistorySize = 20
};
class PromptWidget : public Widget, public CommandSender class PromptWidget : public Widget, public CommandSender
{ {
public: public:
@ -86,6 +79,12 @@ class PromptWidget : public Widget, public CommandSender
void loadConfig(); void loadConfig();
private: private:
enum {
kBufferSize = 32768,
kLineBufferSize = 256,
kHistorySize = 20
};
int _buffer[kBufferSize]; int _buffer[kBufferSize];
int _linesInBuffer; int _linesInBuffer;
@ -115,6 +114,7 @@ class PromptWidget : public Widget, public CommandSender
bool _inverse; bool _inverse;
bool _makeDirty; bool _makeDirty;
bool _firstTime; bool _firstTime;
bool _exitedEarly;
int compareHistory(const char *histLine); int compareHistory(const char *histLine);
}; };