Showing the changes to src/vm/tool_dispatch.cpp (1 of 8 files). Show all
Unified · Split
| @@ -92,6 +92,22 @@ std::size_t vm_tool_dispatch_t::unload_tool(std::size_t tool_id) · 91 unmodified lines | ||
| 92 | 92 | return _tools.size(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | +namespace | |
| 96 | +{ | |
| 97 | + DEFINE_ENUM_FLAG_OPERATORS(vm_trap_flags_t); | |
| 98 | +} | |
| 99 | + | |
| 100 | +void vm_tool_dispatch_t::on_trap(vm_registers_t &r, vm_trap_flags_t f) | |
| 101 | +{ | |
| 102 | + vm_event_context_t cxt{}; | |
| 103 | + cxt.value1.registers = &r; | |
| 104 | + cxt.value2.trap = f; | |
| 105 | + | |
| 106 | + // Clear the trap flag | |
| 107 | + r.trap_flags &= ~f; | |
| 108 | + _events.fire_event_callbacks(vm_event_t::trap, cxt); | |
| 109 | +} | |
| 110 | + | |
| 95 | 111 | opcode_t vm_tool_dispatch_t::on_breakpoint(vm_registers_t &r) |
| 96 | 112 | { |
| 97 | 113 | opcode_t original_op; |
| @@ -361,6 +377,15 @@ void vm_tool_dispatch_t::resume_all_threads() · 263 unmodified lines | ||
| 361 | 377 | _threads_resume.notify_all(); |
| 362 | 378 | } |
| 363 | 379 | |
| 380 | +void vm_tool_dispatch_t::set_thread_trap_flag(const vm_registers_t &r, vm_trap_flags_t flag) | |
| 381 | +{ | |
| 382 | + std::lock_guard<std::mutex> suspend_lock{ _threads_resume_lock }; | |
| 383 | + if (!_threads_suspended) | |
| 384 | + throw vm_system_exception{ "Unable to set thread trap flag while threads are not suspended" }; | |
| 385 | + | |
| 386 | + const_cast<vm_trap_flags_t &>(r.trap_flags) |= flag; | |
| 387 | +} | |
| 388 | + | |
| 364 | 389 | std::tuple<opcode_t, cookie_t> vm_tool_dispatch_t::get_original_opcode_and_cookie(const vm_registers_t &r) |
| 365 | 390 | { |
| 366 | 391 | const auto module = r.module_ref->module.get(); |