From 1a3b2ef914cbdf3a3a504d5d43aaa9d8dae1356d Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 13 Mar 2019 23:53:34 -0400 Subject: [PATCH] Exclude non-CPUs from numerical indexing for debugger commands --- src/emu/debug/debugcmd.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 7f650a2e356..72f4becbdcc 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -461,12 +461,17 @@ bool debugger_commands::validate_cpu_parameter(const char *param, device_t *&res return false; } - /* if we got a valid one, return */ - device_execute_interface *exec = execute_interface_iterator(m_machine.root_device()).byindex(cpunum); - if (exec != nullptr) + // attempt to find by numerical index + int index = 0; + for (device_execute_interface &exec : execute_interface_iterator(m_machine.root_device())) { - result = &exec->device(); - return true; + // real CPUs should have pcbase + const device_state_interface *state; + if (exec.device().interface(state) && state->state_string(STATE_GENPCBASE) != "???" && index++ == cpunum) + { + result = &exec.device(); + return true; + } } /* if out of range, complain */