Have each device create its own device_debug instead of letting the

debugger do it. This allows the device to start itself up before the
debugger tries to figure out what to do with it. Fixes the problem
where register names were not populated into the symbol table
correctly after I shuffled the initialization order.
This commit is contained in:
Aaron Giles 2010-09-04 19:47:54 +00:00
parent 53b7d019e2
commit 1359ea15b1
7 changed files with 24 additions and 19 deletions

View File

@ -91,17 +91,10 @@ static void debug_comment_exit(running_machine &machine);
loads any existing comment file 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 */ /* allocate memory for the comments */
device_disasm_interface *disasm; devdebug.m_comments = auto_alloc_clear(device.machine, debug_cpu_comment_group);
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);
return 1; return 1;
} }

View File

@ -18,7 +18,7 @@
#define DEBUG_COMMENT_MAX_NUM (0x10000) /* 64k comments should be good for awhile */ #define DEBUG_COMMENT_MAX_NUM (0x10000) /* 64k comments should be good for awhile */
/* init and exit */ /* init and exit */
int debug_comment_init(running_machine *machine); int debug_comment_init(device_t &device, device_debug &devdebug);
/* load and save */ /* load and save */
int debug_comment_save(running_machine *machine); int debug_comment_save(running_machine *machine);

View File

@ -96,6 +96,8 @@ struct _debugcpu_private
UINT64 tempvar[NUM_TEMP_VARIABLES]; UINT64 tempvar[NUM_TEMP_VARIABLES];
osd_ticks_t last_periodic_update_time; 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); 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 */ /* first CPU is visible by default */
global->visiblecpu = machine->firstcpu; global->visiblecpu = machine->firstcpu;
@ -1562,14 +1560,14 @@ static UINT64 get_cpunum(void *globalref, void *ref)
// device_debug - constructor // device_debug - constructor
//------------------------------------------------- //-------------------------------------------------
device_debug::device_debug(device_t &device, symbol_table *globalsyms) device_debug::device_debug(device_t &device)
: m_device(device), : m_device(device),
m_exec(NULL), m_exec(NULL),
m_memory(NULL), m_memory(NULL),
m_state(NULL), m_state(NULL),
m_disasm(NULL), m_disasm(NULL),
m_flags(0), 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_instrhook(NULL),
m_dasm_override(NULL), m_dasm_override(NULL),
m_opwidth(0), 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) if (m_state != NULL && symtable_find(m_symtable, "curpc") == NULL)
symtable_add_register(m_symtable, "curpc", NULL, get_current_pc, 0); symtable_add_register(m_symtable, "curpc", NULL, get_current_pc, 0);
} }
// initialize coments
if (m_disasm != NULL)
debug_comment_init(device, *this);
} }
@ -1844,6 +1846,13 @@ void device_debug::instruction_hook(offs_t curpc)
{ {
int firststop = true; 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 any transient state
reset_transient_flags(*m_device.machine); reset_transient_flags(*m_device.machine);
global->breakcpu = NULL; global->breakcpu = NULL;

View File

@ -138,7 +138,7 @@ public:
public: public:
// construction/destruction // construction/destruction
device_debug(device_t &device, symbol_table *globalsyms); device_debug(device_t &device);
~device_debug(); ~device_debug();
// getters // getters

View File

@ -72,7 +72,6 @@ void debugger_init(running_machine *machine)
debug_cpu_init(machine); debug_cpu_init(machine);
debug_command_init(machine); debug_command_init(machine);
debug_console_init(machine); debug_console_init(machine);
debug_comment_init(machine);
/* always initialize the internal render debugger */ /* always initialize the internal render debugger */
debugint_init(machine); debugint_init(machine);

View File

@ -38,6 +38,7 @@
***************************************************************************/ ***************************************************************************/
#include "emu.h" #include "emu.h"
#include "debug/debugcpu.h"
@ -727,6 +728,10 @@ void device_t::start()
// force an update of the clock // force an update of the clock
notify_clock_changed(); 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 // register our save states
state_save_register_device_item(this, 0, m_clock); state_save_register_device_item(this, 0, m_clock);
state_save_register_device_item(this, 0, m_unscaled_clock); state_save_register_device_item(this, 0, m_unscaled_clock);

View File

@ -387,7 +387,6 @@ public:
// debugging // debugging
device_debug *debug() const { return m_debug; } device_debug *debug() const { return m_debug; }
void set_debug(device_debug &debug) { m_debug = &debug; }
// basic information getters ... pass through to underlying config // basic information getters ... pass through to underlying config
device_type type() const { return m_baseconfig.type(); } device_type type() const { return m_baseconfig.type(); }