History

Name the entry module in the exec program. Re-write stack walking function for debugger. System exceptions now print out call stack.

arr committed 10 years ago

Commit 794ecfc1 parent 4f6417b5 files · +54 −35Browse files

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

Unified · Split

src/vm/scheduler.cpp+19−2
@@ -5,6 +5,7 @@ · 4 unmodified lines
5//5//
6 6
7#include <debug.h>7#include <debug.h>
8#include <sstream>
8#include <exceptions.h>9#include <exceptions.h>
9#include "scheduler.h"10#include "scheduler.h"
10 11
@@ -45,8 +46,24 @@ void default_scheduler_t::worker_main(default_scheduler_t &instance) · 34 unmodified lines
45 }46 }
46 catch (const vm_system_exception &se)47 catch (const vm_system_exception &se)
47 {48 {
48 std::printf("%s\n", se.what());49 std::stringstream err_msg;
50 err_msg << se.what() << "\n";
49 51
52 if (current_thread != nullptr)
53 {
54 const auto &r = current_thread->vm_thread->get_registers();
55 walk_stack(r, [&err_msg](const pointer_t, const vm_pc_t pc, const vm_module_ref_t &module_ref)
56 {
57 auto module_name = "<No Name>";
58 if (module_ref.module->module_name != nullptr)
59 module_name = module_ref.module->module_name->str();
60
61 err_msg << "\t" << module_name << "@" << pc << "\n";
62 return true;
63 });
64 }
65
66 std::fprintf(stderr, "%s\n", err_msg.str().c_str());
50 instance._terminating = true;67 instance._terminating = true;
51 instance._worker_event.notify_all();68 instance._worker_event.notify_all();
52 }69 }
@@ -89,7 +106,7 @@ default_scheduler_t::~default_scheduler_t() · 36 unmodified lines
89bool default_scheduler_t::is_idle() const106bool default_scheduler_t::is_idle() const
90{107{
91 std::lock_guard<std::mutex> lock{ _vm_threads_lock };108 std::lock_guard<std::mutex> lock{ _vm_threads_lock };
92 return _running_vm_thread_count == 0 && _runnable_vm_threads.empty() && _blocked_vm_thread_ids.empty() && !_terminating;109 return (_terminating) || (_running_vm_thread_count == 0 && _runnable_vm_threads.empty() && _blocked_vm_thread_ids.empty());
93}110}
94 111
95vm_scheduler_control_t &default_scheduler_t::get_controller() const112vm_scheduler_control_t &default_scheduler_t::get_controller() const