about summary refs log tree commit diff stats
path: root/browse_trace
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-04-28 01:00:24 -0700
committerKartik Agaram <vc@akkartik.com>2019-04-28 01:10:17 -0700
commit02684e8d7cb5292867ebcdea06879b94ba63aef4 (patch)
treefcd9005dea315966f9f611b9739f1d6e44b1f694 /browse_trace
parentffe66972277c856f33e349b3d1fd1b2a6b5bfa2a (diff)
downloadmu-02684e8d7cb5292867ebcdea06879b94ba63aef4.tar.gz
5133 - show instruction source in trace
It's a little hacky in some corner cases. In particular, if debug information
isn't available the trace will contain duplicated lines. This is because
I don't want the core trace lines all my tests rely on (introduced in the
'vm' layer) to have to know about debug info (introduced in the 'labels'
and 'debug' layers).

Thanks Charles Saternos for the feedback and suggestion!
Diffstat (limited to 'browse_trace')
-rw-r--r--browse_trace/browse_trace.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/browse_trace/browse_trace.cc b/browse_trace/browse_trace.cc
index cc03f5ce..abfd6daa 100644
--- a/browse_trace/browse_trace.cc
+++ b/browse_trace/browse_trace.cc
@@ -429,16 +429,22 @@ void render() {
     if (!contains_key(Trace_index, screen_row)) break;
     trace_line& curr_line = Trace_stream->past_lines.at(get(Trace_index, screen_row));
     ostringstream out;
-    out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents;
     if (screen_row < tb_height()-1) {
       int delta = lines_hidden(screen_row);
       // home-brew escape sequence for red
       if (delta > 1) {
         if (delta > 999) out << static_cast<char>(1);
-        out << " (" << delta << ")";
+        out << std::setw(6) << delta << "| ";
         if (delta > 999) out << static_cast<char>(2);
       }
+      else {
+        out << "        ";
+      }
     }
+    else {
+      out << "        ";
+    }
+    out << std::setw(4) << curr_line.depth << ' ' << curr_line.label << ": " << curr_line.contents;
     render_line(screen_row, out.str(), screen_row == Display_row);
   }
   // clear rest of screen
@@ -467,8 +473,8 @@ void render_line(int screen_row, const string& s, bool cursor_line) {
     char c = s.at(col+Left_of_screen);  // todo: unicode
     if (c == '\n') c = ';';  // replace newlines with semi-colons
     // escapes. hack: can't start a line with them.
-    if (c == '\1') { color = /*red*/1;  c = ' '; }
-    if (c == '\2') { color = TB_WHITE;  c = ' '; }
+    if (c == '\1') { color = /*red*/1;  continue; }
+    if (c == '\2') { color = TB_WHITE;  continue; }
     if (in_range(highlight_ranges, col+Left_of_screen))
       tb_print(c, TB_BLACK, /*yellow*/11);
     else