From 12f43029dce51119c7fba40486c82339f2a9908b Mon Sep 17 00:00:00 2001 From: Sven Schnelle Date: Tue, 6 Nov 2018 14:57:00 +0100 Subject: debugger: add 'gp' command gp 'go privilege' starts execution until the privilege mode changes. This can be used to break on task switches. I.e on m68k, one could do: gp { ~sr & 0x2000 && crp_aptr == 0x1234567 } which would execute until the privilege mode changes to user mode and the CPU root pointer is 0x1234567. for cpu code, all that is needed to make this work is calling debugger_privilege_hook() when the execution level changes. --- src/emu/debug/debugcpu.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'src/emu/debug/debugcpu.cpp') diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 3ebd9951a8a..d668b826261 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1513,7 +1513,7 @@ void device_debug::interrupt_hook(int irqline) void device_debug::exception_hook(int exception) { - // see if this matches a pending interrupt request + // see if this matches an exception breakpoint if ((m_flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (m_stopexception == -1 || m_stopexception == exception)) { m_device.machine().debugger().cpu().set_execution_stopped(); @@ -1523,6 +1523,37 @@ void device_debug::exception_hook(int exception) } +//------------------------------------------------- +// privilege_hook - called when privilege level is +// changed +//------------------------------------------------- + +void device_debug::privilege_hook() +{ + bool matched = 1; + + if ((m_flags & DEBUG_FLAG_STOP_PRIVILEGE) != 0) + { + if (m_privilege_condition && !m_privilege_condition->is_empty()) + { + try + { + matched = m_privilege_condition->execute(); + } + catch (...) + { + } + } + + if (matched) + { + m_device.machine().debugger().cpu().set_execution_stopped(); + m_device.machine().debugger().console().printf("Stopped due to privilege change\n", m_device.tag()); + compute_debug_flags(); + } + } +} + //------------------------------------------------- // instruction_hook - called by the CPU cores // before executing each instruction @@ -1860,6 +1891,21 @@ void device_debug::go_milliseconds(u64 milliseconds) } +//------------------------------------------------- +// go_privilege - execute until execution +// level changes +//------------------------------------------------- + +void device_debug::go_privilege(const char *condition) +{ + assert(m_exec != nullptr); + m_device.machine().rewind_invalidate(); + m_privilege_condition = std::make_unique(&m_symtable, condition); + m_flags |= DEBUG_FLAG_STOP_PRIVILEGE; + m_device.machine().debugger().cpu().set_execution_running(); +} + + //------------------------------------------------- // halt_on_next_instruction_impl - halt in the // debugger on the next instruction, internal -- cgit v1.2.3