Showing the changes to src/vm/execution_table.cpp (1 of 18 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | |||
| 11 | #include <cstdint> | 11 | #include <cstdint> |
| 12 | #include <limits> | 12 | #include <limits> |
| 13 | #include <random> | 13 | #include <random> |
| 14 | #include <vector> | ||
| 14 | #include <disvm.h> | 15 | #include <disvm.h> |
| 15 | #include <vm_memory.h> | 16 | #include <vm_memory.h> |
| 16 | #include <opcodes.h> | 17 | #include <opcodes.h> |
| @@ -184,7 +185,7 @@ namespace · 167 unmodified lines | |||
| 184 | EXEC_DECL(cvtwc) | 185 | EXEC_DECL(cvtwc) |
| 185 | { | 186 | { |
| 186 | // String represents the largest possible string from a word. | 187 | // 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")>{}; |
| 188 | 189 | ||
| 189 | const auto w = vt_ref<word_t>(r.src); | 190 | const auto w = vt_ref<word_t>(r.src); |
| 190 | const auto len = std::sprintf(buffer.data(), "%d", w); | 191 | const auto len = std::sprintf(buffer.data(), "%d", w); |
| @@ -1643,6 +1644,11 @@ namespace · 1452 unmodified lines | |||
| 1643 | debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: exception: >>%s<<\n", exception_id->str()); | 1644 | debug::log_msg(debug::component_trace_t::exception, debug::log_level_t::debug, "raise: exception: >>%s<<\n", exception_id->str()); |
| 1644 | } | 1645 | } |
| 1645 | 1646 | ||
| 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 | |||
| 1646 | const handler_t *handler; | 1652 | const handler_t *handler; |
| 1647 | vm_frame_t *target_frame; | 1653 | vm_frame_t *target_frame; |
| 1648 | vm_pc_t handler_pc; | 1654 | vm_pc_t handler_pc; |
| @@ -1652,6 +1658,15 @@ namespace · 3 unmodified lines | |||
| 1652 | 1658 | ||
| 1653 | assert(r.module_ref != nullptr); | 1659 | assert(r.module_ref != nullptr); |
| 1654 | std::tie(handler, target_frame, handler_pc) = find_exception_handler(r.stack, *r.module_ref, faulting_pc, *exception_id); | 1660 | 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 | |||
| 1655 | assert(target_frame != nullptr); | 1670 | assert(target_frame != nullptr); |
| 1656 | 1671 | ||
| 1657 | // Now that we know the exception has a handler, take a reference. | 1672 | // Now that we know the exception has a handler, take a reference. |
| @@ -1694,11 +1709,11 @@ namespace · 36 unmodified lines | |||
| 1694 | auto tool_dispatch = r.tool_dispatch.load(); | 1709 | auto tool_dispatch = r.tool_dispatch.load(); |
| 1695 | if (tool_dispatch == nullptr) | 1710 | if (tool_dispatch == nullptr) |
| 1696 | { | 1711 | { |
| 1697 | assert(false && "Breakpoint set but no tool dispatcher found" ); | 1712 | assert(false && "Breakpoint set but no tool dispatcher found"); |
| 1698 | throw vm_system_exception{ "Breakpoint set but no tool dispatcher found" }; | 1713 | throw vm_system_exception{ "Breakpoint set but no tool(s) loaded" }; |
| 1699 | } | 1714 | } |
| 1700 | 1715 | ||
| 1701 | const auto original_op = tool_dispatch->on_breakpoint(r, vm); | 1716 | const auto original_op = tool_dispatch->on_breakpoint(r); |
| 1702 | 1717 | ||
| 1703 | // Continue execution | 1718 | // Continue execution |
| 1704 | vm_exec_table[static_cast<std::size_t>(original_op)](r, vm); | 1719 | vm_exec_table[static_cast<std::size_t>(original_op)](r, vm); |