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/execution_table.cpp (1 of 18 files). Show all

Unified · Split

src/vm/execution_table.cpp+19−4
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 #include <cstdint>
1212 #include <limits>
1313 #include <random>
14+#include <vector>
1415 #include <disvm.h>
1516 #include <vm_memory.h>
1617 #include <opcodes.h>
@@ -184,7 +185,7 @@ namespace · 167 unmodified lines
184185 EXEC_DECL(cvtwc)
185186 {
186187 // String represents the largest possible string from a word.
187− auto buffer = std::array<char, sizeof("�2147483648")>{};
188+ auto buffer = std::array<char, sizeof("-2147483648")>{};
188189
189190 const auto w = vt_ref<word_t>(r.src);
190191 const auto len = std::sprintf(buffer.data(), "%d", w);
@@ -1643,6 +1644,11 @@ namespace · 1452 unmodified lines
16431644 debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: exception: >>%s<<\n", exception_id->str());
16441645 }
16451646
1647+ // Check if the tool dispatcher has been supplied
1648+ auto tool_dispatch = r.tool_dispatch.load();
1649+ if (tool_dispatch != nullptr)
1650+ tool_dispatch->on_exception_raised(r, *exception_id, *e);
1651+
16461652 const handler_t *handler;
16471653 vm_frame_t *target_frame;
16481654 vm_pc_t handler_pc;
@@ -1652,6 +1658,15 @@ namespace · 3 unmodified lines
16521658
16531659 assert(r.module_ref != nullptr);
16541660 std::tie(handler, target_frame, handler_pc) = find_exception_handler(r.stack, *r.module_ref, faulting_pc, *exception_id);
1661+ if (handler == nullptr && target_frame == nullptr && handler_pc == runtime_constants::invalid_program_counter)
1662+ {
1663+ if (tool_dispatch != nullptr)
1664+ tool_dispatch->on_exception_unhandled(r, *exception_id, *e);
1665+
1666+ auto faulting_module_name = r.module_ref->module->module_name->str();
1667+ throw unhandled_user_exception{ exception_id->str(), faulting_module_name, faulting_pc };
1668+ }
1669+
16551670 assert(target_frame != nullptr);
16561671
16571672 // Now that we know the exception has a handler, take a reference.
@@ -1694,11 +1709,11 @@ namespace · 36 unmodified lines
16941709 auto tool_dispatch = r.tool_dispatch.load();
16951710 if (tool_dispatch == nullptr)
16961711 {
1697− assert(false && "Breakpoint set but no tool dispatcher found" );
1698− throw vm_system_exception{ "Breakpoint set but no tool dispatcher found" };
1712+ assert(false && "Breakpoint set but no tool dispatcher found");
1713+ throw vm_system_exception{ "Breakpoint set but no tool(s) loaded" };
16991714 }
17001715
1701− const auto original_op = tool_dispatch->on_breakpoint(r, vm);
1716+ const auto original_op = tool_dispatch->on_breakpoint(r);
17021717
17031718 // Continue execution
17041719 vm_exec_table[static_cast<std::size_t>(original_op)](r, vm);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t