Bare beginnings of DebuggerParser & its supporting cast. The only

command that works as yet is "quit", and it doesn't actually quit
anything :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@475 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-06-09 04:31:45 +00:00
parent f277b89710
commit f37ab61597
9 changed files with 154 additions and 4 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: makefile,v 1.88 2005-06-08 18:45:07 stephena Exp $
## $Id: makefile,v 1.89 2005-06-09 04:31:44 urchlay Exp $
##============================================================================
##============================================================================
@ -170,6 +170,7 @@ CORE_OBJS = Booster.o Cart.o Cart2K.o Cart3F.o Cart4K.o CartAR.o CartDPC.o \
Props.o PropsSet.o Random.o SoundNull.o Switches.o Settings.o TIA.o \
Serializer.o Deserializer.o EventHandler.o FrameBuffer.o \
OSystem.o FSNode.o unzip.o \
DebuggerParser.o DebuggerCommand.o DCmdQuit.o \
$(M6502_OBJS) $(GUI_OBJS)
stella: $(CORE_OBJS) $(OBJS)
@ -454,3 +455,13 @@ DebuggerDialog.o: $(GUI)/DebuggerDialog.cxx $(GUI)/DebuggerDialog.hxx
PromptDialog.o: $(GUI)/PromptDialog.cxx $(GUI)/PromptDialog.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(GUI)/PromptDialog.cxx
DebuggerParser.o: $(COMMON)/DebuggerParser.cxx $(COMMON)/DebuggerParser.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DebuggerParser.cxx
DebuggerCommand.o: $(COMMON)/DebuggerCommand.cxx $(COMMON)/DebuggerCommand.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DebuggerCommand.cxx
DCmdQuit.o: $(COMMON)/DCmdQuit.cxx $(COMMON)/DCmdQuit.hxx
$(CXX) -c $(FLAGS) $(OPTIONS) $(LDFLAGS) $(COMMON)/DCmdQuit.cxx

View File

@ -0,0 +1,24 @@
#include "bspf.hxx"
#include "DCmdQuit.hxx"
#include "DebuggerParser.hxx"
DCmdQuit::DCmdQuit(DebuggerParser* p) {
parser = p;
}
string DCmdQuit::getName() {
return "Quit";
}
int DCmdQuit::getArgCount() {
return 0;
}
string DCmdQuit::execute() {
parser->setDone();
return "If you quit the debugger, I'll summon Satan all over your hard drive!";
}

View File

@ -0,0 +1,19 @@
#ifndef DCMDQUIT_HXX
#define DCMDQUIT_HXX
#include "bspf.hxx"
#include "DebuggerParser.hxx"
#include "DebuggerCommand.hxx"
class DCmdQuit: public DebuggerCommand
{
public:
DCmdQuit(DebuggerParser* p);
string getName();
int getArgCount();
string execute();
};
#endif

View File

@ -0,0 +1,11 @@
#include "bspf.hxx"
#include "DebuggerCommand.hxx"
#include "DebuggerParser.hxx"
DebuggerCommand::DebuggerCommand() {
}
DebuggerCommand::DebuggerCommand(DebuggerParser* p) {
parser = p;
}

View File

@ -0,0 +1,23 @@
#ifndef DEBUGGER_COMMAND_HXX
#define DEBUGGER_COMMAND_HXX
#include "bspf.hxx"
class DebuggerParser;
class DebuggerCommand
{
public:
DebuggerCommand();
DebuggerCommand(DebuggerParser* p);
virtual string getName() = 0;
virtual int getArgCount() = 0;
virtual string execute() = 0;
protected:
DebuggerParser *parser;
};
#endif

View File

@ -0,0 +1,27 @@
#include "bspf.hxx"
#include "DebuggerParser.hxx"
#include "DebuggerCommand.hxx"
#include "DCmdQuit.hxx"
DebuggerParser::DebuggerParser() {
done = false;
quitCmd = new DCmdQuit(this);
}
string DebuggerParser::currentAddress() {
return "currentAddress()";
}
void DebuggerParser::setDone() {
done = true;
}
string DebuggerParser::run(string command) {
if(command == "quit") {
// TODO: use lookup table to determine which DebuggerCommand to run
return quitCmd->execute();
} else {
return "unimplemented command";
}
}

View File

@ -0,0 +1,21 @@
#ifndef DEBUGGER_PARSER_HXX
#define DEBUGGER_PARSER_HXX
#include "bspf.hxx"
#include "DebuggerCommand.hxx"
class DebuggerParser
{
public:
DebuggerParser();
string currentAddress();
void setDone();
string run(string command);
private:
DebuggerCommand *quitCmd;
bool done;
};
#endif

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: PromptDialog.cxx,v 1.5 2005-06-08 21:16:06 stephena Exp $
// $Id: PromptDialog.cxx,v 1.6 2005-06-09 04:31:45 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -72,6 +72,10 @@ PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent,
_promptStartPos = _promptEndPos = -1;
// Init parser (FIXME: should the parser be a class variable,
// instead of an instance variable?
parser = new DebuggerParser();
// Display greetings & prompt
string version = string("Stella version ") + STELLA_VERSION + "\n";
print(version.c_str());
@ -168,7 +172,8 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers)
if (_callbackProc)
keepRunning = (*_callbackProc)(this, str, _callbackRefCon);
cerr << "Command entered: \'" << str << "\'\n"; // FIXME - tie this into DebuggerParser
print( parser->run(str) + "\n" );
// Get rid of the string buffer
delete [] str;
}
@ -626,6 +631,12 @@ void PromptDialog::putcharIntern(int c)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptDialog::print(string str) // laziness/convenience method
{
print(str.c_str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PromptDialog::print(const char *str)
{

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: PromptDialog.hxx,v 1.3 2005-06-08 18:45:09 stephena Exp $
// $Id: PromptDialog.hxx,v 1.4 2005-06-09 04:31:45 urchlay Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -28,6 +28,7 @@ class ScrollBarWidget;
#include <stdarg.h>
#include "Dialog.hxx"
#include "DebuggerParser.hxx"
enum {
kBufferSize = 32768,
@ -69,6 +70,7 @@ class PromptDialog : public Dialog
void putcharIntern(int c);
void insertIntoPrompt(const char *str);
void print(const char *str);
void print(string str);
void updateScrollBuffer();
void scrollToCurrent();
@ -104,6 +106,7 @@ class PromptDialog : public Dialog
int _promptEndPos;
ScrollBarWidget* _scrollBar;
DebuggerParser* parser;
// The _callbackProc is called whenver a data line is entered
//