diff options
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 37 | ||||
-rw-r--r-- | src/emu/debug/debugcmd.h | 1 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 4 | ||||
-rw-r--r-- | src/emu/debug/debughlp.cpp | 17 | ||||
-rw-r--r-- | src/emu/debug/express.cpp | 19 | ||||
-rw-r--r-- | src/emu/debug/express.h | 6 | ||||
-rw-r--r-- | src/emu/distate.h | 1 |
7 files changed, 72 insertions, 13 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 871dda1df22..cc6738ee9f6 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -136,6 +136,7 @@ debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu m_console.register_command("printf", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_printf, this, _1, _2, _3)); m_console.register_command("logerror", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_logerror, this, _1, _2, _3)); m_console.register_command("tracelog", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_tracelog, this, _1, _2, _3)); + m_console.register_command("tracesym", CMDFLAG_NONE, 0, 1, MAX_COMMAND_PARAMS, std::bind(&debugger_commands::execute_tracesym, this, _1, _2, _3)); m_console.register_command("quit", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_quit, this, _1, _2, _3)); m_console.register_command("exit", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_commands::execute_quit, this, _1, _2, _3)); m_console.register_command("do", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_commands::execute_do, this, _1, _2, _3)); @@ -725,6 +726,42 @@ void debugger_commands::execute_tracelog(int ref, int params, const char *param[ /*------------------------------------------------- + execute_tracesym - execute the tracesym command +-------------------------------------------------*/ + +void debugger_commands::execute_tracesym(int ref, int params, const char *param[]) +{ + // build a format string appropriate for the parameters and validate them + std::stringstream format; + u64 values[MAX_COMMAND_PARAMS]; + for (int i = 0; i < params; i++) + { + // find this symbol + symbol_entry *sym = m_cpu.get_visible_symtable()->find(param[i]); + if (!sym) + { + m_console.printf("Unknown symbol: %s\n", param[i]); + return; + } + + // build the format string + util::stream_format(format, "%s=%s ", + param[i], + sym->format().empty() ? "%16X" : sym->format()); + + // validate the parameter + if (!validate_number_parameter(param[i], &values[i])) + return; + } + + // then do a printf + char buffer[1024]; + if (mini_printf(buffer, format.str().c_str(), params, values)) + m_cpu.get_visible_cpu()->debug()->trace_printf("%s", buffer); +} + + +/*------------------------------------------------- execute_quit - execute the quit command -------------------------------------------------*/ diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index ac57622abd5..02e8ceb5299 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -98,6 +98,7 @@ private: void execute_printf(int ref, int params, const char **param); void execute_logerror(int ref, int params, const char **param); void execute_tracelog(int ref, int params, const char **param); + void execute_tracesym(int ref, int params, const char **param); void execute_quit(int ref, int params, const char **param); void execute_do(int ref, int params, const char **param); void execute_step(int ref, int params, const char **param); diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 85c0b32dd73..178f4cf7f32 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1668,10 +1668,10 @@ device_debug::device_debug(device_t &device) // add all registers into it std::string tempstr; - for (auto &entry : m_state->state_entries()) + for (const auto &entry : m_state->state_entries()) { strmakelower(tempstr.assign(entry->symbol())); - m_symtable.add(tempstr.c_str(), (void *)(uintptr_t)entry->index(), get_state, set_state); + m_symtable.add(tempstr.c_str(), (void *)(uintptr_t)entry->index(), get_state, set_state, entry->format_string()); } } diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index 5c3fb605969..dd46472abb2 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -86,6 +86,7 @@ static const help_item static_help_list[] = " printf <format>[,<item>[,...]] -- prints one or more <item>s to the console using <format>\n" " logerror <format>[,<item>[,...]] -- outputs one or more <item>s to the error.log\n" " tracelog <format>[,<item>[,...]] -- outputs one or more <item>s to the trace file using <format>\n" + " tracesym <item>[,...]] -- outputs one or more <item>s to the trace file\n" " history [<cpu>,<length>] -- outputs a brief history of visited opcodes\n" " trackpc [<bool>,<cpu>,<bool>] -- visually track visited opcodes [boolean to turn on and off, for the given cpu, clear]\n" " trackmem [<bool>,<bool>] -- record which PC writes to each memory address [boolean to turn on and off, clear]\n" @@ -385,6 +386,22 @@ static const help_item static_help_list[] = " Outputs A=<aval>, B=<bval> on one line, and C=<a+bval> on a second line.\n" }, { + "tracesym", + "\n" + " tracesym <item>[,...]\n" + "\n" + "The tracesym command prints the specified symbols and routes the output to the currently open trace " + "file (see the 'trace' command for details). If no file is currently open, tracesym does nothing. " + "\n" + "Examples:\n" + "\n" + "tracelog pc\n" + " Outputs PC=<pcval> where <pcval> is displayed in the default format.\n" + "\n" + "printf a,b\n" + " Outputs A=<aval>, B=<bval> on one line.\n" + }, + { "trackpc", "\n" " trackpc [<bool>,<cpu>,<bool>]\n" diff --git a/src/emu/debug/express.cpp b/src/emu/debug/express.cpp index a9f9e38816f..0aa123f1d11 100644 --- a/src/emu/debug/express.cpp +++ b/src/emu/debug/express.cpp @@ -114,7 +114,7 @@ public: // construction/destruction integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, u64 *ptr = nullptr); integer_symbol_entry(symbol_table &table, const char *name, u64 constval); - integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter); + integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter, const std::string &format); // symbol access virtual bool is_lval() const override; @@ -203,11 +203,12 @@ const char *expression_error::code_string() const // symbol_entry - constructor //------------------------------------------------- -symbol_entry::symbol_entry(symbol_table &table, symbol_type type, const char *name, void *ref) +symbol_entry::symbol_entry(symbol_table &table, symbol_type type, const char *name, const std::string &format, void *ref) : m_next(nullptr), m_table(table), m_type(type), m_name(name), + m_format(format), m_ref(ref) { } @@ -232,7 +233,7 @@ symbol_entry::~symbol_entry() //------------------------------------------------- integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, symbol_table::read_write rw, u64 *ptr) - : symbol_entry(table, SMT_INTEGER, name, (ptr == nullptr) ? &m_value : ptr), + : symbol_entry(table, SMT_INTEGER, name, "", (ptr == nullptr) ? &m_value : ptr), m_getter(internal_getter), m_setter((rw == symbol_table::READ_ONLY) ? nullptr : internal_setter), m_value(0) @@ -241,7 +242,7 @@ integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, u64 constval) - : symbol_entry(table, SMT_INTEGER, name, &m_value), + : symbol_entry(table, SMT_INTEGER, name, "", &m_value), m_getter(internal_getter), m_setter(nullptr), m_value(constval) @@ -249,8 +250,8 @@ integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name } -integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter) - : symbol_entry(table, SMT_INTEGER, name, ref), +integer_symbol_entry::integer_symbol_entry(symbol_table &table, const char *name, void *ref, symbol_table::getter_func getter, symbol_table::setter_func setter, const std::string &format) + : symbol_entry(table, SMT_INTEGER, name, format, ref), m_getter(getter), m_setter(setter), m_value(0) @@ -323,7 +324,7 @@ void integer_symbol_entry::internal_setter(symbol_table &table, void *symref, u6 //------------------------------------------------- function_symbol_entry::function_symbol_entry(symbol_table &table, const char *name, void *ref, int minparams, int maxparams, symbol_table::execute_func execute) - : symbol_entry(table, SMT_FUNCTION, name, ref), + : symbol_entry(table, SMT_FUNCTION, name, "", ref), m_minparams(minparams), m_maxparams(maxparams), m_execute(execute) @@ -434,10 +435,10 @@ void symbol_table::add(const char *name, u64 value) // add - add a new register symbol //------------------------------------------------- -void symbol_table::add(const char *name, void *ref, getter_func getter, setter_func setter) +void symbol_table::add(const char *name, void *ref, getter_func getter, setter_func setter, const std::string &format_string) { m_symlist.erase(name); - m_symlist.emplace(name, std::make_unique<integer_symbol_entry>(*this, name, ref, getter, setter)); + m_symlist.emplace(name, std::make_unique<integer_symbol_entry>(*this, name, ref, getter, setter, format_string)); } diff --git a/src/emu/debug/express.h b/src/emu/debug/express.h index b9ddde14501..2627d198115 100644 --- a/src/emu/debug/express.h +++ b/src/emu/debug/express.h @@ -116,13 +116,14 @@ protected: }; // construction/destruction - symbol_entry(symbol_table &table, symbol_type type, const char *name, void *ref); + symbol_entry(symbol_table &table, symbol_type type, const char *name, const std::string &format, void *ref); public: virtual ~symbol_entry(); // getters symbol_entry *next() const { return m_next; } const char *name() const { return m_name.c_str(); } + const std::string &format() const { return m_format; } // type checking bool is_function() const { return (m_type == SMT_FUNCTION); } @@ -138,6 +139,7 @@ protected: symbol_table & m_table; // pointer back to the owning table symbol_type m_type; // type of symbol std::string m_name; // name of the symbol + std::string m_format; // format of symbol (or empty if unspecified) void * m_ref; // internal reference }; @@ -181,7 +183,7 @@ public: // symbol access void add(const char *name, read_write rw, u64 *ptr = nullptr); void add(const char *name, u64 constvalue); - void add(const char *name, void *ref, getter_func getter, setter_func setter = nullptr); + void add(const char *name, void *ref, getter_func getter, setter_func setter = nullptr, const std::string &format_string = ""); void add(const char *name, void *ref, int minparams, int maxparams, execute_func execute); symbol_entry *find(const char *name) const { if (name) { auto search = m_symlist.find(name); if (search != m_symlist.end()) return search->second.get(); else return nullptr; } else return nullptr; } symbol_entry *find_deep(const char *name); diff --git a/src/emu/distate.h b/src/emu/distate.h index e10cdd1c16a..22db6cc22af 100644 --- a/src/emu/distate.h +++ b/src/emu/distate.h @@ -65,6 +65,7 @@ public: bool visible() const { return ((m_flags & DSF_NOSHOW) == 0); } bool divider() const { return m_flags & DSF_DIVIDER; } device_state_interface *parent_state() const {return m_device_state;} + const std::string &format_string() const { return m_format; } protected: // device state flags |