diff options
author | Sven Schnelle <svens@stackframe.org> | 2018-11-06 14:57:00 +0100 |
---|---|---|
committer | Sven Schnelle <svens@stackframe.org> | 2018-11-06 15:44:52 +0100 |
commit | 12f43029dce51119c7fba40486c82339f2a9908b (patch) | |
tree | f9e38938a8462a076a34c66554797339d35a1a95 /src/emu/debug/debugcpu.cpp | |
parent | 25987a5fdc17899dbef5839b5821e5572ae05717 (diff) |
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.
Diffstat (limited to 'src/emu/debug/debugcpu.cpp')
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 48 |
1 files changed, 47 insertions, 1 deletions
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(); @@ -1524,6 +1524,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 //------------------------------------------------- @@ -1861,6 +1892,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<parsed_expression>(&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 // implementation which is necessary solely due |