History

Basic debugger implementation - No way to enable it without altering exec main.cpp.

arr committed 10 years ago

Commit f2c6ef31 parent 7c21b7718 files · +776 −72Browse files

Showing the changes to src/vm/thread.cpp (1 of 18 files). Show all

Unified · Split

src/vm/thread.cpp+7−1
@@ -13,6 +13,7 @@ · 12 unmodified lines
13#include <vm_memory.h>13#include <vm_memory.h>
14#include <debug.h>14#include <debug.h>
15#include "execution_table.h"15#include "execution_table.h"
16#include "tool_dispatch.h"
16 17
17using namespace disvm;18using namespace disvm;
18using namespace disvm::runtime;19using namespace disvm::runtime;
@@ -254,6 +255,11 @@ vm_thread_state_t vm_thread_t::execute(vm_t &vm, const uint32_t quanta) · 235 unmodified lines
254 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "exit: vm thread: stack exhausted: %d\n", _thread_id);255 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "exit: vm thread: stack exhausted: %d\n", _thread_id);
255 256
256 _registers.current_thread_state = vm_thread_state_t::empty_stack;257 _registers.current_thread_state = vm_thread_state_t::empty_stack;
258
259 auto tool_dispatch = _registers.tool_dispatch.load();
260 if (tool_dispatch != nullptr)
261 tool_dispatch->on_thread_end(*this);
262
257 break;263 break;
258 }264 }
259 265
@@ -278,7 +284,7 @@ vm_thread_state_t vm_thread_t::execute(vm_t &vm, const uint32_t quanta) · 18 unmodified lines
278 catch (const unhandled_user_exception &uue)284 catch (const unhandled_user_exception &uue)
279 {285 {
280 // [TODO] Store the exception286 // [TODO] Store the exception
281 std::fprintf(stderr, "%s - %s in %s at instruction %d\n", uue.what(), uue.exception_id, uue.module_name, uue.program_counter);287 std::fprintf(stderr, "%s - '%s' in %s at instruction %d\n", uue.what(), uue.exception_id, uue.module_name, uue.program_counter);
282 _registers.current_thread_state = vm_thread_state_t::broken;288 _registers.current_thread_state = vm_thread_state_t::broken;
283 }289 }
284 catch (const index_out_of_range_memory &ioor)290 catch (const index_out_of_range_memory &ioor)