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
1313 #include <vm_memory.h>
1414 #include <debug.h>
1515 #include "execution_table.h"
16+#include "tool_dispatch.h"
1617
1718 using namespace disvm;
1819 using 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
254255 debug::log_msg(debug::component_trace_t::thread, debug::log_level_t::debug, "exit: vm thread: stack exhausted: %d\n", _thread_id);
255256
256257 _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+
257263 break;
258264 }
259265
@@ -278,7 +284,7 @@ vm_thread_state_t vm_thread_t::execute(vm_t &vm, const uint32_t quanta) · 18 unmodified lines
278284 catch (const unhandled_user_exception &uue)
279285 {
280286 // [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);
282288 _registers.current_thread_state = vm_thread_state_t::broken;
283289 }
284290 catch (const index_out_of_range_memory &ioor)