History

Add support for traps in VM Add instruction trap to enable single step scenario in debugger Remote get_state() function from thread

arr committed 9 years ago

Commit cb408a11 parent eb570d98 files · +120 −40Browse files

Showing the changes to src/include (2 of 8 files). Show all

Unified · Split

2 files
  1. src/include/runtime.h +12 −6
  2. src/include/vm_tools.h +5 −0
src/include/runtime.h+12−6
@@ -709,7 +709,7 @@ namespace disvm · 708 unmodified lines
709709 const vm_string_t &exception_id);
710710
711711 // VM thread states
712− enum class vm_thread_state_t : uint16_t
712+ enum class vm_thread_state_t : uint8_t
713713 {
714714 unknown = 0,
715715
@@ -729,6 +729,13 @@ namespace disvm · 13 unmodified lines
729729 broken, // thread crashed - the scheduler is free to terminate the entire VM if any thread enters this state.
730730 };
731731
732+ // VM trap flags
733+ enum class vm_trap_flags_t : uint8_t
734+ {
735+ none = 0,
736+ instruction = 1 << 0,
737+ };
738+
732739 // Forward declaration
733740 class vm_thread_t;
734741 class vm_tool_dispatch_t;
@@ -738,11 +745,11 @@ namespace disvm · 3 unmodified lines
738745 {
739746 public:
740747 vm_registers_t(
741− const vm_thread_t &thread,
748+ vm_thread_t &thread,
742749 vm_module_ref_t &entry);
743750 ~vm_registers_t();
744751
745− const vm_thread_t &thread;
752+ vm_thread_t &thread;
746753 std::atomic<vm_tool_dispatch_t *> tool_dispatch;
747754 vm_stack_t stack; // Frame pointer access (FP)
748755 vm_pc_t pc; // Current Program counter (Index into module code section)
@@ -751,8 +758,9 @@ namespace disvm · 2 unmodified lines
751758 vm_module_ref_t *module_ref; // Module reference
752759 vm_request_mutex_t request_mutex;
753760
754− vm_thread_state_t current_thread_state;
755761 uint16_t current_thread_quanta;
762+ vm_thread_state_t current_thread_state;
763+ vm_trap_flags_t trap_flags;
756764
757765 pointer_t src;
758766 pointer_t mid;
@@ -795,8 +803,6 @@ namespace disvm · 36 unmodified lines
795803 // this vm thread.
796804 void set_tool_dispatch(vm_tool_dispatch_t *dispatch);
797805
798− vm_thread_state_t get_state() const;
799−
800806 // This function will only return a non-null
801807 // value if this thread is in the broken state.
802808 const char *get_error_message() const;
src/include/vm_tools.h+5−0
@@ -23,6 +23,7 @@ namespace disvm · 22 unmodified lines
2323 union vm_context_value_t
2424 {
2525 cookie_t cookie;
26+ vm_trap_flags_t trap;
2627 std::shared_ptr<vm_module_t> *module; // Note this is a pointer to std::shared_ptr<>
2728 vm_registers_t *registers;
2829 const vm_thread_t *thread;
@@ -61,6 +62,9 @@ namespace disvm · 32 unmodified lines
6162
6263 breakpoint, // value1: vm_registers_t
6364 // value2: cookie_t - cookie of breakpoint. '0' indicates the breakpoint was inserted by the VM or compiler.
65+
66+ trap, // value1: vm_registers_t - The trap flag is unset prior to the event be fired.
67+ // value2: vm_trap_flags_t
6468 };
6569
6670 using vm_event_callback_t = std::function<void(vm_event_t, vm_event_context_t &)>;
@@ -91,6 +95,7 @@ namespace disvm · 24 unmodified lines
9195 // Manipulate thread execution
9296 virtual void suspend_all_threads() = 0;
9397 virtual void resume_all_threads() = 0;
98+ virtual void set_thread_trap_flag(const vm_registers_t &, vm_trap_flags_t flag) = 0;
9499 };
95100 }
96101 }