about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--000organization.cc1
-rw-r--r--001help.cc3
-rw-r--r--090trace_browser.cc30
3 files changed, 34 insertions, 0 deletions
diff --git a/000organization.cc b/000organization.cc
index 61c60b63..0f2518f5 100644
--- a/000organization.cc
+++ b/000organization.cc
@@ -105,6 +105,7 @@ int main(int argc, char* argv[]) {
 
   // End One-time Setup
 
+  // Commandline Parsing
   // End Commandline Parsing
 
   return 0;  // End Main
diff --git a/001help.cc b/001help.cc
index 4b7c3858..b2ca4c46 100644
--- a/001help.cc
+++ b/001help.cc
@@ -16,6 +16,9 @@ if (argc <= 1 || is_equal(argv[1], "--help")) {
        << "You can test directories just like files.\n"
        << "To pass ingredients to a mu program, provide them after '--':\n"
        << "  mu file_or_dir1 file_or_dir2 ... -- ingredient1 ingredient2 ...\n"
+       << "\n"
+       << "To browse a trace generated by a previous run:\n"
+       << "  mu browse-trace file\n"
        ;
   return 0;
 }
diff --git a/090trace_browser.cc b/090trace_browser.cc
index 676be4f2..93cba272 100644
--- a/090trace_browser.cc
+++ b/090trace_browser.cc
@@ -1,3 +1,6 @@
+//: A debugging helper that lets you zoom in/out on a trace.
+
+//: browse the trace we just created
 :(before "End Primitive Recipe Declarations")
 _BROWSE_TRACE,
 :(before "End Primitive Recipe Numbers")
@@ -12,6 +15,14 @@ case _BROWSE_TRACE: {
   break;
 }
 
+//: browse a trace loaded from a file
+:(after "Commandline Parsing")
+if (argc == 3 && is_equal(argv[1], "browse-trace")) {
+  load_trace(argv[2]);
+  start_trace_browser();
+  return 0;
+}
+
 :(before "End Globals")
 set<long long int> Visible;
 long long int Top_of_screen = 0;
@@ -211,3 +222,22 @@ void render_line(int screen_row, const string& s) {
     tb_change_cell(col, screen_row, ' ', TB_WHITE, TB_BLACK);
   }
 }
+
+void load_trace(const char* filename) {
+  ifstream tin(filename);
+  if (!tin) {
+    cerr << "no such file: " << filename << '\n';
+    exit(1);
+  }
+  Trace_stream = new trace_stream;
+  while (has_data(tin)) {
+    int depth;
+    tin >> depth;
+    string label;
+    tin >> label;
+    if (*--label.end() == ':') label.erase(--label.end());
+    string line;
+    getline(tin, line);
+    Trace_stream->past_lines.push_back(trace_line(depth, label, line));
+  }
+}