diff options
Diffstat (limited to 'src/emu/debug/debugcpu.cpp')
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 124 |
1 files changed, 35 insertions, 89 deletions
diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index afd8884cad9..37dcdc4bc93 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -29,12 +29,6 @@ #include <fstream> -enum -{ - EXECUTION_STATE_STOPPED, - EXECUTION_STATE_RUNNING -}; - const size_t debugger_cpu::NUM_TEMP_VARIABLES = 10; /*------------------------------------------------- @@ -49,7 +43,7 @@ debugger_cpu::debugger_cpu(running_machine &machine) , m_breakcpu(nullptr) , m_symtable(nullptr) , m_vblank_occurred(false) - , m_execution_state(EXECUTION_STATE_STOPPED) + , m_execution_state(exec_state::STOPPED) , m_stop_when_not_device(nullptr) , m_bpindex(1) , m_wpindex(1) @@ -144,58 +138,10 @@ void debugger_cpu::flush_traces() /*************************************************************************** - DEBUGGING STATUS AND INFORMATION -***************************************************************************/ - -/*------------------------------------------------- - get_visible_cpu - return the visible CPU - device (the one that commands should apply to) --------------------------------------------------*/ - -device_t* debugger_cpu::get_visible_cpu() -{ - return m_visiblecpu; -} - - -/*------------------------------------------------- - within_instruction_hook - true if the debugger - is currently live --------------------------------------------------*/ - -bool debugger_cpu::within_instruction_hook() -{ - return m_within_instruction_hook; -} - - -/*------------------------------------------------- - is_stopped - return true if the - current execution state is stopped --------------------------------------------------*/ - -bool debugger_cpu::is_stopped() -{ - return m_execution_state == EXECUTION_STATE_STOPPED; -} - - -/*************************************************************************** SYMBOL TABLE INTERFACES ***************************************************************************/ /*------------------------------------------------- - get_global_symtable - return the global - symbol table --------------------------------------------------*/ - -symbol_table* debugger_cpu::get_global_symtable() -{ - return m_symtable.get(); -} - - -/*------------------------------------------------- get_visible_symtable - return the locally-visible symbol table -------------------------------------------------*/ @@ -775,7 +721,7 @@ void debugger_cpu::process_source_file() std::string buf; // loop until the file is exhausted or until we are executing again - while (m_execution_state == EXECUTION_STATE_STOPPED + while (m_execution_state == exec_state::STOPPED && m_source_file && std::getline(*m_source_file, buf)) { @@ -1372,12 +1318,12 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) if (m_stop_when_not_device != nullptr && m_stop_when_not_device != device) { m_stop_when_not_device = nullptr; - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; reset_transient_flags(); } // if we're running, do some periodic updating - if (m_execution_state != EXECUTION_STATE_STOPPED) + if (m_execution_state != exec_state::STOPPED) { if (device == m_visiblecpu && osd_ticks() > m_last_periodic_update_time + osd_ticks_per_second() / 4) { // check for periodic updates @@ -1387,7 +1333,7 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) } else if (device == m_breakcpu) { // check for pending breaks - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; m_breakcpu = nullptr; } @@ -1399,7 +1345,7 @@ void debugger_cpu::start_hook(device_t *device, bool stop_on_vblank) // if we were waiting for a VBLANK, signal it now if (stop_on_vblank) { - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; m_machine.debugger().console().printf("Stopped at VBLANK\n"); } } @@ -1435,13 +1381,13 @@ void debugger_cpu::ensure_comments_loaded() void debugger_cpu::go_next_device(device_t *device) { m_stop_when_not_device = device; - m_execution_state = EXECUTION_STATE_RUNNING; + m_execution_state = exec_state::RUNNING; } void debugger_cpu::go_vblank() { m_vblank_occurred = false; - m_execution_state = EXECUTION_STATE_RUNNING; + m_execution_state = exec_state::RUNNING; } void debugger_cpu::halt_on_next_instruction(device_t *device, util::format_argument_pack<std::ostream> &&args) @@ -1456,7 +1402,7 @@ void debugger_cpu::halt_on_next_instruction(device_t *device, util::format_argum // if we are live, stop now, otherwise note that we want to break there if (device == m_livecpu) { - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; if (m_livecpu != nullptr) m_livecpu->debug()->compute_debug_flags(); } @@ -1634,7 +1580,7 @@ void device_debug::interrupt_hook(int irqline) // see if this matches a pending interrupt request if ((m_flags & DEBUG_FLAG_STOP_INTERRUPT) != 0 && (m_stopirq == -1 || m_stopirq == irqline)) { - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED); + m_device.machine().debugger().cpu().set_execution_stopped(); m_device.machine().debugger().console().printf("Stopped on interrupt (CPU '%s', IRQ %d)\n", m_device.tag(), irqline); compute_debug_flags(); } @@ -1651,7 +1597,7 @@ void device_debug::exception_hook(int exception) // see if this matches a pending interrupt request if ((m_flags & DEBUG_FLAG_STOP_EXCEPTION) != 0 && (m_stopexception == -1 || m_stopexception == exception)) { - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_STOPPED); + m_device.machine().debugger().cpu().set_execution_stopped(); m_device.machine().debugger().console().printf("Stopped on exception (CPU '%s', exception %d)\n", m_device.tag(), exception); compute_debug_flags(); } @@ -1690,11 +1636,11 @@ void device_debug::instruction_hook(offs_t curpc) m_trace->update(curpc); // per-instruction hook? - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc)) - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + if (!debugcpu.is_stopped() && (m_flags & DEBUG_FLAG_HOOKED) != 0 && (*m_instrhook)(m_device, curpc)) + debugcpu.set_execution_stopped(); // handle single stepping - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0) + if (!debugcpu.is_stopped() && (m_flags & DEBUG_FLAG_STEPPING_ANY) != 0) { // is this an actual step? if (m_stepaddr == ~0 || curpc == m_stepaddr) @@ -1705,7 +1651,7 @@ void device_debug::instruction_hook(offs_t curpc) // if we hit 0, stop if (m_stepsleft == 0) - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // update every 100 steps until we are within 200 of the end else if ((m_flags & DEBUG_FLAG_STEPPING_OUT) == 0 && (m_stepsleft < 200 || m_stepsleft % 100 == 0)) @@ -1718,20 +1664,20 @@ void device_debug::instruction_hook(offs_t curpc) } // handle breakpoints - if (debugcpu.execution_state() != EXECUTION_STATE_STOPPED && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) + if (!debugcpu.is_stopped() && (m_flags & (DEBUG_FLAG_STOP_TIME | DEBUG_FLAG_STOP_PC | DEBUG_FLAG_LIVE_BP)) != 0) { // see if we hit a target time if ((m_flags & DEBUG_FLAG_STOP_TIME) != 0 && machine.time() >= m_stoptime) { machine.debugger().console().printf("Stopped at time interval %.1g\n", machine.time().as_double()); - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); } // check the temp running breakpoint and break if we hit it else if ((m_flags & DEBUG_FLAG_STOP_PC) != 0 && m_stopaddr == curpc) { machine.debugger().console().printf("Stopped at temporary breakpoint %X on CPU '%s'\n", m_stopaddr, m_device.tag()); - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); } // check for execution breakpoints @@ -1740,7 +1686,7 @@ void device_debug::instruction_hook(offs_t curpc) } // if we are supposed to halt, do it now - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) { bool firststop = true; @@ -1760,7 +1706,7 @@ void device_debug::instruction_hook(offs_t curpc) // wait for the debugger; during this time, disable sound output m_device.machine().sound().debugger_mute(true); - while (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + while (debugcpu.is_stopped()) { // flush any pending updates before waiting again machine.debug_view().flush_osd_updates(); @@ -1785,7 +1731,7 @@ void device_debug::instruction_hook(offs_t curpc) // if an event got scheduled, resume if (machine.scheduled_event_pending()) - debugcpu.set_execution_state(EXECUTION_STATE_RUNNING); + debugcpu.set_execution_stopped(); } m_device.machine().sound().debugger_mute(false); @@ -1888,7 +1834,7 @@ void device_debug::single_step(int numsteps) m_stepsleft = numsteps; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1905,7 +1851,7 @@ void device_debug::single_step_over(int numsteps) m_stepsleft = numsteps; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING_OVER; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1922,7 +1868,7 @@ void device_debug::single_step_out() m_stepsleft = 100; m_stepaddr = ~0; m_flags |= DEBUG_FLAG_STEPPING_OUT; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1938,7 +1884,7 @@ void device_debug::go(offs_t targetpc) m_device.machine().rewind_invalidate(); m_stopaddr = targetpc; m_flags |= DEBUG_FLAG_STOP_PC; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -1968,7 +1914,7 @@ void device_debug::go_interrupt(int irqline) m_device.machine().rewind_invalidate(); m_stopirq = irqline; m_flags |= DEBUG_FLAG_STOP_INTERRUPT; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } void device_debug::go_next_device() @@ -1988,7 +1934,7 @@ void device_debug::go_exception(int exception) m_device.machine().rewind_invalidate(); m_stopexception = exception; m_flags |= DEBUG_FLAG_STOP_EXCEPTION; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -2004,7 +1950,7 @@ void device_debug::go_milliseconds(u64 milliseconds) m_device.machine().rewind_invalidate(); m_stoptime = m_device.machine().time() + attotime::from_msec(milliseconds); m_flags |= DEBUG_FLAG_STOP_TIME; - m_device.machine().debugger().cpu().set_execution_state(EXECUTION_STATE_RUNNING); + m_device.machine().debugger().cpu().set_execution_running(); } @@ -2556,7 +2502,7 @@ void device_debug::compute_debug_flags() return; // if we're stopped, keep calling the hook - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) machine.debug_flags |= DEBUG_FLAG_CALL_HOOK; // if we're tracking history, or we're hooked, or stepping, or stopping at a breakpoint @@ -2659,14 +2605,14 @@ void device_debug::breakpoint_check(offs_t pc) if (bp->hit(pc)) { // halt in the debugger by default - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // if we hit, evaluate the action if (!bp->m_action.empty()) m_device.machine().debugger().console().execute_command(bp->m_action, false); // print a notification, unless the action made us go again - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) m_device.machine().debugger().console().printf("Stopped at breakpoint %X\n", bp->m_index); break; } @@ -2677,7 +2623,7 @@ void device_debug::breakpoint_check(offs_t pc) if (rp->hit()) { // halt in the debugger by default - debugcpu.set_execution_state(EXECUTION_STATE_STOPPED); + debugcpu.set_execution_stopped(); // if we hit, evaluate the action if (!rp->m_action.empty()) @@ -2686,7 +2632,7 @@ void device_debug::breakpoint_check(offs_t pc) } // print a notification, unless the action made us go again - if (debugcpu.execution_state() == EXECUTION_STATE_STOPPED) + if (debugcpu.is_stopped()) { m_device.machine().debugger().console().printf("Stopped at registerpoint %X\n", rp->m_index); } @@ -2794,14 +2740,14 @@ void debugger_cpu::watchpoint_check(address_space& space, int type, offs_t addre if (wp->hit(type, address, size)) { // halt in the debugger by default - m_execution_state = EXECUTION_STATE_STOPPED; + m_execution_state = exec_state::STOPPED; // if we hit, evaluate the action if (!wp->action().empty()) m_machine.debugger().console().execute_command(wp->action(), false); // print a notification, unless the action made us go again - if (m_execution_state == EXECUTION_STATE_STOPPED) + if (m_execution_state == exec_state::STOPPED) { static const char *const sizes[] = { |