about summary refs log tree commit diff stats
path: root/033exclusive_container.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-02-25 00:17:46 -0800
committerKartik Agaram <vc@akkartik.com>2019-02-25 01:50:53 -0800
commitc442a5ad806b6cccbb3ec4c5744b14b0c1f31a01 (patch)
tree318fb1d56e7ee3c750635d3326ad0739dfdacefe /033exclusive_container.cc
parente5998f74ac29bb4bf2aedfdd6fbea801ffdb08f6 (diff)
downloadmu-c442a5ad806b6cccbb3ec4c5744b14b0c1f31a01.tar.gz
4987 - support `browse_trace` tool in SubX
I've extracted it into a separate binary, independent of my Mu prototype.

I also cleaned up my tracing layer to be a little nicer. Major improvements:

- Realized that incremental tracing really ought to be the default.
  And to minimize printing traces to screen.

- Finally figured out how to combine layers and call stack frames in a
  single dimension of depth. The answer: optimize for the experience of
  `browse_trace`. Instructions occupy a range of depths based on their call
  stack frame, and minor details of an instruction lie one level deeper
  in each case.

Other than that, I spent some time adjusting levels everywhere to make
`browse_trace` useful.
Diffstat (limited to '033exclusive_container.cc')
-rw-r--r--033exclusive_container.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index c2d69f60..5c57972e 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -150,19 +150,19 @@ case MAYBE_CONVERT: {
   write_products = false;
   if (tag == static_cast<int>(get_or_insert(Memory, base_address))) {
     const reagent& variant = variant_type(base, tag);
-    trace("mem") << "storing 1 in location " << status.value << end();
+    trace(Callstack_depth+1, "mem") << "storing 1 in location " << status.value << end();
     put(Memory, status.value, 1);
     if (!is_dummy(product)) {
       // Write Memory in Successful MAYBE_CONVERT in Run
       for (int i = 0;  i < size_of(variant);  ++i) {
         double val = get_or_insert(Memory, base_address+/*skip tag*/1+i);
-        trace("mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end();
+        trace(Callstack_depth+1, "mem") << "storing " << no_scientific(val) << " in location " << product.value+i << end();
         put(Memory, product.value+i, val);
       }
     }
   }
   else {
-    trace("mem") << "storing 0 in location " << status.value << end();
+    trace(Callstack_depth+1, "mem") << "storing 0 in location " << status.value << end();
     put(Memory, status.value, 0);
   }
   break;
@@ -305,7 +305,7 @@ $error: 0
 :(before "End check_merge_call Special-cases")
 case EXCLUSIVE_CONTAINER: {
   assert(state.data.top().container_element_index == 0);
-  trace("transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end();
+  trace(102, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end();
   // easy case: exact match
   if (types_strictly_match(container, inst.ingredients.at(ingredient_index)))
     return;
@@ -320,7 +320,7 @@ case EXCLUSIVE_CONTAINER: {
     return;
   }
   const reagent& variant = variant_type(container, ingredient.value);
-  trace("transform") << "tag: " << ingredient.value << end();
+  trace(102, "transform") << "tag: " << ingredient.value << end();
   // replace union with its variant
   state.data.pop();
   state.data.push(merge_check_point(variant, 0));