summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug
diff options
context:
space:
mode:
author Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-05-14 04:24:31 +0000
committer Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-05-14 04:24:31 +0000
commit9007f919828032503933eaab71f5f65ad94855ca (patch)
treec01eda98fe27c76d5738f54d193360cec92e72ac /src/emu/debug
parent8dba8bdf406a15dcb85df40d47ab7c921a7bb705 (diff)
Adds statesave (ss) & stateload (sl) commands to the debugger. [Andrew Gardner]
Diffstat (limited to 'src/emu/debug')
-rw-r--r--src/emu/debug/debugcmd.c63
-rw-r--r--src/emu/debug/debughlp.c48
2 files changed, 91 insertions, 20 deletions
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index 688c9f21914..6622f61fafc 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -129,6 +129,8 @@ static void execute_rpclear(running_machine &machine, int ref, int params, const
static void execute_rpdisenable(running_machine &machine, int ref, int params, const char **param);
static void execute_rplist(running_machine &machine, int ref, int params, const char **param);
static void execute_hotspot(running_machine &machine, int ref, int params, const char **param);
+static void execute_statesave(running_machine &machine, int ref, int params, const char **param);
+static void execute_stateload(running_machine &machine, int ref, int params, const char **param);
static void execute_save(running_machine &machine, int ref, int params, const char **param);
static void execute_load(running_machine &machine, int ref, int params, const char **param);
static void execute_dump(running_machine &machine, int ref, int params, const char **param);
@@ -326,6 +328,11 @@ void debug_command_init(running_machine &machine)
debug_console_register_command(machine, "hotspot", CMDFLAG_NONE, 0, 0, 3, execute_hotspot);
+ debug_console_register_command(machine, "statesave", CMDFLAG_NONE, 0, 1, 1, execute_statesave);
+ debug_console_register_command(machine, "ss", CMDFLAG_NONE, 0, 1, 1, execute_statesave);
+ debug_console_register_command(machine, "stateload", CMDFLAG_NONE, 0, 1, 1, execute_stateload);
+ debug_console_register_command(machine, "sl", CMDFLAG_NONE, 0, 1, 1, execute_stateload);
+
debug_console_register_command(machine, "save", CMDFLAG_NONE, AS_PROGRAM, 3, 4, execute_save);
debug_console_register_command(machine, "saved", CMDFLAG_NONE, AS_DATA, 3, 4, execute_save);
debug_console_register_command(machine, "savei", CMDFLAG_NONE, AS_IO, 3, 4, execute_save);
@@ -380,22 +387,22 @@ void debug_command_init(running_machine &machine)
debug_console_register_command(machine, "source", CMDFLAG_NONE, 0, 1, 1, execute_source);
- debug_console_register_command(machine, "map", CMDFLAG_NONE, AS_PROGRAM, 1, 1, execute_map);
- debug_console_register_command(machine, "mapd", CMDFLAG_NONE, AS_DATA, 1, 1, execute_map);
- debug_console_register_command(machine, "mapi", CMDFLAG_NONE, AS_IO, 1, 1, execute_map);
- debug_console_register_command(machine, "memdump", CMDFLAG_NONE, 0, 0, 1, execute_memdump);
+ debug_console_register_command(machine, "map", CMDFLAG_NONE, AS_PROGRAM, 1, 1, execute_map);
+ debug_console_register_command(machine, "mapd", CMDFLAG_NONE, AS_DATA, 1, 1, execute_map);
+ debug_console_register_command(machine, "mapi", CMDFLAG_NONE, AS_IO, 1, 1, execute_map);
+ debug_console_register_command(machine, "memdump", CMDFLAG_NONE, 0, 0, 1, execute_memdump);
- debug_console_register_command(machine, "symlist", CMDFLAG_NONE, 0, 0, 1, execute_symlist);
+ debug_console_register_command(machine, "symlist", CMDFLAG_NONE, 0, 0, 1, execute_symlist);
- debug_console_register_command(machine, "softreset", CMDFLAG_NONE, 0, 0, 1, execute_softreset);
- debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset);
+ debug_console_register_command(machine, "softreset", CMDFLAG_NONE, 0, 0, 1, execute_softreset);
+ debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset);
- debug_console_register_command(machine, "images", CMDFLAG_NONE, 0, 0, 0, execute_images);
- debug_console_register_command(machine, "mount", CMDFLAG_NONE, 0, 2, 2, execute_mount);
- debug_console_register_command(machine, "unmount", CMDFLAG_NONE, 0, 1, 1, execute_unmount);
+ debug_console_register_command(machine, "images", CMDFLAG_NONE, 0, 0, 0, execute_images);
+ debug_console_register_command(machine, "mount", CMDFLAG_NONE, 0, 2, 2, execute_mount);
+ debug_console_register_command(machine, "unmount", CMDFLAG_NONE, 0, 1, 1, execute_unmount);
- debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input);
- debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
+ debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input);
+ debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
@@ -1695,6 +1702,38 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
/*-------------------------------------------------
+ execute_statesave - execute the statesave command
+-------------------------------------------------*/
+
+static void execute_statesave(running_machine &machine, int ref, int params, const char *param[])
+{
+ astring filename(param[0]);
+ machine.immediate_save(filename);
+ debug_console_printf(machine, "State save attempted. Please refer to window message popup for results.\n");
+}
+
+
+/*-------------------------------------------------
+ execute_stateload - execute the stateload command
+-------------------------------------------------*/
+
+static void execute_stateload(running_machine &machine, int ref, int params, const char *param[])
+{
+ astring filename(param[0]);
+ machine.immediate_load(filename);
+
+ // Clear all PC & memory tracks
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
+ {
+ device->debug()->track_pc_data_clear();
+ device->debug()->track_mem_data_clear();
+ }
+ debug_console_printf(machine, "State load attempted. Please refer to window message popup for results.\n");
+}
+
+
+/*-------------------------------------------------
execute_save - execute the save command
-------------------------------------------------*/
diff --git a/src/emu/debug/debughlp.c b/src/emu/debug/debughlp.c
index de89766aac1..1a06b2cc30a 100644
--- a/src/emu/debug/debughlp.c
+++ b/src/emu/debug/debughlp.c
@@ -87,14 +87,16 @@ static const help_item static_help_list[] =
" printf <format>[,<item>[,...]] -- prints one or more <item>s to the console using <format>\n"
" logerror <format>[,<item>[,...]] -- outputs one or more <item>s to the error.log\n"
" tracelog <format>[,<item>[,...]] -- outputs one or more <item>s to the trace file using <format>\n"
- " history [<cpu>,<length>] -- outputs a brief history of visited opcodes.\n"
- " trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear].\n"
- " trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear].\n"
- " pcatmemp <address>[,<cpu>] -- query which PC wrote to a given program memory address for the current CPU.\n"
- " pcatmemd <address>[,<cpu>] -- query which PC wrote to a given data memory address for the current CPU.\n"
- " pcatmemi <address>[,<cpu>] -- query which PC wrote to a given I/O memory address for the current CPU.\n"
- " (Note: you can also query this info by right clicking in a memory window.\n"
- " snap [<filename>] -- save a screen snapshot\n"
+ " history [<cpu>,<length>] -- outputs a brief history of visited opcodes\n"
+ " trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear]\n"
+ " trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear]\n"
+ " pcatmemp <address>[,<cpu>] -- query which PC wrote to a given program memory address for the current CPU\n"
+ " pcatmemd <address>[,<cpu>] -- query which PC wrote to a given data memory address for the current CPU\n"
+ " pcatmemi <address>[,<cpu>] -- query which PC wrote to a given I/O memory address for the current CPU\n"
+ " (Note: you can also query this info by right clicking in a memory window\n"
+ " statesave[ss] <filename> -- save a state file for the current driver\n"
+ " stateload[sl] <filename> -- load a state file for the current driver\n"
+ " snap [<filename>] -- save a screen snapshot.\n"
" source <filename> -- reads commands from <filename> and executes them one by one\n"
" quit -- exits MAME and the debugger\n"
},
@@ -435,6 +437,36 @@ static const help_item static_help_list[] =
" Print which PC wrote this CPU's memory location 0x400000.\n"
},
{
+ "statesave[ss]",
+ "\n"
+ " statesave[ss] <filename>\n"
+ "\n"
+ "The statesave command creates a save state at this exact moment in time. "
+ "The given state file gets written to the standard state directory (sta), and gets .sta to it - "
+ "no file extension necessary. All output for this command is currently echoed into the "
+ "running machine window.\n"
+ "\n"
+ "Examples:\n"
+ "\n"
+ "statesave foo\n"
+ " Writes file 'foo.sta' in the default state save directory.\n"
+ },
+ {
+ "stateload[sl]",
+ "\n"
+ " stateload[ss] <filename>\n"
+ "\n"
+ "The stateload command retrieves a save state from disk. "
+ "The given state file gets read from the standard state directory (sta), and gets .sta to it - "
+ "no file extension necessary. All output for this command is currently echoed into the "
+ "running machine window. Previous memory and PC tracking statistics are cleared.\n"
+ "\n"
+ "Examples:\n"
+ "\n"
+ "stateload foo\n"
+ " Reads file 'foo.sta' from the default state save directory.\n"
+ },
+ {
"snap",
"\n"
" snap [[<filename>], <scrnum>]\n"