From e404f1ffe0a831a7b7a5cdb8acf9d98e89f7b76e Mon Sep 17 00:00:00 2001 From: npwoods Date: Tue, 2 Aug 2022 10:24:17 -0400 Subject: [PATCH] Changed gdbstub to no longer expect a CPU named ':maincpu' (#10170) The logic was changed to find the first CPU, without any particular expectation about naming. This should address issue #10141 --- src/osd/modules/debugger/debuggdbstub.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/osd/modules/debugger/debuggdbstub.cpp b/src/osd/modules/debugger/debuggdbstub.cpp index 5e477200dc2..cd21a4c5b1b 100644 --- a/src/osd/modules/debugger/debuggdbstub.cpp +++ b/src/osd/modules/debugger/debuggdbstub.cpp @@ -643,7 +643,19 @@ void debug_gdbstub::wait_for_debugger(device_t &device, bool firststop) if ( firststop && !m_initialized ) { - m_maincpu = m_machine->root_device().subdevice(":maincpu"); + // find the "main" CPU, which is the first CPU (gdbstub doesn't seem to have any notion of switching CPUs) + for (device_t &device : device_enumerator(m_machine->root_device())) + { + auto *cpu = dynamic_cast(&device); + if (cpu) + { + m_maincpu = cpu; + break; + } + } + if (!m_maincpu) + fatalerror("gdbstub: cannot find any CPUs\n"); + const char *cpuname = m_maincpu->shortname(); auto it = gdb_register_maps.find(cpuname); if ( it == gdb_register_maps.end() )