about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
Diffstat (limited to 'subx')
-rw-r--r--subx/001help.cc15
-rw-r--r--subx/003trace.cc28
2 files changed, 14 insertions, 29 deletions
diff --git a/subx/001help.cc b/subx/001help.cc
index 5f90abca..8d815be5 100644
--- a/subx/001help.cc
+++ b/subx/001help.cc
@@ -76,10 +76,19 @@ void init_help() {
     "    subx translate input1.subx intput2.subx ... -o <output ELF binary>\n"
     "- Run a SubX binary using SubX itself (for better error messages):\n"
     "    subx run <ELF binary>\n"
-    "Add '--trace' to any of these commands to also emit a trace, for debugging purposes.\n"
-    "However, options starting with '--' must always come before any other arguments.\n"
     "\n"
-    "To start learning how to write SubX programs, run:\n"
+    "== Debugging aids\n"
+    "- Add '--trace' to any of these commands to print a trace to stderr\n"
+    "  for debugging purposes.\n"
+    "- Add '--map' to add information to traces. 'subx --map translate' will save\n"
+    "  (to a file called 'map') the mapping from labels to addresses that it computes\n"
+    "  during translation. This file is then available to 'subx --map --trace run'\n"
+    "  which prints out label names in the trace as it encounters them.\n"
+    "\n"
+    "Options starting with '--' must always come before any other arguments.\n"
+    "\n"
+    "To start learning how to write SubX programs, see Readme.md (particularly\n"
+    "the section on the x86 instruction set) and then run:\n"
     "  subx help\n"
   );
   // End Help Texts
diff --git a/subx/003trace.cc b/subx/003trace.cc
index 22622930..e2080898 100644
--- a/subx/003trace.cc
+++ b/subx/003trace.cc
@@ -76,22 +76,9 @@ struct trace_line {
   trace_line(int d, string l, string c) :depth(d), label(l), contents(c) {}
 };
 
-//: Support for tracing an entire run.
-//: Traces can have a lot of overhead, so only turn them on when asked.
-:(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--trace")) {
-  Save_trace = true;
-}
-:(before "End Commandline Parsing")
-if (Save_trace) {
-  cerr << "initializing trace\n";
-  Trace_stream = new trace_stream;
-}
 :(code)
 void cleanup_main() {
   if (!Trace_stream) return;
-  if (Save_trace)
-    Trace_stream->save();
   delete Trace_stream;
   Trace_stream = NULL;
 }
@@ -130,13 +117,6 @@ struct trace_stream {
     return *curr_stream;
   }
 
-  void save() {
-    cerr << "saving trace to 'last_run'\n";
-    ofstream fout("last_run");
-    fout << readable_contents("");
-    fout.close();
-  }
-
   // be sure to call this before messing with curr_stream or curr_label
   void newline();
   // useful for debugging
@@ -174,11 +154,11 @@ string trace_stream::readable_contents(string label) {
 trace_stream* Trace_stream = NULL;
 int Trace_errors = 0;  // used only when Trace_stream is NULL
 
-//: option to print trace to the screen
+//: commandline flag to print trace incrementally to stderr
 :(before "End Globals")
 bool Flag_dump_trace = false;
 :(before "End Commandline Options(*arg)")
-else if (is_equal(*arg, "--dump")) {
+else if (is_equal(*arg, "--trace")) {
   Flag_dump_trace = true;
 }
 
@@ -233,9 +213,6 @@ ostream& operator<<(ostream& os, end /*unused*/) {
   return os;
 }
 
-:(before "End Globals")
-bool Save_trace = false;  // if set, write out trace to disk
-
 // Trace_stream is a resource, lease_tracer uses RAII to manage it.
 :(before "End Types")
 struct lease_tracer {
@@ -245,7 +222,6 @@ struct lease_tracer {
 :(code)
 lease_tracer::lease_tracer() { Trace_stream = new trace_stream; }
 lease_tracer::~lease_tracer() {
-  if (Save_trace) Trace_stream->save();
   delete Trace_stream, Trace_stream = NULL;
 }
 :(before "End Includes")