History

Change assert to exception if a dis module contains an invalid magic number. Broken threads now terminate the VM using the default scheduler. Tools can not get a callback for broken threads.

arr committed 10 years ago

Commit 096b0c71 parent 9c1abd69 files · +74 −28Browse files

Showing the changes to src/include (3 of 9 files). Show all

Unified · Split

3 files
  1. src/include/exceptions.h +12 −0
  2. src/include/runtime.h +7 −2
  3. src/include/vm_tools.h +1 −0
src/include/exceptions.h+12−0
@@ -128,6 +128,18 @@ namespace disvm · 127 unmodified lines
128 const char *module_name;128 const char *module_name;
129 const vm_pc_t program_counter;129 const vm_pc_t program_counter;
130 };130 };
131
132 class vm_term_request final : public vm_user_exception
133 {
134 public:
135 explicit vm_term_request()
136 : vm_user_exception("VM termination requested")
137 { }
138
139 explicit vm_term_request(const char *msg)
140 : vm_user_exception(msg)
141 { }
142 };
131 }143 }
132}144}
133 145
src/include/runtime.h+7−2
@@ -717,7 +717,7 @@ namespace disvm · 716 unmodified lines
717 exiting, // exit instruction717 exiting, // exit instruction
718 empty_stack,718 empty_stack,
719 719
720 broken, // thread crashed720 broken, // thread crashed - the scheduler is free to terminate the entire VM if any thread enters this state.
721 };721 };
722 722
723 // Forward declaration723 // Forward declaration
@@ -787,6 +787,10 @@ namespace disvm · 63 unmodified lines
787 787
788 vm_thread_state_t get_state() const;788 vm_thread_state_t get_state() const;
789 789
790 // This function will only return a non-null
791 // value if this thread is in the broken state.
792 const char *get_error_message() const;
793
790 uint32_t get_thread_id() const;794 uint32_t get_thread_id() const;
791 795
792 uint32_t get_parent_thread_id() const;796 uint32_t get_parent_thread_id() const;
@@ -794,9 +798,10 @@ namespace disvm · 1 unmodified line
794 const vm_registers_t& get_registers() const;798 const vm_registers_t& get_registers() const;
795 799
796 private:800 private:
801 vm_registers_t _registers;
797 const uint32_t _thread_id;802 const uint32_t _thread_id;
798 const uint32_t _parent_thread_id;803 const uint32_t _parent_thread_id;
799 vm_registers_t _registers;804 char *_error_message;
800 };805 };
801 806
802 //807 //
src/include/vm_tools.h+1−0
@@ -49,6 +49,7 @@ namespace disvm · 48 unmodified lines
49 49
50 thread_begin, // value1: const vm_thread_t50 thread_begin, // value1: const vm_thread_t
51 thread_end, // value1: const vm_thread_t51 thread_end, // value1: const vm_thread_t
52 thread_broken, // value1: const vm_thread_t
52 53
53 exception_raised, // value1: vm_registers_t54 exception_raised, // value1: vm_registers_t
54 // value2: const vm_string_t - exception ID55 // value2: const vm_string_t - exception ID