about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-04-27 21:33:26 -0700
committerKartik Agaram <vc@akkartik.com>2019-04-27 21:40:12 -0700
commitf539a27245d31f4ba3c90389dce1f5f4d372bd27 (patch)
tree63ad429ff673c9c0febef165b0dc0e93c8adaee8 /subx
parent62a71b89a88800c1966980db1b0ca01ef728c78e (diff)
downloadmu-f539a27245d31f4ba3c90389dce1f5f4d372bd27.tar.gz
5131
Rename '--map' to '--debug'.
Diffstat (limited to 'subx')
-rw-r--r--subx/001help.cc9
-rw-r--r--subx/035labels.cc26
-rw-r--r--subx/036global_variables.cc4
-rw-r--r--subx/039debug.cc7
-rw-r--r--subx/Readme.md15
-rwxr-xr-xsubx/dgen4
-rwxr-xr-xsubx/drun4
7 files changed, 37 insertions, 32 deletions
diff --git a/subx/001help.cc b/subx/001help.cc
index 8d815be5..1b3f64dd 100644
--- a/subx/001help.cc
+++ b/subx/001help.cc
@@ -80,10 +80,11 @@ void init_help() {
     "== 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"
+    "- Add '--debug' to add information to traces. 'subx --debug translate' will\n"
+    "  save (to a file called 'labels') the mapping from labels to addresses that\n"
+    "  it computes during translation. This file is then available to\n"
+    "  'subx --debug --trace run' which prints out label names in the trace as it\n"
+    "  encounters them.\n"
     "\n"
     "Options starting with '--' must always come before any other arguments.\n"
     "\n"
diff --git a/subx/035labels.cc b/subx/035labels.cc
index 5596f6cc..f1eb6510 100644
--- a/subx/035labels.cc
+++ b/subx/035labels.cc
@@ -168,8 +168,8 @@ void compute_byte_indices_for_labels(const segment& code, map<string, int32_t>&
           raise << "'" << to_string(inst) << "': label definition (':') not allowed in operand\n" << end();
         if (j > 0)
           raise << "'" << to_string(inst) << "': labels can only be the first word in a line.\n" << end();
-        if (Map_file.is_open())
-          Map_file << "0x" << HEXWORD << (code.start + current_byte) << ' ' << label << '\n';
+        if (Labels_file.is_open())
+          Labels_file << "0x" << HEXWORD << (code.start + current_byte) << ' ' << label << '\n';
         if (contains_key(byte_index, label) && label != "Entry") {
           raise << "duplicate label '" << label << "'\n" << end();
           return;
@@ -183,20 +183,22 @@ void compute_byte_indices_for_labels(const segment& code, map<string, int32_t>&
 }
 
 :(before "End Globals")
-bool Dump_map = false;  // currently used only by 'subx translate'
-ofstream Map_file;
+bool Dump_debug_info = false;  // currently used only by 'subx translate'
+ofstream Labels_file;
 :(before "End Commandline Options")
-else if (is_equal(*arg, "--map")) {
-  Dump_map = true;
-  // End --map Settings
+else if (is_equal(*arg, "--debug")) {
+  Dump_debug_info = true;
+  // End --debug Settings
 }
-//: wait to open "map" for writing until we're sure we aren't trying to read it
+//: wait to open "labels" for writing until we're sure we aren't trying to read it
 :(after "Begin subx translate")
-if (Dump_map)
-  Map_file.open("map");
+if (Dump_debug_info) {
+  cerr << "saving address->label information to 'labels'\n";
+  Labels_file.open("labels");
+}
 :(before "End subx translate")
-if (Dump_map)
-  Map_file.close();
+if (Dump_debug_info)
+  Labels_file.close();
 
 :(code)
 void drop_labels(segment& code) {
diff --git a/subx/036global_variables.cc b/subx/036global_variables.cc
index 846cd291..fffabf72 100644
--- a/subx/036global_variables.cc
+++ b/subx/036global_variables.cc
@@ -54,8 +54,8 @@ void compute_addresses_for_global_variables(const segment& s, map<string, uint32
         if (trace_contains_errors()) return;
         if (j > 0)
           raise << "'" << to_string(inst) << "': global variable names can only be the first word in a line.\n" << end();
-        if (Map_file.is_open())
-          Map_file << "0x" << HEXWORD << current_address << ' ' << variable << '\n';
+        if (Labels_file.is_open())
+          Labels_file << "0x" << HEXWORD << current_address << ' ' << variable << '\n';
         if (contains_key(address, variable)) {
           raise << "duplicate global '" << variable << "'\n" << end();
           return;
diff --git a/subx/039debug.cc b/subx/039debug.cc
index fc0b622b..b631336a 100644
--- a/subx/039debug.cc
+++ b/subx/039debug.cc
@@ -1,12 +1,13 @@
 //:: Some helpers for debugging.
 
-//: Load the 'map' file generated during 'subx --map translate' when running 'subx --map --trace run'.
+//: Load the 'map' file generated during 'subx --debug translate' when running
+//: 'subx --debug --trace run'.
 //: (It'll only affect the trace.)
 
 :(before "End Globals")
 map</*address*/uint32_t, string> Symbol_name;  // used only by 'subx run'
-:(before "End --map Settings")
-load_map("map");
+:(before "End --debug Settings")
+load_map("labels");
 :(code)
 void load_map(const string& map_filename) {
   ifstream fin(map_filename.c_str());
diff --git a/subx/Readme.md b/subx/Readme.md
index 02867df4..15cb9972 100644
--- a/subx/Readme.md
+++ b/subx/Readme.md
@@ -41,8 +41,9 @@ messages.
 Emulated runs generate a trace that permits [time-travel debugging](https://github.com/akkartik/mu/blob/master/browse_trace/Readme.md).
 
   ```sh
-  $ ./subx --map translate examples/factorial.subx -o examples/factorial
-  $ ./subx --map --trace run examples/factorial
+  $ ./subx --debug translate examples/factorial.subx -o examples/factorial
+  saving address->label information to 'labels'
+  $ ./subx --debug --trace run examples/factorial
   saving trace to 'last_run'
   $ ../browse_trace/browse_trace last_run  # text-mode debugger UI
   ```
@@ -408,12 +409,12 @@ rudimentary but hopefully still workable toolkit:
 * As a further refinement, it is possible to render label names in the trace
   by adding a second flag to both the `translate` and `run` commands:
   ```
-  $ ./subx --map translate input.subx -o binary
-  $ ./subx --map --trace run binary arg1 arg2  2>trace
+  $ ./subx --debug translate input.subx -o binary
+  $ ./subx --debug --trace run binary arg1 arg2  2>trace
   ```
-  `subx --map translate` emits a mapping from label to address in a file
-  called `map`. `subx --map --trace run` reads in the `map` file at the start
-  and prints out any matching label name as it traces each instruction
+  `subx --debug translate` emits a mapping from label to address in a file
+  called `labels`. `subx --debug --trace run` reads in the `labels` file at
+  the start and prints out any matching label name as it traces each instruction
   executed.
 
   Here's a sample of what a trace looks like, with a few boxes highlighted:
diff --git a/subx/dgen b/subx/dgen
index 4aeec375..1a5a8366 100755
--- a/subx/dgen
+++ b/subx/dgen
@@ -18,11 +18,11 @@ export CFLAGS=-g
 
 case $1 in
   ex*)
-    ./subx --map translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'`
+    ./subx --debug translate examples/$1.subx -o examples/`echo $1 |sed 's/\..*//'`
     exit $?
     ;;
   *)
-    ./subx --map translate *.subx apps/$1.subx  -o apps/`echo $1 |sed 's/\..*//'`
+    ./subx --debug translate *.subx apps/$1.subx  -o apps/`echo $1 |sed 's/\..*//'`
     exit $?
     ;;
 esac
diff --git a/subx/drun b/subx/drun
index b094f995..71b2f0e0 100755
--- a/subx/drun
+++ b/subx/drun
@@ -12,11 +12,11 @@ fi
 
 case $1 in
   ex*)
-    ./subx --map --trace run examples/$*
+    ./subx --debug --trace run examples/$*
     exit $?
     ;;
   *)
-    ./subx --map --trace run apps/$*
+    ./subx --debug --trace run apps/$*
     exit $?
     ;;
 esac