diff --git a/src/emu/debug/debugcmt.c b/src/emu/debug/debugcmt.c index 3b9c1a3ef46..c957cf64361 100644 --- a/src/emu/debug/debugcmt.c +++ b/src/emu/debug/debugcmt.c @@ -91,17 +91,10 @@ static void debug_comment_exit(running_machine &machine); loads any existing comment file -------------------------------------------------------------------------*/ -int debug_comment_init(running_machine *machine) +int debug_comment_init(device_t &device, device_debug &devdebug) { /* allocate memory for the comments */ - device_disasm_interface *disasm; - for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) - if (device->interface(disasm)) - device->debug()->m_comments = auto_alloc_clear(machine, debug_cpu_comment_group); - - /* automatically load em up */ - debug_comment_load(machine); - machine->add_notifier(MACHINE_NOTIFY_EXIT, debug_comment_exit); + devdebug.m_comments = auto_alloc_clear(device.machine, debug_cpu_comment_group); return 1; } diff --git a/src/emu/debug/debugcmt.h b/src/emu/debug/debugcmt.h index 1e3e63e1ae0..1214fbb4be4 100644 --- a/src/emu/debug/debugcmt.h +++ b/src/emu/debug/debugcmt.h @@ -18,7 +18,7 @@ #define DEBUG_COMMENT_MAX_NUM (0x10000) /* 64k comments should be good for awhile */ /* init and exit */ -int debug_comment_init(running_machine *machine); +int debug_comment_init(device_t &device, device_debug &devdebug); /* load and save */ int debug_comment_save(running_machine *machine); diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index 9b8b658f8f2..8f413f7ae03 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -96,6 +96,8 @@ struct _debugcpu_private UINT64 tempvar[NUM_TEMP_VARIABLES]; osd_ticks_t last_periodic_update_time; + + bool comments_loaded; }; @@ -184,10 +186,6 @@ void debug_cpu_init(running_machine *machine) symtable_add_register(global->symtable, symname, &global->tempvar[regnum], get_tempvar, set_tempvar); } - /* loop over devices and build up their info */ - for (device_t *device = machine->m_devicelist.first(); device != NULL; device = device->next()) - device->set_debug(*auto_alloc(machine, device_debug(*device, global->symtable))); - /* first CPU is visible by default */ global->visiblecpu = machine->firstcpu; @@ -1562,14 +1560,14 @@ static UINT64 get_cpunum(void *globalref, void *ref) // device_debug - constructor //------------------------------------------------- -device_debug::device_debug(device_t &device, symbol_table *globalsyms) +device_debug::device_debug(device_t &device) : m_device(device), m_exec(NULL), m_memory(NULL), m_state(NULL), m_disasm(NULL), m_flags(0), - m_symtable(symtable_alloc(globalsyms, (void *)&device)), + m_symtable(symtable_alloc(debug_cpu_get_global_symtable(device.machine), (void *)&device)), m_instrhook(NULL), m_dasm_override(NULL), m_opwidth(0), @@ -1631,6 +1629,10 @@ device_debug::device_debug(device_t &device, symbol_table *globalsyms) if (m_state != NULL && symtable_find(m_symtable, "curpc") == NULL) symtable_add_register(m_symtable, "curpc", NULL, get_current_pc, 0); } + + // initialize coments + if (m_disasm != NULL) + debug_comment_init(device, *this); } @@ -1843,6 +1845,13 @@ void device_debug::instruction_hook(offs_t curpc) if (global->execution_state == EXECUTION_STATE_STOPPED) { int firststop = true; + + // load comments if we haven't yet + if (!global->comments_loaded) + { + debug_comment_load(m_device.machine); + global->comments_loaded = true; + } // reset any transient state reset_transient_flags(*m_device.machine); diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 4598afbdde4..6bf2196b910 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -138,7 +138,7 @@ public: public: // construction/destruction - device_debug(device_t &device, symbol_table *globalsyms); + device_debug(device_t &device); ~device_debug(); // getters diff --git a/src/emu/debugger.c b/src/emu/debugger.c index f04f20c26aa..5e6c4d86d0e 100644 --- a/src/emu/debugger.c +++ b/src/emu/debugger.c @@ -72,7 +72,6 @@ void debugger_init(running_machine *machine) debug_cpu_init(machine); debug_command_init(machine); debug_console_init(machine); - debug_comment_init(machine); /* always initialize the internal render debugger */ debugint_init(machine); diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 557cf628426..8876c983ff3 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -38,6 +38,7 @@ ***************************************************************************/ #include "emu.h" +#include "debug/debugcpu.h" @@ -726,6 +727,10 @@ void device_t::start() // force an update of the clock notify_clock_changed(); + + // if we're debugging, create a device_debug object + if ((m_machine.debug_flags & DEBUG_FLAG_ENABLED) != 0) + m_debug = auto_alloc(&m_machine, device_debug(*this)); // register our save states state_save_register_device_item(this, 0, m_clock); diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 9ec09ea9186..fa9444051b8 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -387,7 +387,6 @@ public: // debugging device_debug *debug() const { return m_debug; } - void set_debug(device_debug &debug) { m_debug = &debug; } // basic information getters ... pass through to underlying config device_type type() const { return m_baseconfig.type(); }