diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 24 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 22 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.h | 7 | ||||
-rw-r--r-- | src/emu/debug/debughlp.cpp | 19 |
4 files changed, 58 insertions, 14 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 5469670caa6..871dda1df22 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -2496,6 +2496,7 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char * { const char *action = nullptr; bool detect_loops = true; + bool logerror = false; device_t *cpu; FILE *f = nullptr; const char *mode; @@ -2507,8 +2508,25 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char * /* validate parameters */ if (!validate_cpu_parameter((params > 1) ? param[1] : nullptr, &cpu)) return; - if (!validate_boolean_parameter((params > 2) ? param[2] : nullptr, &detect_loops)) - return; + if (params > 2) + { + std::stringstream stream; + stream.str(param[2]); + + std::string flag; + while (std::getline(stream, flag, '|')) + { + if (!core_stricmp(flag.c_str(), "noloop")) + detect_loops = false; + else if (!core_stricmp(flag.c_str(), "logerror")) + logerror = true; + else + { + m_console.printf("Invalid flag '%s'\n", flag.c_str()); + return; + } + } + } if (!debug_command_parameter_command(action = (params > 3) ? param[3] : nullptr)) return; @@ -2533,7 +2551,7 @@ void debugger_commands::execute_trace_internal(int ref, int params, const char * } /* do it */ - cpu->debug()->trace(f, trace_over, detect_loops, action); + cpu->debug()->trace(f, trace_over, detect_loops, logerror, action); if (f) m_console.printf("Tracing CPU '%s' to file %s\n", cpu->tag(), filename.c_str()); else diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 98fa6c9f038..85c0b32dd73 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1684,6 +1684,10 @@ device_debug::device_debug(device_t &device) if (m_state != nullptr && m_symtable.find("curpc") == nullptr) m_symtable.add("curpc", nullptr, get_current_pc); } + + // set up trace + using namespace std::placeholders; + m_device.machine().add_logerror_callback(std::bind(&device_debug::errorlog_write_line, this, _1)); } @@ -2623,14 +2627,14 @@ u32 device_debug::compute_opcode_crc32(offs_t pc) const // trace - trace execution of a given device //------------------------------------------------- -void device_debug::trace(FILE *file, bool trace_over, bool detect_loops, const char *action) +void device_debug::trace(FILE *file, bool trace_over, bool detect_loops, bool logerror, const char *action) { // delete any existing tracers m_trace = nullptr; // if we have a new file, make a new tracer if (file != nullptr) - m_trace = std::make_unique<tracer>(*this, *file, trace_over, detect_loops, action); + m_trace = std::make_unique<tracer>(*this, *file, trace_over, detect_loops, logerror, action); } @@ -3291,11 +3295,12 @@ bool device_debug::registerpoint::hit() // tracer - constructor //------------------------------------------------- -device_debug::tracer::tracer(device_debug &debug, FILE &file, bool trace_over, bool detect_loops, const char *action) +device_debug::tracer::tracer(device_debug &debug, FILE &file, bool trace_over, bool detect_loops, bool logerror, const char *action) : m_debug(debug) , m_file(file) , m_action((action != nullptr) ? action : "") , m_detect_loops(detect_loops) + , m_logerror(logerror) , m_loops(0) , m_nextdex(0) , m_trace_over(trace_over) @@ -3447,3 +3452,14 @@ device_debug::dasm_comment::dasm_comment(offs_t address, u32 crc, const char *te m_color(std::move(color)) { } + + +//------------------------------------------------- +// dasm_comment - constructor +//------------------------------------------------- + +void device_debug::errorlog_write_line(const char *line) +{ + if (m_trace && m_trace->logerror()) + trace_printf("%s", line); +}
\ No newline at end of file diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index c01cc0e0646..383940c21cb 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -263,7 +263,7 @@ public: void track_mem_data_clear() { m_track_mem_set.clear(); } // tracing - void trace(FILE *file, bool trace_over, bool detect_loops, const char *action); + void trace(FILE *file, bool trace_over, bool detect_loops, bool logerror, const char *action); void trace_printf(const char *fmt, ...) ATTR_PRINTF(2,3); void trace_flush() { if (m_trace != nullptr) m_trace->flush(); } @@ -280,6 +280,7 @@ private: // internal helpers void prepare_for_step_overout(offs_t pc); u32 dasm_wrapped(std::string &buffer, offs_t pc); + void errorlog_write_line(const char *line); // breakpoint and watchpoint helpers void breakpoint_update_flags(); @@ -336,12 +337,13 @@ private: class tracer { public: - tracer(device_debug &debug, FILE &file, bool trace_over, bool detect_loops, const char *action); + tracer(device_debug &debug, FILE &file, bool trace_over, bool detect_loops, bool logerror, const char *action); ~tracer(); void update(offs_t pc); void vprintf(const char *format, va_list va); void flush(); + bool logerror() const { return m_logerror; } private: static const int TRACE_LOOPS = 64; @@ -351,6 +353,7 @@ private: std::string m_action; // action to perform during a trace offs_t m_history[TRACE_LOOPS]; // history of recent PCs bool m_detect_loops; // whether or not we should detect loops + bool m_logerror; // whether or not we should collect logerror output int m_loops; // number of instructions in a loop int m_nextdex; // next index bool m_trace_over; // true if we're tracing over diff --git a/src/emu/debug/debughlp.cpp b/src/emu/debug/debughlp.cpp index ded8cafb993..5c3fb605969 100644 --- a/src/emu/debug/debughlp.cpp +++ b/src/emu/debug/debughlp.cpp @@ -818,14 +818,15 @@ static const help_item static_help_list[] = { "trace", "\n" - " trace {<filename>|OFF}[,<cpu>[,<detectloops>[,<action>]]]\n" + " trace {<filename>|OFF}[,<cpu>[,[noloop|logerror][,<action>]]]\n" "\n" "Starts or stops tracing of the execution of the specified <cpu>. If <cpu> is omitted, " "the currently active CPU is specified. When enabling tracing, specify the filename in the " "<filename> parameter. To disable tracing, substitute the keyword 'off' for <filename>. " - "<detectloops> should be either true or false. If <detectloops> is true or omitted, the trace " - "will have loops detected and condensed to a single line. If it is false, the trace will contain " - "every opcode as it is executed. If you " + "<detectloops> should be either true or false. If 'noloop' is omitted, the trace " + "will have loops detected and condensed to a single line. If 'noloop' is specified, the trace " + "will contain every opcode as it is executed. If 'logerror' is specified, logerror output " + "will augment the trace. If you " "wish to log additional information on each trace, you can append an <action> parameter which " "is a command that is executed before each trace is logged. Generally, this is used to include " "a 'tracelog' command. Note that you may need to embed the action within braces { } in order " @@ -840,16 +841,22 @@ static const help_item static_help_list[] = "trace dribling.tr,0\n" " Begin tracing the execution of CPU #0, logging output to dribling.tr.\n" "\n" - "trace starswep.tr,0,false\n" + "trace starswep.tr,0,noloop\n" " Begin tracing the execution of CPU #0, logging output to starswep.tr, with loop detection disabled.\n" "\n" + "trace starswep.tr,0,logerror\n" + " Begin tracing the execution of CPU #0, logging output (along with logerror output) to starswep.tr.\n" + "\n" + "trace starswep.tr,0,logerror|noloop\n" + " Begin tracing the execution of CPU #0, logging output (along with logerror output) to starswep.tr, with loop detection disabled.\n" + "\n" "trace >>pigskin.tr\n" " Begin tracing the currently active CPU, appending log output to pigskin.tr.\n" "\n" "trace off,0\n" " Turn off tracing on CPU #0.\n" "\n" - "trace asteroid.tr,0,true,{tracelog \"A=%02X \",a}\n" + "trace asteroid.tr,0,,{tracelog \"A=%02X \",a}\n" " Begin tracing the execution of CPU #0, logging output to asteroid.tr. Before each line, " "output A=<aval> to the tracelog.\n" }, |