about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-03-22 21:52:42 -0700
committerKartik Agaram <vc@akkartik.com>2019-03-22 21:52:42 -0700
commitb0212309664363e832404fe80b959397314909c2 (patch)
treea1b0b306bdf6790b8cf01577d73ecff03c4a8e8b
parent9be1aa30d8c32c7750c9ae9e73b4caa1037a7a5b (diff)
downloadmu-b0212309664363e832404fe80b959397314909c2.tar.gz
5016
-rw-r--r--subx/010---vm.cc9
-rw-r--r--subx/039debug.cc8
2 files changed, 16 insertions, 1 deletions
diff --git a/subx/010---vm.cc b/subx/010---vm.cc
index 4c346a3d..3def0ff9 100644
--- a/subx/010---vm.cc
+++ b/subx/010---vm.cc
@@ -302,7 +302,7 @@ void run_one_instruction() {
   }
   uint32_t inst_start_address = EIP;
   op = next();
-  trace(Callstack_depth, "run") << "0x" << HEXWORD << inst_start_address << " opcode: " << HEXBYTE << NUM(op) << (op == 0xe8 ? "/call" : "") << end();
+  trace(Callstack_depth, "run") << "0x" << HEXWORD << inst_start_address << " opcode: " << HEXBYTE << NUM(op) << call_label(op) << end();
   switch (op) {
   case 0xf4:  // hlt
     EIP = End_of_program;
@@ -375,6 +375,13 @@ void dump_registers() {
   trace(Callstack_depth+1, "run") << out.str() << end();
 }
 
+// debugging info from a later layer
+string call_label(uint8_t op) {
+  if (op != 0xe8) return "";
+  // End Trace Call Instruction
+  return "/call";
+}
+
 //: start tracking supported opcodes
 :(before "End Globals")
 map</*op*/string, string> Name;
diff --git a/subx/039debug.cc b/subx/039debug.cc
index 9078acf2..fc0b622b 100644
--- a/subx/039debug.cc
+++ b/subx/039debug.cc
@@ -24,6 +24,14 @@ void load_map(const string& map_filename) {
 if (contains_key(Symbol_name, EIP))
   trace(Callstack_depth, "run") << "== label " << get(Symbol_name, EIP) << end();
 
+//: make calls in particular more salient
+:(before "End Trace Call Instruction")
+// at this point we've skipped past the e8 opcode, but not the offset operand
+int32_t offset = read_mem_i32(EIP);
+uint32_t next_eip = EIP+offset+4;
+if (contains_key(Symbol_name, next_eip))
+  return "/call "+get(Symbol_name, next_eip);
+
 //: If a label starts with '$watch-', make a note of the effective address
 //: computed by the next instruction. Start dumping out its contents to the
 //: trace after every subsequent instruction.