summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/debugcon.cpp
diff options
context:
space:
mode:
author Stevie-O <stevie@qrpff.net>2020-06-06 11:31:33 -0400
committer GitHub <noreply@github.com>2020-06-07 01:31:33 +1000
commit8b021e8bf3aa30abd9e9d2d88d2d00a935bc9a4a (patch)
treec90a08efb5bc4d8204e3b72eca08a9fec8162e80 /src/emu/debug/debugcon.cpp
parentfe2802711c29b37272c2e05a1c61ba04ffbf1435 (diff)
Debugger: add `condump` command to export console buffer to a log file (#6781)
This is another debugger enhancement -- it allows you to export the current contents of the debug console window to a file. The filename parsing is based on the `trace` command, and as such, supports both the "{game}" placeholder, and the ">>" prefix for appending instead of overwriting.
Diffstat (limited to 'src/emu/debug/debugcon.cpp')
-rw-r--r--src/emu/debug/debugcon.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/emu/debug/debugcon.cpp b/src/emu/debug/debugcon.cpp
index 692c7945445..0b4ae76c95b 100644
--- a/src/emu/debug/debugcon.cpp
+++ b/src/emu/debug/debugcon.cpp
@@ -65,6 +65,7 @@ debugger_console::debugger_console(running_machine &machine)
/* register our own custom-command help */
register_command("helpcustom", CMDFLAG_NONE, 0, 0, 0, std::bind(&debugger_console::execute_help_custom, this, _1, _2));
+ register_command("condump", CMDFLAG_NONE, 0, 1, 1, std::bind(&debugger_console::execute_condump, this, _1, _2));
/* first CPU is visible by default */
for (device_t &device : device_iterator(m_machine.root_device()))
@@ -139,6 +140,42 @@ void debugger_console::execute_help_custom(int ref, const std::vector<std::strin
}
}
+/*------------------------------------------------------------
+ execute_condump - execute the condump command
+------------------------------------------------------------*/
+
+void debugger_console::execute_condump(int ref, const std::vector<std::string>& params)
+{
+ std::string filename = params[0];
+ const char* mode;
+
+ /* replace macros */
+ strreplace(filename, "{game}", m_machine.basename());
+
+ mode = "w";
+ /* opening for append? */
+ if ((filename[0] == '>') && (filename[1] == '>'))
+ {
+ mode = "a";
+ filename = filename.substr(2);
+ }
+
+ FILE* f = fopen(filename.c_str(), mode);
+ if (!f)
+ {
+ printf("Error opening file '%s'\n", filename.c_str());
+ return;
+ }
+
+ for (auto line_info : text_buffer_get_lines(m_console_textbuf))
+ {
+ fwrite(line_info.text, sizeof(char), line_info.length, f);
+ fputc('\n', f);
+ }
+
+ fclose(f);
+ printf("Wrote console contents to '%s'\n", filename.c_str());
+}
//-------------------------------------------------
// visible_symtable - return the locally-visible