summaryrefslogtreecommitdiffstats
path: root/src/emu/debugger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/debugger.cpp')
-rw-r--r--src/emu/debugger.cpp110
1 files changed, 94 insertions, 16 deletions
diff --git a/src/emu/debugger.cpp b/src/emu/debugger.cpp
index 849b16d068d..ca7f86030d1 100644
--- a/src/emu/debugger.cpp
+++ b/src/emu/debugger.cpp
@@ -23,6 +23,95 @@
static running_machine *g_machine = nullptr;
static int g_atexit_registered = FALSE;
+/*-------------------------------------------------
+ debugger_instruction_hook - CPU cores call
+ this once per instruction from CPU cores
+-------------------------------------------------*/
+
+void debugger_instruction_hook(device_t *device, offs_t curpc)
+{
+#ifndef MAME_DEBUG_FAST
+ if ((device->machine().debug_flags & DEBUG_FLAG_CALL_HOOK) != 0)
+ device->debug()->instruction_hook(curpc);
+#endif
+}
+
+
+/*-------------------------------------------------
+ debugger_exception_hook - CPU cores call this
+ anytime an exception is generated
+-------------------------------------------------*/
+
+void debugger_exception_hook(device_t *device, int exception)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->exception_hook(exception);
+}
+
+/*-------------------------------------------------
+ debugger_start_cpu_hook - the CPU execution
+ system calls this hook before beginning
+ execution for the given CPU
+-------------------------------------------------*/
+
+void debugger_start_cpu_hook(device_t *device, const attotime &endtime)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->start_hook(endtime);
+}
+
+
+/*-------------------------------------------------
+ debugger_stop_cpu_hook - the CPU execution
+ system calls this hook when ending execution
+ for the given CPU
+-------------------------------------------------*/
+
+void debugger_stop_cpu_hook(device_t *device)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->stop_hook();
+}
+
+
+/*-------------------------------------------------
+ debugger_interrupt_hook - the CPU execution
+ system calls this hook when an interrupt is
+ acknowledged
+-------------------------------------------------*/
+
+void debugger_interrupt_hook(device_t *device, int irqline)
+{
+ if ((device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ device->debug()->interrupt_hook(irqline);
+}
+
+/*-------------------------------------------------
+ debug_break - stop in the debugger at the next
+ opportunity
+-------------------------------------------------*/
+
+void debugger_manager::debug_break()
+{
+ if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ m_cpu->get_visible_cpu()->debug()->halt_on_next_instruction("Internal breakpoint\n");
+}
+
+
+/*-------------------------------------------------
+ within_instruction_hook - call this to
+ determine if the debugger is currently halted
+ within the instruction hook
+-------------------------------------------------*/
+
+bool debugger_manager::within_instruction_hook()
+{
+ if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
+ return m_cpu->within_instruction_hook();
+ return false;
+}
+
+
//**************************************************************************
// DEBUGGER MANAGER
//**************************************************************************
@@ -35,8 +124,9 @@ debugger_manager::debugger_manager(running_machine &machine)
: m_machine(machine)
{
/* initialize the submodules */
- debug_cpu_init(machine);
- debug_command_init(machine);
+ m_cpu = std::make_unique<debugger_cpu>(machine);
+ m_console = std::make_unique<debugger_console>(machine);
+ m_commands = std::make_unique<debugger_commands>(machine, cpu(), console());
g_machine = &machine;
@@ -45,9 +135,6 @@ debugger_manager::debugger_manager(running_machine &machine)
atexit(debugger_flush_all_traces_on_abnormal_exit);
g_atexit_registered = TRUE;
- /* listen in on the errorlog */
- machine.add_logerror_callback(debug_errorlog_write_line);
-
/* initialize osd debugger features */
machine.osd().init_debugger();
}
@@ -61,15 +148,6 @@ debugger_manager::~debugger_manager()
g_machine = nullptr;
}
-void debugger_manager::initialize()
-{
- /* only if debugging is enabled */
- if (machine().debug_flags & DEBUG_FLAG_ENABLED)
- {
- debug_console_init(machine());
- }
-}
-
/*-------------------------------------------------
refresh_display - redraw the current
video display
@@ -89,8 +167,8 @@ void debugger_manager::refresh_display()
void debugger_flush_all_traces_on_abnormal_exit(void)
{
- if(g_machine!=nullptr)
+ if(g_machine != nullptr)
{
- debug_cpu_flush_traces(*g_machine);
+ g_machine->debugger().cpu().flush_traces();
}
}