about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2019-07-15 15:47:35 -0700
committerKartik Agaram <vc@akkartik.com>2019-07-15 15:47:35 -0700
commit9ad8133197a8917c819db6cee3348a7d04090877 (patch)
treebc1598ccdfd5fe17b700b9b29061da479a92198b
parentaef4efb959b215a2cd830e186c083c78f7bde60a (diff)
downloadmu-9ad8133197a8917c819db6cee3348a7d04090877.tar.gz
5405
-rw-r--r--subx/003trace.cc9
-rw-r--r--subx/010---vm.cc3
-rw-r--r--subx/012elf.cc11
-rw-r--r--subx/020syscalls.cc3
4 files changed, 12 insertions, 14 deletions
diff --git a/subx/003trace.cc b/subx/003trace.cc
index 590fb7fa..379077a9 100644
--- a/subx/003trace.cc
+++ b/subx/003trace.cc
@@ -168,6 +168,15 @@ ostream& operator<<(ostream& os, end /*unused*/) {
   return os;
 }
 
+//: Fatal error.
+:(before "End Types")
+struct die {};
+:(code)
+ostream& operator<<(ostream& /*unused*/, die /*unused*/) {
+  if (Trace_stream) Trace_stream->newline();
+  exit(1);
+}
+
 :(before "End trace_stream Methods")
 void newline();
 :(code)
diff --git a/subx/010---vm.cc b/subx/010---vm.cc
index de8d51b1..6ee41c9b 100644
--- a/subx/010---vm.cc
+++ b/subx/010---vm.cc
@@ -202,8 +202,7 @@ inline uint8_t* mem_addr_u8(uint32_t addr) {
   }
   if (result == NULL) {
     if (Trace_file) Trace_file.flush();
-    raise << "Tried to access uninitialized memory at address 0x" << HEXWORD << addr << '\n' << end();
-    exit(1);
+    raise << "Tried to access uninitialized memory at address 0x" << HEXWORD << addr << '\n' << die();
   }
   return result;
 }
diff --git a/subx/012elf.cc b/subx/012elf.cc
index da70adec..9bd6cbf1 100644
--- a/subx/012elf.cc
+++ b/subx/012elf.cc
@@ -94,8 +94,7 @@ void push(uint32_t val) {
     raise << "The stack overflowed its segment. "
           << "Maybe SPACE_FOR_SEGMENT should be larger? "
           << "Or you need to carve out an exception for the stack segment "
-          << "to be larger.\n" << end();
-    exit(1);
+          << "to be larger.\n" << die();
   }
   trace(Callstack_depth+1, "run") << "decrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end();
   trace(Callstack_depth+1, "run") << "pushing value 0x" << HEXWORD << val << end();
@@ -182,14 +181,6 @@ ostream& operator<<(ostream& os, perr /*unused*/) {
   return os;
 }
 
-:(before "End Types")
-struct die {};
-:(code)
-ostream& operator<<(ostream& /*unused*/, die /*unused*/) {
-  if (Trace_stream) Trace_stream->newline();
-  exit(1);
-}
-
 :(before "End Includes")
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/subx/020syscalls.cc b/subx/020syscalls.cc
index eb72f85d..f885089e 100644
--- a/subx/020syscalls.cc
+++ b/subx/020syscalls.cc
@@ -119,8 +119,7 @@ uint32_t new_segment(uint32_t length) {
   uint32_t result = (Segments_allocated_above - length) & 0xff000000;  // same number of zeroes as SEGMENT_ALIGNMENT
   if (result <= START_HEAP) {
     raise << "Allocated too many segments; the VM ran out of memory. "
-          << "Maybe SEGMENT_ALIGNMENT can be smaller?\n" << end();
-    exit(1);
+          << "Maybe SEGMENT_ALIGNMENT can be smaller?\n" << die();
   }
   Mem.push_back(vma(result, result+length));
   Segments_allocated_above = result;