Previous 199869 Revisions Next

r22816 Tuesday 14th May, 2013 at 04:24:31 UTC by Andrew Gardner
Adds statesave (ss) & stateload (sl) commands to the debugger.  [Andrew Gardner]
[src/emu]machine.c machine.h
[src/emu/debug]debugcmd.c debughlp.c

trunk/src/emu/machine.c
r22815r22816
585585
586586
587587//-------------------------------------------------
588//  immediate_save - save state.
589//-------------------------------------------------
590
591void running_machine::immediate_save(const char *filename)
592{
593   // specify the filename to save or load
594   set_saveload_filename(filename);
595
596   // set up some parameters for handle_saveload()
597   m_saveload_schedule = SLS_SAVE;
598   m_saveload_schedule_time = this->time();
599
600   // jump right into the save, anonymous timers can't hurt us!
601   handle_saveload();
602}
603
604
605//-------------------------------------------------
588606//  schedule_load - schedule a load to occur as
589607//  soon as possible
590608//-------------------------------------------------
r22815r22816
604622
605623
606624//-------------------------------------------------
625//  immediate_load - load state.
626//-------------------------------------------------
627
628void running_machine::immediate_load(const char *filename)
629{
630   // specify the filename to save or load
631   set_saveload_filename(filename);
632
633   // set up some parameters for handle_saveload()
634   m_saveload_schedule = SLS_LOAD;
635   m_saveload_schedule_time = this->time();
636
637   // jump right into the load, anonymous timers can't hurt us
638   handle_saveload();
639}
640
641
642//-------------------------------------------------
607643//  pause - pause the system
608644//-------------------------------------------------
609645
trunk/src/emu/machine.h
r22815r22816
264264   void add_logerror_callback(logerror_callback callback);
265265   void set_ui_active(bool active) { m_ui_active = active; }
266266
267   // TODO: Do saves and loads still require scheduling?
268   void immediate_save(const char *filename);
269   void immediate_load(const char *filename);
270
267271   // scheduled operations
268272   void schedule_exit();
269273   void schedule_hard_reset();
trunk/src/emu/debug/debugcmd.c
r22815r22816
129129static void execute_rpdisenable(running_machine &machine, int ref, int params, const char **param);
130130static void execute_rplist(running_machine &machine, int ref, int params, const char **param);
131131static void execute_hotspot(running_machine &machine, int ref, int params, const char **param);
132static void execute_statesave(running_machine &machine, int ref, int params, const char **param);
133static void execute_stateload(running_machine &machine, int ref, int params, const char **param);
132134static void execute_save(running_machine &machine, int ref, int params, const char **param);
133135static void execute_load(running_machine &machine, int ref, int params, const char **param);
134136static void execute_dump(running_machine &machine, int ref, int params, const char **param);
r22815r22816
326328
327329   debug_console_register_command(machine, "hotspot",   CMDFLAG_NONE, 0, 0, 3, execute_hotspot);
328330
331   debug_console_register_command(machine, "statesave", CMDFLAG_NONE, 0, 1, 1, execute_statesave);
332   debug_console_register_command(machine, "ss",        CMDFLAG_NONE, 0, 1, 1, execute_statesave);
333   debug_console_register_command(machine, "stateload", CMDFLAG_NONE, 0, 1, 1, execute_stateload);
334   debug_console_register_command(machine, "sl",        CMDFLAG_NONE, 0, 1, 1, execute_stateload);
335
329336   debug_console_register_command(machine, "save",      CMDFLAG_NONE, AS_PROGRAM, 3, 4, execute_save);
330337   debug_console_register_command(machine, "saved",     CMDFLAG_NONE, AS_DATA, 3, 4, execute_save);
331338   debug_console_register_command(machine, "savei",     CMDFLAG_NONE, AS_IO, 3, 4, execute_save);
r22815r22816
380387
381388   debug_console_register_command(machine, "source",    CMDFLAG_NONE, 0, 1, 1, execute_source);
382389
383   debug_console_register_command(machine, "map",      CMDFLAG_NONE, AS_PROGRAM, 1, 1, execute_map);
384   debug_console_register_command(machine, "mapd",     CMDFLAG_NONE, AS_DATA, 1, 1, execute_map);
385   debug_console_register_command(machine, "mapi",     CMDFLAG_NONE, AS_IO, 1, 1, execute_map);
386   debug_console_register_command(machine, "memdump",  CMDFLAG_NONE, 0, 0, 1, execute_memdump);
390   debug_console_register_command(machine, "map",       CMDFLAG_NONE, AS_PROGRAM, 1, 1, execute_map);
391   debug_console_register_command(machine, "mapd",      CMDFLAG_NONE, AS_DATA, 1, 1, execute_map);
392   debug_console_register_command(machine, "mapi",      CMDFLAG_NONE, AS_IO, 1, 1, execute_map);
393   debug_console_register_command(machine, "memdump",   CMDFLAG_NONE, 0, 0, 1, execute_memdump);
387394
388   debug_console_register_command(machine, "symlist",  CMDFLAG_NONE, 0, 0, 1, execute_symlist);
395   debug_console_register_command(machine, "symlist",  CMDFLAG_NONE, 0, 0, 1, execute_symlist);
389396
390   debug_console_register_command(machine, "softreset",    CMDFLAG_NONE, 0, 0, 1, execute_softreset);
391   debug_console_register_command(machine, "hardreset",    CMDFLAG_NONE, 0, 0, 1, execute_hardreset);
397   debug_console_register_command(machine, "softreset", CMDFLAG_NONE, 0, 0, 1, execute_softreset);
398   debug_console_register_command(machine, "hardreset", CMDFLAG_NONE, 0, 0, 1, execute_hardreset);
392399
393   debug_console_register_command(machine, "images",   CMDFLAG_NONE, 0, 0, 0, execute_images);
394   debug_console_register_command(machine, "mount",    CMDFLAG_NONE, 0, 2, 2, execute_mount);
395   debug_console_register_command(machine, "unmount",  CMDFLAG_NONE, 0, 1, 1, execute_unmount);
400   debug_console_register_command(machine, "images",    CMDFLAG_NONE, 0, 0, 0, execute_images);
401   debug_console_register_command(machine, "mount",     CMDFLAG_NONE, 0, 2, 2, execute_mount);
402   debug_console_register_command(machine, "unmount",   CMDFLAG_NONE, 0, 1, 1, execute_unmount);
396403
397   debug_console_register_command(machine, "input",    CMDFLAG_NONE, 0, 1, 1, execute_input);
398   debug_console_register_command(machine, "dumpkbd",  CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
404   debug_console_register_command(machine, "input",     CMDFLAG_NONE, 0, 1, 1, execute_input);
405   debug_console_register_command(machine, "dumpkbd",   CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
399406
400407   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
401408
r22815r22816
16951702
16961703
16971704/*-------------------------------------------------
1705    execute_statesave - execute the statesave command
1706-------------------------------------------------*/
1707
1708static void execute_statesave(running_machine &machine, int ref, int params, const char *param[])
1709{
1710   astring filename(param[0]);
1711   machine.immediate_save(filename);
1712   debug_console_printf(machine, "State save attempted.  Please refer to window message popup for results.\n");
1713}
1714
1715
1716/*-------------------------------------------------
1717    execute_stateload - execute the stateload command
1718-------------------------------------------------*/
1719
1720static void execute_stateload(running_machine &machine, int ref, int params, const char *param[])
1721{
1722   astring filename(param[0]);
1723   machine.immediate_load(filename);
1724   
1725   // Clear all PC & memory tracks
1726   device_iterator iter(machine.root_device());
1727   for (device_t *device = iter.first(); device != NULL; device = iter.next())
1728   {
1729      device->debug()->track_pc_data_clear();
1730      device->debug()->track_mem_data_clear();
1731   }
1732   debug_console_printf(machine, "State load attempted.  Please refer to window message popup for results.\n");
1733}
1734
1735
1736/*-------------------------------------------------
16981737    execute_save - execute the save command
16991738-------------------------------------------------*/
17001739
trunk/src/emu/debug/debughlp.c
r22815r22816
8787      "  printf <format>[,<item>[,...]] -- prints one or more <item>s to the console using <format>\n"
8888      "  logerror <format>[,<item>[,...]] -- outputs one or more <item>s to the error.log\n"
8989      "  tracelog <format>[,<item>[,...]] -- outputs one or more <item>s to the trace file using <format>\n"
90      "  history [<cpu>,<length>] -- outputs a brief history of visited opcodes.\n"
91      "  trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear].\n"
92      "  trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear].\n"
93      "  pcatmemp <address>[,<cpu>] -- query which PC wrote to a given program memory address for the current CPU.\n"
94      "  pcatmemd <address>[,<cpu>] -- query which PC wrote to a given data memory address for the current CPU.\n"
95      "  pcatmemi <address>[,<cpu>] -- query which PC wrote to a given I/O memory address for the current CPU.\n"
96      "                                (Note: you can also query this info by right clicking in a memory window.\n"
97      "  snap [<filename>] -- save a screen snapshot\n"
90      "  history [<cpu>,<length>] -- outputs a brief history of visited opcodes\n"
91      "  trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear]\n"
92      "  trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear]\n"
93      "  pcatmemp <address>[,<cpu>] -- query which PC wrote to a given program memory address for the current CPU\n"
94      "  pcatmemd <address>[,<cpu>] -- query which PC wrote to a given data memory address for the current CPU\n"
95      "  pcatmemi <address>[,<cpu>] -- query which PC wrote to a given I/O memory address for the current CPU\n"
96      "                                (Note: you can also query this info by right clicking in a memory window\n"
97      "  statesave[ss] <filename> -- save a state file for the current driver\n"
98      "  stateload[sl] <filename> -- load a state file for the current driver\n"
99      "  snap [<filename>] -- save a screen snapshot.\n"
98100      "  source <filename> -- reads commands from <filename> and executes them one by one\n"
99101      "  quit -- exits MAME and the debugger\n"
100102   },
r22815r22816
435437      "  Print which PC wrote this CPU's memory location 0x400000.\n"
436438   },
437439   {
440      "statesave[ss]",
441      "\n"
442      "  statesave[ss] <filename>\n"
443      "\n"
444      "The statesave command creates a save state at this exact moment in time. "
445      "The given state file gets written to the standard state directory (sta), and gets .sta to it - "
446      "no file extension necessary.  All output for this command is currently echoed into the "
447      "running machine window.\n"
448      "\n"
449      "Examples:\n"
450      "\n"
451      "statesave foo\n"
452      "  Writes file 'foo.sta' in the default state save directory.\n"
453   },
454   {
455      "stateload[sl]",
456      "\n"
457      "  stateload[ss] <filename>\n"
458      "\n"
459      "The stateload command retrieves a save state from disk. "
460      "The given state file gets read from the standard state directory (sta), and gets .sta to it - "
461      "no file extension necessary.  All output for this command is currently echoed into the "
462      "running machine window.  Previous memory and PC tracking statistics are cleared.\n"
463      "\n"
464      "Examples:\n"
465      "\n"
466      "stateload foo\n"
467      "  Reads file 'foo.sta' from the default state save directory.\n"
468   },
469   {
438470      "snap",
439471      "\n"
440472      "  snap [[<filename>], <scrnum>]\n"

Previous 199869 Revisions Next


© 1997-2024 The MAME Team