From 12111c21d0df5aefaaf605c9d58470288a7b0fdf Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 8 Nov 2010 08:58:41 +0000 Subject: Fix issues with setting condition expressions on break/watchpoints. --- src/emu/debug/debugcmd.c | 20 ++++++++++---------- src/emu/debug/express.c | 35 ++++++++++++++++++++--------------- src/emu/debug/express.h | 1 + 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c index ec9f9afe344..75cf528cd18 100644 --- a/src/emu/debug/debugcmd.c +++ b/src/emu/debug/debugcmd.c @@ -1163,17 +1163,21 @@ static void execute_comment_save(running_machine *machine, int ref, int params, static void execute_bpset(running_machine *machine, int ref, int params, const char *param[]) { - parsed_expression condition(debug_cpu_get_global_symtable(machine)); device_t *cpu; const char *action = NULL; UINT64 address; int bpnum; + /* CPU is implicit */ + if (!debug_command_parameter_cpu(machine, NULL, &cpu)) + return; + /* param 1 is the address */ if (!debug_command_parameter_number(machine, param[0], &address)) return; /* param 2 is the condition */ + parsed_expression condition(&cpu->debug()->symtable()); if (!debug_command_parameter_expression(machine, param[1], condition)) return; @@ -1181,10 +1185,6 @@ static void execute_bpset(running_machine *machine, int ref, int params, const c if (!debug_command_parameter_command(machine, action = param[2])) return; - /* CPU is implicit */ - if (!debug_command_parameter_cpu(machine, NULL, &cpu)) - return; - /* set the breakpoint */ bpnum = cpu->debug()->breakpoint_set(address, (condition.is_empty()) ? NULL : condition.original_string(), action); debug_console_printf(machine, "Breakpoint %X set\n", bpnum); @@ -1303,13 +1303,16 @@ static void execute_bplist(running_machine *machine, int ref, int params, const static void execute_wpset(running_machine *machine, int ref, int params, const char *param[]) { - parsed_expression condition(debug_cpu_get_global_symtable(machine)); address_space *space; const char *action = NULL; UINT64 address, length; int type = 0; int wpnum; + /* CPU is implicit */ + if (!debug_command_parameter_cpu_space(machine, NULL, ref, &space)) + return; + /* param 1 is the address */ if (!debug_command_parameter_number(machine, param[0], &address)) return; @@ -1332,6 +1335,7 @@ static void execute_wpset(running_machine *machine, int ref, int params, const c } /* param 4 is the condition */ + parsed_expression condition(&space->cpu->debug()->symtable()); if (!debug_command_parameter_expression(machine, param[3], condition)) return; @@ -1339,10 +1343,6 @@ static void execute_wpset(running_machine *machine, int ref, int params, const c if (!debug_command_parameter_command(machine, action = param[4])) return; - /* CPU is implicit */ - if (!debug_command_parameter_cpu_space(machine, NULL, ref, &space)) - return; - /* set the watchpoint */ wpnum = space->cpu->debug()->watchpoint_set(*space, type, address, length, (condition.is_empty()) ? NULL : condition.original_string(), action); debug_console_printf(machine, "Watchpoint %X set\n", wpnum); diff --git a/src/emu/debug/express.c b/src/emu/debug/express.c index 9690570c481..853f6adfa92 100644 --- a/src/emu/debug/express.c +++ b/src/emu/debug/express.c @@ -482,19 +482,31 @@ void symbol_table::add(const char *name, void *ref, int minparams, int maxparams //------------------------------------------------- -// value - return the value of a symbol +// find_deep - do a deep search for a symbol, +// looking in the parent if needed //------------------------------------------------- -UINT64 symbol_table::value(const char *symbol) +symbol_entry *symbol_table::find_deep(const char *symbol) { // walk up the table hierarchy to find the owner for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) { symbol_entry *entry = symtable->find(symbol); if (entry != NULL) - return entry->value(); + return entry; } - return 0; + return NULL; +} + + +//------------------------------------------------- +// value - return the value of a symbol +//------------------------------------------------- + +UINT64 symbol_table::value(const char *symbol) +{ + symbol_entry *entry = find_deep(symbol); + return (entry != NULL) ? entry->value() : 0; } @@ -504,16 +516,9 @@ UINT64 symbol_table::value(const char *symbol) void symbol_table::set_value(const char *symbol, UINT64 value) { - // walk up the table hierarchy to find the owner - for (symbol_table *symtable = this; symtable != NULL; symtable = symtable->m_parent) - { - symbol_entry *entry = symtable->find(symbol); - if (entry != NULL) - { - entry->set_value(value); - return; - } - } + symbol_entry *entry = find_deep(symbol); + if (entry != NULL) + entry->set_value(value); } @@ -961,7 +966,7 @@ void parsed_expression::parse_symbol_or_number(parse_token &token, const char *& return parse_number(token, &buffer[1], 16, expression_error::INVALID_NUMBER); // check for a symbol match - symbol_entry *symbol = m_symtable->find(buffer); + symbol_entry *symbol = m_symtable->find_deep(buffer); if (symbol != NULL) { token.configure_symbol(*symbol); diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index 5d0af33b3ca..8a5282ff855 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -211,6 +211,7 @@ public: void add(const char *name, void *ref, getter_func getter, setter_func setter = NULL); void add(const char *name, void *ref, int minparams, int maxparams, execute_func execute); symbol_entry *find(const char *name) { return m_symlist.find(name); } + symbol_entry *find_deep(const char *name); // value getter/setter UINT64 value(const char *symbol); -- cgit v1.2.3