2005-06-09 15:08:23 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
2005-06-09 15:08:23 +00:00
|
|
|
// 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
|
|
|
|
//
|
2016-12-30 00:00:30 +00:00
|
|
|
// Copyright (c) 1995-2017 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2005-06-09 04:31:45 +00:00
|
|
|
|
|
|
|
#ifndef DEBUGGER_PARSER_HXX
|
|
|
|
#define DEBUGGER_PARSER_HXX
|
|
|
|
|
2014-11-17 00:08:23 +00:00
|
|
|
#include <functional>
|
2017-08-18 21:17:35 +00:00
|
|
|
#include <set>
|
2010-04-10 00:52:47 +00:00
|
|
|
|
2005-06-12 18:18:01 +00:00
|
|
|
class Debugger;
|
2017-11-16 17:01:20 +00:00
|
|
|
class Settings;
|
2010-10-18 18:39:57 +00:00
|
|
|
class FilesystemNode;
|
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"
|
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:
|
2013-07-27 22:28:41 +00:00
|
|
|
DebuggerParser(Debugger& debugger, Settings& settings);
|
2005-09-15 19:43:36 +00:00
|
|
|
|
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' */
|
2017-10-10 10:00:10 +00:00
|
|
|
string exec(const FilesystemNode& file, StringList* history = nullptr);
|
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 */
|
2014-11-07 15:52:24 +00:00
|
|
|
int decipher_arg(const string& str);
|
2006-12-02 23:25:55 +00:00
|
|
|
|
|
|
|
/** String representation of all watches currently defined */
|
|
|
|
string showWatches();
|
|
|
|
|
|
|
|
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();
|
2017-10-08 16:54:10 +00:00
|
|
|
string saveScriptFile(string file);
|
2005-09-15 19:43:36 +00:00
|
|
|
|
|
|
|
private:
|
2017-11-13 19:39:53 +00:00
|
|
|
enum { kNumCommands = 91 };
|
2006-12-02 23:25:55 +00:00
|
|
|
|
|
|
|
// Constants for argument processing
|
|
|
|
enum {
|
|
|
|
kIN_COMMAND,
|
|
|
|
kIN_SPACE,
|
|
|
|
kIN_BRACE,
|
|
|
|
kIN_ARG
|
|
|
|
};
|
|
|
|
|
2014-11-07 15:52:24 +00:00
|
|
|
enum parameters {
|
2006-12-02 23:25:55 +00:00
|
|
|
kARG_WORD, // single 16-bit value
|
2017-10-02 12:23:08 +00:00
|
|
|
kARG_DWORD, // single 32-bit value
|
2006-12-02 23:25:55 +00:00
|
|
|
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
|
2014-11-07 15:52:24 +00:00
|
|
|
};
|
2006-12-02 23:25:55 +00:00
|
|
|
|
|
|
|
struct Command {
|
|
|
|
string cmdString;
|
|
|
|
string description;
|
2017-04-04 16:47:10 +00:00
|
|
|
string extendedDesc;
|
2006-12-02 23:25:55 +00:00
|
|
|
bool parmsRequired;
|
|
|
|
bool refreshRequired;
|
2014-11-17 00:08:23 +00:00
|
|
|
parameters parms[10];
|
2014-11-17 20:33:56 +00:00
|
|
|
std::function<void (DebuggerParser*)> executor;
|
2006-12-02 23:25:55 +00:00
|
|
|
};
|
2017-10-07 16:25:56 +00:00
|
|
|
struct Trap
|
|
|
|
{
|
|
|
|
bool read;
|
|
|
|
bool write;
|
|
|
|
uInt32 begin;
|
|
|
|
uInt32 end;
|
2017-10-07 21:45:32 +00:00
|
|
|
string condition;
|
2017-10-07 16:25:56 +00:00
|
|
|
};
|
2017-10-09 21:44:49 +00:00
|
|
|
|
2013-05-09 10:08:30 +00:00
|
|
|
// Reference to our debugger object
|
|
|
|
Debugger& debugger;
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2013-07-27 22:28:41 +00:00
|
|
|
// Reference to settings object (required for saving certain options)
|
|
|
|
Settings& settings;
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// The results of the currently running command
|
2010-04-10 00:52:47 +00:00
|
|
|
ostringstream commandResult;
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2017-10-09 21:15:40 +00:00
|
|
|
// currently execute command id
|
|
|
|
int myCommand;
|
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;
|
2017-04-15 21:30:50 +00:00
|
|
|
uInt32 argCount;
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2017-11-13 21:02:46 +00:00
|
|
|
uInt32 execDepth;
|
|
|
|
|
2017-10-09 21:44:49 +00:00
|
|
|
StringList myWatches;
|
|
|
|
|
2017-08-18 21:17:35 +00:00
|
|
|
// Keep track of traps (read and/or write)
|
2017-10-09 21:44:49 +00:00
|
|
|
vector<unique_ptr<Trap>> myTraps;
|
2017-10-09 21:15:40 +00:00
|
|
|
void listTraps(bool listCond);
|
2017-10-07 18:22:54 +00:00
|
|
|
string trapStatus(const Trap& trap);
|
2005-09-15 19:43:36 +00:00
|
|
|
|
2017-10-09 21:15:40 +00:00
|
|
|
// output the error with the example provided for the command
|
|
|
|
void outputCommandError(const string& errorMsg, int command);
|
|
|
|
|
2006-12-02 23:25:55 +00:00
|
|
|
// List of available command methods
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeA();
|
|
|
|
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();
|
2010-09-07 22:03:20 +00:00
|
|
|
void executeClearconfig();
|
2017-11-19 17:52:27 +00:00
|
|
|
void executeClearsavestateifs();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeCleartraps();
|
|
|
|
void executeClearwatches();
|
2010-04-10 00:52:47 +00:00
|
|
|
void executeCls();
|
2010-08-30 12:04:56 +00:00
|
|
|
void executeCode();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeColortest();
|
|
|
|
void executeD();
|
2010-08-30 12:04:56 +00:00
|
|
|
void executeData();
|
2017-04-08 02:41:02 +00:00
|
|
|
void executeDebugColors();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeDefine();
|
2017-10-09 21:44:49 +00:00
|
|
|
void executeDelbreakif();
|
2010-04-10 00:52:47 +00:00
|
|
|
void executeDelfunction();
|
2017-11-19 17:52:27 +00:00
|
|
|
void executeDelsavestateif();
|
2017-10-07 16:25:56 +00:00
|
|
|
void executeDeltrap();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeDelwatch();
|
|
|
|
void executeDisasm();
|
|
|
|
void executeDump();
|
|
|
|
void executeExec();
|
2011-05-26 16:14:46 +00:00
|
|
|
void executeExitRom();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeFrame();
|
|
|
|
void executeFunction();
|
2010-08-30 12:04:56 +00:00
|
|
|
void executeGfx();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeHelp();
|
2017-11-13 19:39:53 +00:00
|
|
|
void executeJoy0Up();
|
|
|
|
void executeJoy0Down();
|
|
|
|
void executeJoy0Left();
|
|
|
|
void executeJoy0Right();
|
|
|
|
void executeJoy0Fire();
|
|
|
|
void executeJoy1Up();
|
|
|
|
void executeJoy1Down();
|
|
|
|
void executeJoy1Left();
|
|
|
|
void executeJoy1Right();
|
|
|
|
void executeJoy1Fire();
|
2010-09-05 17:57:21 +00:00
|
|
|
void executeJump();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeListbreaks();
|
Many big improvements to disassembler directives. Directives are no
longer simply added to a list, but intelligently 'merged' (so that
the entire range represented by all directives contains no overlap).
This makes the disassembly a little faster, since it doesn't have to
iterate redundantly. Still TODO in this area is intelligent insertion
for the same type (ie, if inserting in between like blocks, the
blocks should coalesce, instead of being clipped and then a new range
inserted in between).
Added 'loadconfig' and 'saveconfig' debugger prompt commands, which
will eventually access Distella-like config files. No implementation
is present yet.
Added 'listconfig' debugger command, which lists all directives
currently defined by the user, as well as the directives resulting
from a disassembly of a bank (taking into account extra knowledge
that Stella has WRT cached entry points). This command can show
information for a specified bank, or all banks in the cart.
User-defined directives can now be removed; simply issue the same
command that caused an insertion (ie, attempting to insert the same
type and range will remove it instead).
Fixed bug in Distella processing of directives; similar to the
standalone Distella, directives should be processed *before* any
automatic code determination is done.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2121 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-08-31 16:37:27 +00:00
|
|
|
void executeListconfig();
|
2017-10-09 21:44:49 +00:00
|
|
|
void executeListfunctions();
|
2017-11-19 17:52:27 +00:00
|
|
|
void executeListsavestateifs();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeListtraps();
|
Many big improvements to disassembler directives. Directives are no
longer simply added to a list, but intelligently 'merged' (so that
the entire range represented by all directives contains no overlap).
This makes the disassembly a little faster, since it doesn't have to
iterate redundantly. Still TODO in this area is intelligent insertion
for the same type (ie, if inserting in between like blocks, the
blocks should coalesce, instead of being clipped and then a new range
inserted in between).
Added 'loadconfig' and 'saveconfig' debugger prompt commands, which
will eventually access Distella-like config files. No implementation
is present yet.
Added 'listconfig' debugger command, which lists all directives
currently defined by the user, as well as the directives resulting
from a disassembly of a bank (taking into account extra knowledge
that Stella has WRT cached entry points). This command can show
information for a specified bank, or all banks in the cart.
User-defined directives can now be removed; simply issue the same
command that caused an insertion (ie, attempting to insert the same
type and range will remove it instead).
Fixed bug in Distella processing of directives; similar to the
standalone Distella, directives should be processed *before* any
automatic code determination is done.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2121 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-08-31 16:37:27 +00:00
|
|
|
void executeLoadconfig();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeLoadstate();
|
|
|
|
void executeN();
|
2017-04-06 20:24:41 +00:00
|
|
|
void executePalette();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executePc();
|
2010-10-23 17:50:45 +00:00
|
|
|
void executePGfx();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executePrint();
|
2010-04-10 00:52:47 +00:00
|
|
|
void executeRam();
|
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();
|
2010-10-23 17:50:45 +00:00
|
|
|
void executeRow();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeRun();
|
|
|
|
void executeRunTo();
|
2010-04-09 20:13:12 +00:00
|
|
|
void executeRunToPc();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeS();
|
|
|
|
void executeSave();
|
Many big improvements to disassembler directives. Directives are no
longer simply added to a list, but intelligently 'merged' (so that
the entire range represented by all directives contains no overlap).
This makes the disassembly a little faster, since it doesn't have to
iterate redundantly. Still TODO in this area is intelligent insertion
for the same type (ie, if inserting in between like blocks, the
blocks should coalesce, instead of being clipped and then a new range
inserted in between).
Added 'loadconfig' and 'saveconfig' debugger prompt commands, which
will eventually access Distella-like config files. No implementation
is present yet.
Added 'listconfig' debugger command, which lists all directives
currently defined by the user, as well as the directives resulting
from a disassembly of a bank (taking into account extra knowledge
that Stella has WRT cached entry points). This command can show
information for a specified bank, or all banks in the cart.
User-defined directives can now be removed; simply issue the same
command that caused an insertion (ie, attempting to insert the same
type and range will remove it instead).
Fixed bug in Distella processing of directives; similar to the
standalone Distella, directives should be processed *before* any
automatic code determination is done.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2121 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-08-31 16:37:27 +00:00
|
|
|
void executeSaveconfig();
|
2013-03-04 23:35:26 +00:00
|
|
|
void executeSavedisassembly();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeSaverom();
|
|
|
|
void executeSaveses();
|
2013-09-12 22:37:01 +00:00
|
|
|
void executeSavesnap();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeSavestate();
|
2017-11-19 17:52:27 +00:00
|
|
|
void executeSavestateif();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeScanline();
|
|
|
|
void executeStep();
|
|
|
|
void executeTia();
|
|
|
|
void executeTrace();
|
|
|
|
void executeTrap();
|
2017-10-06 21:06:59 +00:00
|
|
|
void executeTrapif();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeTrapread();
|
2017-10-06 21:06:59 +00:00
|
|
|
void executeTrapreadif();
|
2017-10-09 21:44:49 +00:00
|
|
|
void executeTrapwrite();
|
|
|
|
void executeTrapwriteif();
|
2017-10-09 21:15:40 +00:00
|
|
|
void executeTraps(bool read, bool write, const string& command, bool cond = false);
|
2017-10-07 16:25:56 +00:00
|
|
|
void executeTrapRW(uInt32 addr, bool read, bool write, bool add = true); // not exposed by debugger
|
The emulation core now tracks access to DATA areas (currently, any address
used as a peek operand). Still TODO is deal with poke areas, which would
be relevant in carts with extended RAM.
The interaction between the internal tracking and Distella is now much
tighter, in that knowledge gained by Distella is used in the core code,
and vice versa. This allows the best of both worlds, where the internal
tracking finds stuff at runtime (that couldn't be found in a static
analysis), and Distella tracks potential paths (that haven't occurred at
runtime yet).
Added 'type' debugger prompt command, which basically queries an address
for its disassembly type (CODE/GFX/DATA, etc).
Added debugger commands to query the last address used in an operation
for various registers, but they're only stubs at the moment.
Updated the bankswitch schemes to deal with accesses in and around the
hotspot areas. Previously, peek accesses in these areas weren't being
recorded as DATA areas.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2145 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-10-10 20:24:22 +00:00
|
|
|
void executeType();
|
2013-07-27 22:28:41 +00:00
|
|
|
void executeUHex();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeUndef();
|
2017-10-12 15:43:41 +00:00
|
|
|
void executeUnwind();
|
2005-09-15 19:43:36 +00:00
|
|
|
void executeV();
|
|
|
|
void executeWatch();
|
2017-11-13 14:07:48 +00:00
|
|
|
void executeWinds(bool unwind);
|
2005-09-15 19:43:36 +00:00
|
|
|
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];
|
2015-04-26 19:02:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
DebuggerParser() = delete;
|
|
|
|
DebuggerParser(const DebuggerParser&) = delete;
|
|
|
|
DebuggerParser(DebuggerParser&&) = delete;
|
|
|
|
DebuggerParser& operator=(const DebuggerParser&) = delete;
|
|
|
|
DebuggerParser& operator=(DebuggerParser&&) = delete;
|
2005-06-25 06:27:01 +00:00
|
|
|
};
|
|
|
|
|
2005-06-09 04:31:45 +00:00
|
|
|
#endif
|