2005-06-09 15:08:23 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// Copyright (c) 1995-2010 by Bradford W. Mott and the Stella Team
|
2005-06-09 15:08:23 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2005-06-09 15:08:23 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2005-06-09 15:08:23 +00:00
|
|
|
//============================================================================
|
2005-06-09 04:31:45 +00:00
|
|
|
|
|
|
|
#ifndef DEBUGGER_PARSER_HXX
|
|
|
|
#define DEBUGGER_PARSER_HXX
|
|
|
|
|
2005-06-12 18:18:01 +00:00
|
|
|
class Debugger;
|
2005-06-25 06:27:01 +00:00
|
|
|
struct Command;
|
2005-06-12 18:18:01 +00:00
|
|
|
|
2005-06-09 04:31:45 +00:00
|
|
|
#include "bspf.hxx"
|
Eliminated final Valgrind complaints about uninitialized data. The rest
occur in libraries, so there's not much I can do about those.
Eliminated memory leaks in DebuggerParser by using the GUI::Array class.
This is basically a dynamically sized array implementation. As a result,
there's no longer a hardcoded limit on the # of arguments or watches.
Brian, this new array class is a bit different than raw arrays in the
following ways:
1) You add to it with push_back(). You *can* add to it with index
notation, but it will assert and exit if you attempt to walk past the
end of it.
2) Because it's dynamically sized, you can't assume it has 100
elements (or even 1 element). That's why push_back() should be used
for assignment, unless you check the bound of the index first.
2) It has a size() method, so you always know how far to walk it.
3) You can erase all items with clear().
4) It makes use of templates, so is quite fast.
5) The syntax is close to STL containers. so when we eventually
move to a faster container (hashmap, etc), minimal syntax changes
will be required.
6) And finally, it frees you from having to deal with memory issues
(new/delete or malloc/free).
Have a look at gui/Array.hxx (which probably should be moved to
common/Array.hxx at some point).
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@541 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2005-06-21 23:01:25 +00:00
|
|
|
#include "Array.hxx"
|
2007-08-15 17:43:51 +00:00
|
|
|
#include "FrameBuffer.hxx"
|
2005-06-18 19:00:44 +00:00
|
|
|
|
2005-06-20 18:32:12 +00:00
|
|
|
typedef enum {
|
2005-06-19 08:29:40 +00:00
|
|
|
kBASE_16,
|
2005-08-16 18:34:12 +00:00
|
|
|
kBASE_16_4,
|
2005-06-19 08:29:40 +00:00
|
|
|
kBASE_10,
|
2005-06-20 02:36:39 +00:00
|
|
|
kBASE_2,
|
|
|
|
kBASE_DEFAULT
|
2005-06-20 18:32:12 +00:00
|
|
|
} BaseFormat;
|
2005-06-19 08:29:40 +00:00
|
|
|
|
2005-06-09 04:31:45 +00:00
|
|
|
class DebuggerParser
|
|
|
|
{
|
2005-09-15 19:43:36 +00:00
|
|
|
public:
|
|
|
|
DebuggerParser(Debugger* debugger);
|
|
|
|
~DebuggerParser();
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
/** Run the given command, and return the result */
|
2005-09-15 19:43:36 +00:00
|
|
|
string run(const string& command);
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
/** Execute parser commands given in 'file' */
|
|
|
|
string exec(const string& file, bool verbose = true);
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
/** Given a substring, determine matching substrings from the list
|
2010-04-04 13:15:35 +00:00
|
|
|
of available commands. Used in the debugger prompt for tab-completion */
|
2010-04-08 18:21:00 +00:00
|
|
|
void getCompletions(const char* in, StringList& list) const;
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
/** Evaluate the given expression using operators, current base, etc */
|
|
|
|
int decipher_arg(const string &str);
|
|
|
|
|
|
|
|
/** String representation of all watches currently defined */
|
|
|
|
string showWatches();
|
|
|
|
|
|
|
|
/** Get/set the number base when parsing numeric values */
|
|
|
|
void setBase(BaseFormat base) { defaultBase = base; }
|
|
|
|
BaseFormat base() { return defaultBase; }
|
|
|
|
|
|
|
|
static inline string red(const string& msg = "")
|
2005-09-15 19:43:36 +00:00
|
|
|
{
|
2007-08-15 17:43:51 +00:00
|
|
|
return char(kDbgChangedColor) + msg;
|
2005-09-15 19:43:36 +00:00
|
|
|
}
|
2006-12-02 23:25:55 +00:00
|
|
|
static inline string inverse(const string& msg = "")
|
2005-09-15 19:43:36 +00:00
|
|
|
{
|
|
|
|
// ASCII DEL char, decimal 127
|
|
|
|
return "\177" + msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2006-12-02 23:25:55 +00:00
|
|
|
bool getArgs(const string& command, string& verb);
|
2005-09-15 19:43:36 +00:00
|
|
|
bool validateArgs(int cmd);
|
|
|
|
string eval();
|
|
|
|
string trapStatus(int addr);
|
2006-12-02 23:25:55 +00:00
|
|
|
bool saveScriptFile(string file);
|
2005-09-15 19:43:36 +00:00
|
|
|
|
|
|
|
private:
|
2006-12-02 23:25:55 +00:00
|
|
|
enum {
|
2010-02-28 17:12:16 +00:00
|
|
|
kNumCommands = 55,
|
2006-12-02 23:25:55 +00:00
|
|
|
kMAX_ARG_TYPES = 10 // TODO: put in separate header file Command.hxx
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constants for argument processing
|
|
|
|
enum {
|
|
|
|
kIN_COMMAND,
|
|
|
|
kIN_SPACE,
|
|
|
|
kIN_BRACE,
|
|
|
|
kIN_ARG
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
kARG_WORD, // single 16-bit value
|
|
|
|
kARG_MULTI_WORD, // multiple 16-bit values (must occur last)
|
|
|
|
kARG_BYTE, // single 8-bit value
|
|
|
|
kARG_MULTI_BYTE, // multiple 8-bit values (must occur last)
|
|
|
|
kARG_BOOL, // 0 or 1 only
|
|
|
|
kARG_LABEL, // label (need not be defined, treated as string)
|
|
|
|
kARG_FILE, // filename
|
|
|
|
kARG_BASE_SPCL, // base specifier: 2, 10, or 16 (or "bin" "dec" "hex")
|
|
|
|
kARG_END_ARGS // sentinel, occurs at end of list
|
|
|
|
} parameters;
|
|
|
|
|
|
|
|
// Pointer to DebuggerParser instance method, no args, returns void.
|
|
|
|
typedef void (DebuggerParser::*METHOD)();
|
|
|
|
|
|
|
|
struct Command {
|
|
|
|
string cmdString;
|
|
|
|
string description;
|
|
|
|
bool parmsRequired;
|
|
|
|
bool refreshRequired;
|
|
|
|
parameters parms[kMAX_ARG_TYPES];
|
|
|
|
METHOD executor;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Pointer to our debugger object
|
2005-09-15 19:43:36 +00:00
|
|
|
Debugger* debugger;
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// The results of the currently running command
|
2005-09-15 19:43:36 +00:00
|
|
|
string commandResult;
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// Arguments in 'int' and 'string' format for the currently running command
|
2005-09-15 19:43:36 +00:00
|
|
|
IntArray args;
|
|
|
|
StringList argStrings;
|
|
|
|
int argCount;
|
|
|
|
|
|
|
|
BaseFormat defaultBase;
|
|
|
|
StringList watches;
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// List of available command methods
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeA();
|
|
|
|
void executeBank();
|
|
|
|
void executeBase();
|
|
|
|
void executeBreak();
|
|
|
|
void executeBreakif();
|
|
|
|
void executeC();
|
2005-11-11 21:44:19 +00:00
|
|
|
void executeCheat();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeClearbreaks();
|
|
|
|
void executeCleartraps();
|
|
|
|
void executeClearwatches();
|
|
|
|
void executeColortest();
|
|
|
|
void executeD();
|
|
|
|
void executeDefine();
|
|
|
|
void executeDelbreakif();
|
|
|
|
void executeDelwatch();
|
|
|
|
void executeDisasm();
|
|
|
|
void executeDump();
|
|
|
|
void executeExec();
|
|
|
|
void executeFrame();
|
|
|
|
void executeFunction();
|
|
|
|
void executeHelp();
|
|
|
|
void executeListbreaks();
|
|
|
|
void executeListtraps();
|
|
|
|
void executeListwatches();
|
|
|
|
void executeLoadstate();
|
2006-12-02 23:25:55 +00:00
|
|
|
void executeLoadsym();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeN();
|
|
|
|
void executePc();
|
|
|
|
void executePrint();
|
2006-12-02 23:25:55 +00:00
|
|
|
void executeRam(); // also implements 'poke' command
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeReset();
|
OK, this looks like a huge update, but it's only because of some Serializer
class reworking. Serializer class now handles read/write of state from
files as well as in-memory streams. As a result, Deserializer class has
been removed.
Added state rewinding to the debugger. For now, this is limited to 100
levels of undo, with a new state generated each time a step/trace/frame/
scanline advance is performed. The undo level is 'rolling', in that it
remembers the last 100 levels (so you lose the oldest states when you
start adding more than 100). For now, this is tied to the 'Alt-r' key
in the debugger. Still TODO is add a button for it, and clean up some
TIA output issues when rewinding.
Added support for 6K version of Supercharger ROMs (this fixes issues
with the 6K version of Cubis).
Cleaned up the Serializable infrastructure, making sure that all
classes that need to implement it actually do so now.
Fixed issue with editable widgets in the UI, where pressing Enter
on the keypad wasn't actually being registered.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1849 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2009-08-05 16:05:34 +00:00
|
|
|
void executeRewind();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeRiot();
|
|
|
|
void executeRom();
|
|
|
|
void executeRun();
|
|
|
|
void executeRunTo();
|
|
|
|
void executeS();
|
|
|
|
void executeSave();
|
|
|
|
void executeSaverom();
|
|
|
|
void executeSaveses();
|
|
|
|
void executeSavestate();
|
|
|
|
void executeScanline();
|
|
|
|
void executeStep();
|
|
|
|
void executeTia();
|
|
|
|
void executeTrace();
|
|
|
|
void executeTrap();
|
|
|
|
void executeTrapread();
|
|
|
|
void executeTrapwrite();
|
|
|
|
void executeUndef();
|
|
|
|
void executeV();
|
|
|
|
void executeWatch();
|
|
|
|
void executeX();
|
|
|
|
void executeY();
|
|
|
|
void executeZ();
|
2005-06-25 06:27:01 +00:00
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// List of commands available
|
|
|
|
static Command commands[kNumCommands];
|
2005-06-25 06:27:01 +00:00
|
|
|
};
|
|
|
|
|
2005-06-09 04:31:45 +00:00
|
|
|
#endif
|