From 02684e8d7cb5292867ebcdea06879b94ba63aef4 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 28 Apr 2019 01:00:24 -0700 Subject: 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! --- browse_trace/browse_trace.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'browse_trace/browse_trace.cc') 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(1); - out << " (" << delta << ")"; + out << std::setw(6) << delta << "| "; if (delta > 999) out << static_cast(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 -- cgit 1.4.1-2-gfad0