summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcmd.c
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2012-01-24 20:18:55 +0000
committer Aaron Giles <aaron@aarongiles.com>2012-01-24 20:18:55 +0000
commited0207f1267c34dd195a9807d47b74e9fab155e0 (patch)
treed162988b04326e6b945e0aa5c8a228acdb90f92a /src/emu/debug/debugcmd.c
parentf2ed9c39edc94438907152a05459483d930ab5ef (diff)
Move devices into a proper hierarchy and handle naming
and paths consistently for devices, I/O ports, memory regions, memory banks, and memory shares. [Aaron Giles] NOTE: there are likely regressions lurking here, mostly due to devices not being properly found. I have temporarily added more logging to -verbose to help understand what's going on. Please let me know ASAP if anything that is being actively worked on got broken. As before, the driver device is the root device and all other devices are owned by it. Previously all devices were kept in a single master list, and the hierarchy was purely logical. With this change, each device owns its own list of subdevices, and the hierarchy is explicitly manifest. This means when a device is removed, all of its subdevices are automatically removed as well. A side effect of this is that walking the device list is no longer simple. To address this, a new set of iterator classes is provided, which walks the device tree in a depth first manner. There is a general device_iterator class for walking all devices, plus templates for a device_type_iterator and a device_interface_iterator which are used to build iterators for identifying only devices of a given type or with a given interface. Typedefs for commonly-used cases (e.g., screen_device_iterator, memory_interface_iterator) are provided. Iterators can also provide counts, and can perform indexed lookups. All device name lookups are now done relative to another device. The maching_config and running_machine classes now have a root_device() method to get the root of the hierarchy. The existing machine->device("name") is now equivalent to machine->root_device().subdevice("name"). A proper and normalized device path structure is now supported. Device names that start with a colon are treated as absolute paths from the root device. Device names can also use a caret (^) to refer to the owning device. Querying the device's tag() returns the device's full path from the root. A new method basetag() returns just the final tag. The new pathing system is built on top of the device_t::subtag() method, so anyone using that will automatically support the new pathing rules. Each device has its own internal map to cache successful lookups so that subsequent lookups should be very fast. Updated every place I could find that referenced devices, memory regions, I/O ports, memory banks and memory shares to leverage subtag/subdevice (or siblingtag/siblingdevice which are built on top). Removed the device_list class, as it doesn't apply any more. Moved some of its methods into running_machine instead. Simplified the device callback system since the new pathing can describe all of the special-case devices that were previously handled manually. Changed the core output function callbacks to be delegates. Completely rewrote the validity checking mechanism. The validity checker is now a proper C++ class, and temporarily takes over the error and warning outputs. All errors and warnings are collected during a session, and then output in a consistent manner, with an explicit driver and source file listed for each one, as well as additional device and/or I/O port contexts where appropriate. Validity checkers should no longer explicitly output this information, just the error, assuming that the context is provided. Rewrote the software_list_device as a modern device, getting rid of the software_list_config abstraction and simplifying things. Changed the way FLAC compiles so that it works like other external libraries, and also compiles successfully for MSVC builds.
Diffstat (limited to 'src/emu/debug/debugcmd.c')
-rw-r--r--src/emu/debug/debugcmd.c78
1 files changed, 47 insertions, 31 deletions
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index 5f5606f1968..4711418c06d 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -391,7 +391,8 @@ void debug_command_init(running_machine &machine)
static void debug_command_exit(running_machine &machine)
{
/* turn off all traces */
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->debug()->trace(NULL, 0, NULL);
if (cheat.length)
@@ -545,8 +546,8 @@ int debug_command_parameter_cpu(running_machine &machine, const char *param, dev
}
/* if we got a valid one, return */
- device_execute_interface *exec = NULL;
- for (bool gotone = machine.devicelist().first(exec); gotone; gotone = exec->next(exec))
+ execute_interface_iterator iter(machine.root_device());
+ for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
if (cpunum-- == 0)
{
*result = &exec->device();
@@ -982,8 +983,8 @@ static void execute_focus(running_machine &machine, int ref, int params, const c
cpu->debug()->ignore(false);
/* then loop over CPUs and set the ignore flags on all other CPUs */
- device_execute_interface *exec = NULL;
- for (bool gotone = machine.devicelist().first(exec); gotone; gotone = exec->next(exec))
+ execute_interface_iterator iter(machine.root_device());
+ for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
if (&exec->device() != cpu)
exec->device().debug()->ignore(true);
debug_console_printf(machine, "Now focused on CPU '%s'\n", cpu->tag());
@@ -1002,8 +1003,8 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
astring buffer;
/* loop over all executable devices */
- device_execute_interface *exec = NULL;
- for (bool gotone = machine.devicelist().first(exec); gotone; gotone = exec->next(exec))
+ execute_interface_iterator iter(machine.root_device());
+ for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
/* build up a comma-separated list */
if (!exec->device().debug()->observing())
@@ -1034,11 +1035,14 @@ static void execute_ignore(running_machine &machine, int ref, int params, const
for (int paramnum = 0; paramnum < params; paramnum++)
{
/* make sure this isn't the last live CPU */
- device_execute_interface *exec = NULL;
- bool gotone;
- for (gotone = machine.devicelist().first(exec); gotone; gotone = exec->next(exec))
+ execute_interface_iterator iter(machine.root_device());
+ bool gotone = false;
+ for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
if (&exec->device() != devicelist[paramnum] && exec->device().debug()->observing())
+ {
+ gotone = true;
break;
+ }
if (!gotone)
{
debug_console_printf(machine, "Can't ignore all devices!\n");
@@ -1064,8 +1068,8 @@ static void execute_observe(running_machine &machine, int ref, int params, const
astring buffer;
/* loop over all executable devices */
- device_execute_interface *exec = NULL;
- for (bool gotone = machine.devicelist().first(exec); gotone; gotone = exec->next(exec))
+ execute_interface_iterator iter(machine.root_device());
+ for (device_execute_interface *exec = iter.first(); exec != NULL; exec = iter.next())
/* build up a comma-separated list */
if (exec->device().debug()->observing())
@@ -1214,7 +1218,8 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->debug()->breakpoint_clear_all();
debug_console_printf(machine, "Cleared all breakpoints\n");
}
@@ -1224,8 +1229,9 @@ static void execute_bpclear(running_machine &machine, int ref, int params, const
return;
else
{
+ device_iterator iter(machine.root_device());
bool found = false;
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->breakpoint_clear(bpindex))
found = true;
if (found)
@@ -1248,7 +1254,8 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->debug()->breakpoint_enable_all(ref);
if (ref == 0)
debug_console_printf(machine, "Disabled all breakpoints\n");
@@ -1261,8 +1268,9 @@ static void execute_bpdisenable(running_machine &machine, int ref, int params, c
return;
else
{
+ device_iterator iter(machine.root_device());
bool found = false;
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->breakpoint_enable(bpindex, ref))
found = true;
if (found)
@@ -1284,7 +1292,8 @@ static void execute_bplist(running_machine &machine, int ref, int params, const
astring buffer;
/* loop over all CPUs */
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->breakpoint_first() != NULL)
{
debug_console_printf(machine, "Device '%s' breakpoints:\n", device->tag());
@@ -1372,7 +1381,8 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->debug()->watchpoint_clear_all();
debug_console_printf(machine, "Cleared all watchpoints\n");
}
@@ -1382,8 +1392,9 @@ static void execute_wpclear(running_machine &machine, int ref, int params, const
return;
else
{
+ device_iterator iter(machine.root_device());
bool found = false;
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->watchpoint_clear(wpindex))
found = true;
if (found)
@@ -1406,7 +1417,8 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c
/* if 0 parameters, clear all */
if (params == 0)
{
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
device->debug()->watchpoint_enable_all(ref);
if (ref == 0)
debug_console_printf(machine, "Disabled all watchpoints\n");
@@ -1419,8 +1431,9 @@ static void execute_wpdisenable(running_machine &machine, int ref, int params, c
return;
else
{
+ device_iterator iter(machine.root_device());
bool found = false;
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->watchpoint_enable(wpindex, ref))
found = true;
if (found)
@@ -1442,7 +1455,8 @@ static void execute_wplist(running_machine &machine, int ref, int params, const
astring buffer;
/* loop over all CPUs */
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
for (address_spacenum spacenum = AS_0; spacenum < ADDRESS_SPACES; spacenum++)
if (device->debug()->watchpoint_first(spacenum) != NULL)
{
@@ -1484,7 +1498,8 @@ static void execute_hotspot(running_machine &machine, int ref, int params, const
bool cleared = false;
/* loop over CPUs and find live spots */
- for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
+ device_iterator iter(machine.root_device());
+ for (device_t *device = iter.first(); device != NULL; device = iter.next())
if (device->debug()->hotspot_tracking_enabled())
{
device->debug()->hotspot_track(0, 0);
@@ -2498,7 +2513,8 @@ static void execute_snap(running_machine &machine, int ref, int params, const ch
const char *filename = param[0];
int scrnum = (params > 1) ? atoi(param[1]) : 0;
- screen_device *screen = downcast<screen_device *>(machine.devicelist().find(SCREEN, scrnum));
+ screen_device_iterator iter(machine.root_device());
+ screen_device *screen = iter.byindex(scrnum);
if ((screen == NULL) || !machine.render().is_live(*screen))
{
@@ -2682,12 +2698,12 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con
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))
+ image_interface_iterator iter(machine.root_device());
+ for (device_image_interface *img = iter.first(); img != NULL; img = iter.next())
{
debug_console_printf(machine, "%s: %s\n",img->brief_instance_name(),img->exists() ? img->filename() : "[empty slot]");
}
- if (!machine.devicelist().first(img)) {
+ if (iter.first() == NULL) {
debug_console_printf(machine, "No image devices in this driver\n");
}
}
@@ -2698,9 +2714,9 @@ static void execute_images(running_machine &machine, int ref, int params, const
static void execute_mount(running_machine &machine, int ref, int params, const char **param)
{
- device_image_interface *img = NULL;
+ image_interface_iterator iter(machine.root_device());
bool done = false;
- for (bool gotone = machine.devicelist().first(img); gotone; gotone = img->next(img))
+ for (device_image_interface *img = iter.first(); img != NULL; img = iter.next())
{
if (strcmp(img->brief_instance_name(),param[0])==0) {
if (img->load(param[1])==IMAGE_INIT_FAIL) {
@@ -2722,9 +2738,9 @@ static void execute_mount(running_machine &machine, int ref, int params, const c
static void execute_unmount(running_machine &machine, int ref, int params, const char **param)
{
- device_image_interface *img = NULL;
+ image_interface_iterator iter(machine.root_device());
bool done = false;
- for (bool gotone = machine.devicelist().first(img); gotone; gotone = img->next(img))
+ for (device_image_interface *img = iter.first(); img != NULL; img = iter.next())
{
if (strcmp(img->brief_instance_name(),param[0])==0) {
img->unload();