summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/textbuf.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/textbuf.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/textbuf.cpp')
-rw-r--r--src/emu/debug/textbuf.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/emu/debug/textbuf.cpp b/src/emu/debug/textbuf.cpp
index fea5ed31c9c..dd30beec210 100644
--- a/src/emu/debug/textbuf.cpp
+++ b/src/emu/debug/textbuf.cpp
@@ -311,3 +311,66 @@ const char *text_buffer_get_seqnum_line(text_buffer *text, u32 seqnum)
return nullptr;
return &text->buffer[text->lineoffs[(text->linestart + index) % text->linesize]];
}
+
+text_buffer_lines text_buffer_get_lines(text_buffer* text)
+{
+ return text_buffer_lines(*text);
+}
+
+/*---------------------------------------------------------------------
+ text_buffer_lines::text_buffer_line_iterator::operator*
+ Gets the line that the iterator currently points to.
+-----------------------------------------------------------------------*/
+
+text_buffer_line text_buffer_lines::text_buffer_line_iterator::operator*() const
+{
+ const char* line = &m_buffer.buffer[m_buffer.lineoffs[m_lineptr]];
+
+ auto next_lineptr = m_lineptr + 1;
+ if (next_lineptr == m_buffer.linesize)
+ next_lineptr = 0;
+
+ const char* nextline = &m_buffer.buffer[m_buffer.lineoffs[next_lineptr]];
+
+ /* -1 for the '\0' at the end of line */
+
+ ptrdiff_t difference = (nextline - line) - 1;
+
+ if (difference < 0)
+ difference += m_buffer.bufsize;
+
+ return text_buffer_line{ line, (size_t)difference };
+}
+
+/*---------------------------------------------------------------------
+ text_buffer_lines::text_buffer_line_iterator::operator++
+ Moves to the next line.
+-----------------------------------------------------------------------*/
+
+text_buffer_lines::text_buffer_line_iterator& text_buffer_lines::text_buffer_line_iterator::operator++()
+{
+ if (++m_lineptr == m_buffer.linesize)
+ m_lineptr = 0;
+
+ return *this;
+}
+
+/*------------------------------------------------------
+ text_buffer_lines::begin()
+ Returns an iterator that points to the first line.
+--------------------------------------------------------*/
+
+text_buffer_lines::iterator text_buffer_lines::begin() const
+{
+ return text_buffer_line_iterator(m_buffer, m_buffer.linestart);
+}
+
+/*-----------------------------------------------------------
+ text_buffer_lines::begin()
+ Returns an iterator that points just past the last line.
+-------------------------------------------------------------*/
+
+text_buffer_lines::iterator text_buffer_lines::end() const
+{
+ return text_buffer_line_iterator(m_buffer, m_buffer.lineend);
+}