Added image devices support to debugger [Miodrag Milanovic]

This commit is contained in:
Miodrag Milanovic 2011-06-08 07:03:24 +00:00
parent 5493aeb8fa
commit 9a6d2b7bac
2 changed files with 117 additions and 1 deletions

View File

@ -149,7 +149,9 @@ static void execute_memdump(running_machine &machine, int ref, int params, const
static void execute_symlist(running_machine &machine, int ref, int params, const char **param);
static void execute_softreset(running_machine &machine, int ref, int params, const char **param);
static void execute_hardreset(running_machine &machine, int ref, int params, const char **param);
static void execute_images(running_machine &machine, int ref, int params, const char **param);
static void execute_mount(running_machine &machine, int ref, int params, const char **param);
static void execute_unmount(running_machine &machine, int ref, int params, const char **param);
/***************************************************************************
@ -369,6 +371,10 @@ void debug_command_init(running_machine &machine)
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);
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
/* set up the initial debugscript if specified */
@ -2668,3 +2674,65 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con
{
machine.schedule_hard_reset();
}
/*-------------------------------------------------
execute_images - lists all image devices with
mounted files
-------------------------------------------------*/
static void execute_images(running_machine &machine, int ref, int params, const char **param)
{
device_image_interface *img = NULL;
for (bool gotone = machine.devicelist().first(img); gotone; gotone = img->next(img))
{
debug_console_printf(machine, "%s: %s\n",img->brief_instance_name(),img->exists() ? img->filename() : "[empty slot]");
}
if (!machine.devicelist().first(img)) {
debug_console_printf(machine, "No image devices in this driver\n");
}
}
/*-------------------------------------------------
execute_mount - execute the image mount command
-------------------------------------------------*/
static void execute_mount(running_machine &machine, int ref, int params, const char **param)
{
device_image_interface *img = NULL;
bool done = false;
for (bool gotone = machine.devicelist().first(img); gotone; gotone = img->next(img))
{
if (strcmp(img->brief_instance_name(),param[0])==0) {
if (img->load(param[1])==IMAGE_INIT_FAIL) {
debug_console_printf(machine, "Unable to mount file %s on %s\n",param[1],param[0]);
} else {
debug_console_printf(machine, "File %s mounted on %s\n",param[1],param[0]);
}
done = true;
break;
}
}
if (!done)
debug_console_printf(machine, "There is no image device :%s\n",param[0]);
}
/*-------------------------------------------------
execute_unmount - execute the image unmount command
-------------------------------------------------*/
static void execute_unmount(running_machine &machine, int ref, int params, const char **param)
{
device_image_interface *img = NULL;
bool done = false;
for (bool gotone = machine.devicelist().first(img); gotone; gotone = img->next(img))
{
if (strcmp(img->brief_instance_name(),param[0])==0) {
img->unload();
debug_console_printf(machine, "Unmounted file from : %s\n",param[0]);
done = true;
break;
}
}
if (!done)
debug_console_printf(machine, "There is no image device :%s\n",param[0]);
}

View File

@ -70,6 +70,7 @@ static const help_item static_help_list[] =
" Expressions\n"
" Comments\n"
" Cheats\n"
" Image\n"
},
{
"general",
@ -220,6 +221,16 @@ static const help_item static_help_list[] =
" cheatlist [<filename>] -- show the list of cheat search matches or save them to <filename>\n"
" cheatundo -- undo the last cheat search (state only)\n"
},
{
"image",
"\n"
"Image Commands\n"
"Type help <command> for further details on each command\n"
"\n"
" images -- lists all image devices and mounted files\n"
" mount <device>,<filename> -- mounts file to named device\n"
" unmount <device> -- unmounts file from named device\n"
},
{
"do",
"\n"
@ -1223,6 +1234,43 @@ static const help_item static_help_list[] =
"\n"
"cheatundo\n"
" Undo the last search (state only).\n"
},
{
"images",
"\n"
" images\n"
"\n"
"Used to display list of available image devices.\n"
"\n"
"Examples:\n"
"\n"
"images\n"
" Show list of devices and mounted files for current driver.\n"
},
{
"mount",
"\n"
" mount <device>,<filename>\n"
"\n"
"Mount <filename> to image <device>.\n"
"<filename> can be softlist item or full path to file.\n"
"\n"
"Examples:\n"
"\n"
"mount cart,aladdin\n"
" Mounts softlist item alladin on cart device.\n"
},
{
"unmount",
"\n"
" unmount <device>\n"
"\n"
"Unmounts file from image <device>.\n"
"\n"
"Examples:\n"
"\n"
"unmount cart\n"
" Unmounts any file mounted on device named cart.\n"
}
};