Showing the changes to src/exec/debugger.cpp (1 of 6 files). Show all
Unified · Split
| @@ -139,7 +139,7 @@ namespace · 138 unmodified lines | |||
| 139 | 139 | ||
| 140 | register_string | 140 | register_string |
| 141 | << " Thread ID: " << r.thread.get_thread_id() << "\n" | 141 | << " Thread ID: " << r.thread.get_thread_id() << "\n" |
| 142 | << " Module: " << r.module_ref->module->module_name->str() << " PC: " << r.pc << "\n" | 142 | << " PC: " << r.pc << " Module: " << r.module_ref->module->module_name->str() << "\n" |
| 143 | << " Opcode: " << r.module_ref->code_section[r.pc].op << "\n"; | 143 | << " Opcode: " << r.module_ref->code_section[r.pc].op << "\n"; |
| 144 | 144 | ||
| 145 | return register_string.str(); | 145 | return register_string.str(); |
| @@ -389,14 +389,7 @@ namespace · 243 unmodified lines | |||
| 389 | if (pc < 0 || module->code_section.size() <= static_cast<std::size_t>(pc)) | 389 | if (pc < 0 || module->code_section.size() <= static_cast<std::size_t>(pc)) |
| 390 | throw debug_cmd_error_t{ "Invalid IP for module" }; | 390 | throw debug_cmd_error_t{ "Invalid IP for module" }; |
| 391 | 391 | ||
| 392 | try | 392 | cxt.dbg.breakpoint_cookies.emplace(cxt.dbg.controller->set_breakpoint(module, pc)); |
| 393 | { | ||
| 394 | cxt.dbg.breakpoint_cookies.push_back(cxt.dbg.controller->set_breakpoint(module, pc)); | ||
| 395 | } | ||
| 396 | catch (const vm_system_exception& e) | ||
| 397 | { | ||
| 398 | throw debug_cmd_error_t{ e.what() }; | ||
| 399 | } | ||
| 400 | } | 393 | } |
| 401 | 394 | ||
| 402 | void cmd_breakpoint_clear(const std::vector<std::string> &a, dbg_cmd_cxt_t &cxt) | 395 | void cmd_breakpoint_clear(const std::vector<std::string> &a, dbg_cmd_cxt_t &cxt) |
| @@ -880,14 +873,14 @@ namespace · 477 unmodified lines | |||
| 880 | 873 | ||
| 881 | std::ostream& operator<<(std::ostream &ss, const debugger_options o) | 874 | std::ostream& operator<<(std::ostream &ss, const debugger_options o) |
| 882 | { | 875 | { |
| 883 | ss << "Break on enter: " << std::boolalpha << o.break_on_enter << "\n" | 876 | ss << "Break on enter: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_enter) << "\n" |
| 884 | << "Break on module load: " << std::boolalpha << o.break_on_module_load << "\n" | 877 | << "Break on module load: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_module_load) << "\n" |
| 885 | << "Break on exception: " << std::boolalpha << o.break_on_exception << "\n"; | 878 | << "Break on exception: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_exception) << "\n"; |
| 886 | 879 | ||
| 887 | return ss; | 880 | return ss; |
| 888 | } | 881 | } |
| 889 | 882 | ||
| 890 | debugger::debugger(const debugger_options &opt) | 883 | debugger::debugger(const debugger_options opt) |
| 891 | : _options{ opt } | 884 | : _options{ opt } |
| 892 | , _tool_id{ 0 } | 885 | , _tool_id{ 0 } |
| 893 | , controller{ nullptr } | 886 | , controller{ nullptr } |
| @@ -898,7 +891,7 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 4 unmodified lines | |||
| 898 | _tool_id = tool_id; | 891 | _tool_id = tool_id; |
| 899 | controller = &controller_; | 892 | controller = &controller_; |
| 900 | 893 | ||
| 901 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::thread_begin, [](vm_event_t, vm_event_context_t &cxt) | 894 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::thread_begin, [](vm_event_t, vm_event_context_t &cxt) |
| 902 | { | 895 | { |
| 903 | auto t = cxt.value1.thread; | 896 | auto t = cxt.value1.thread; |
| 904 | auto ss = std::stringstream{}; | 897 | auto ss = std::stringstream{}; |
| @@ -912,7 +905,7 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 7 unmodified lines | |||
| 912 | debug_print_info(ss.str()); | 905 | debug_print_info(ss.str()); |
| 913 | })); | 906 | })); |
| 914 | 907 | ||
| 915 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::thread_end, [](vm_event_t, vm_event_context_t &cxt) | 908 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::thread_end, [](vm_event_t, vm_event_context_t &cxt) |
| 916 | { | 909 | { |
| 917 | auto ss = std::stringstream{}; | 910 | auto ss = std::stringstream{}; |
| 918 | ss << "Thread " | 911 | ss << "Thread " |
| @@ -922,7 +915,7 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 3 unmodified lines | |||
| 922 | debug_print_info(ss.str()); | 915 | debug_print_info(ss.str()); |
| 923 | })); | 916 | })); |
| 924 | 917 | ||
| 925 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::exception_raised, [&](vm_event_t, vm_event_context_t &cxt) | 918 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::exception_raised, [&](vm_event_t, vm_event_context_t &cxt) |
| 926 | { | 919 | { |
| 927 | auto ss = std::stringstream{}; | 920 | auto ss = std::stringstream{}; |
| 928 | ss << "Exception '" | 921 | ss << "Exception '" |
| @@ -931,11 +924,11 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 2 unmodified lines | |||
| 931 | 924 | ||
| 932 | debug_print_info(ss.str()); | 925 | debug_print_info(ss.str()); |
| 933 | 926 | ||
| 934 | if (_options.break_on_exception) | 927 | if (util::has_flag(_options, debugger_options::break_on_exception)) |
| 935 | prompt(*this, *cxt.value1.registers); | 928 | prompt(*this, *cxt.value1.registers); |
| 936 | })); | 929 | })); |
| 937 | 930 | ||
| 938 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::exception_unhandled, [&](vm_event_t, vm_event_context_t &cxt) | 931 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::exception_unhandled, [&](vm_event_t, vm_event_context_t &cxt) |
| 939 | { | 932 | { |
| 940 | auto ss = std::stringstream{}; | 933 | auto ss = std::stringstream{}; |
| 941 | ss << "Unhandled exception '" | 934 | ss << "Unhandled exception '" |
| @@ -946,7 +939,7 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 4 unmodified lines | |||
| 946 | prompt(*this, *cxt.value1.registers); | 939 | prompt(*this, *cxt.value1.registers); |
| 947 | })); | 940 | })); |
| 948 | 941 | ||
| 949 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::module_thread_load, [&](vm_event_t, vm_event_context_t &cxt) | 942 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::module_thread_load, [&](vm_event_t, vm_event_context_t &cxt) |
| 950 | { | 943 | { |
| 951 | auto m = (*cxt.value2.module); | 944 | auto m = (*cxt.value2.module); |
| 952 | auto ss = std::stringstream{}; | 945 | auto ss = std::stringstream{}; |
| @@ -961,19 +954,19 @@ void debugger::on_load(vm_tool_controller_t &controller_, std::size_t tool_id) · 8 unmodified lines | |||
| 961 | 954 | ||
| 962 | // If the break on enter flag was set, it will be true | 955 | // If the break on enter flag was set, it will be true |
| 963 | // and the first module load will be the user entry module. | 956 | // and the first module load will be the user entry module. |
| 964 | if (_options.break_on_enter) | 957 | if (util::has_flag(_options, debugger_options::break_on_enter)) |
| 965 | { | 958 | { |
| 966 | // Reset the break on enter flag and set a breakpoint | 959 | // Reset the break on enter flag and set a breakpoint |
| 967 | // on the entry PC for the module - 'break on enter' | 960 | // on the entry PC for the module - 'break on enter' |
| 968 | _options.break_on_enter = false; | 961 | _options ^= debugger_options::break_on_enter; |
| 969 | controller->set_breakpoint(m, m->header.entry_pc); | 962 | controller->set_breakpoint(m, m->header.entry_pc); |
| 970 | } | 963 | } |
| 971 | 964 | ||
| 972 | if (_options.break_on_module_load) | 965 | if (util::has_flag(_options, debugger_options::break_on_module_load)) |
| 973 | prompt(*this, *cxt.value1.registers); | 966 | prompt(*this, *cxt.value1.registers); |
| 974 | })); | 967 | })); |
| 975 | 968 | ||
| 976 | _event_cookies.push_back(controller->subscribe_event(vm_event_t::breakpoint, [&](vm_event_t, vm_event_context_t &cxt) | 969 | _event_cookies.emplace(controller->subscribe_event(vm_event_t::breakpoint, [&](vm_event_t, vm_event_context_t &cxt) |
| 977 | { | 970 | { |
| 978 | auto ss = std::stringstream{}; | 971 | auto ss = std::stringstream{}; |
| 979 | ss << "Breakpoint hit"; | 972 | ss << "Breakpoint hit"; |