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 | 140 | register_string |
| 141 | 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 | 143 | << " Opcode: " << r.module_ref->code_section[r.pc].op << "\n"; |
| 144 | 144 | |
| 145 | 145 | return register_string.str(); |
| @@ -389,14 +389,7 @@ namespace · 243 unmodified lines | ||
| 389 | 389 | if (pc < 0 || module->code_section.size() <= static_cast<std::size_t>(pc)) |
| 390 | 390 | throw debug_cmd_error_t{ "Invalid IP for module" }; |
| 391 | 391 | |
| 392 | − try | |
| 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 | − } | |
| 392 | + cxt.dbg.breakpoint_cookies.emplace(cxt.dbg.controller->set_breakpoint(module, pc)); | |
| 400 | 393 | } |
| 401 | 394 | |
| 402 | 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 | 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" | |
| 884 | − << "Break on module load: " << std::boolalpha << o.break_on_module_load << "\n" | |
| 885 | − << "Break on exception: " << std::boolalpha << o.break_on_exception << "\n"; | |
| 876 | + ss << "Break on enter: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_enter) << "\n" | |
| 877 | + << "Break on module load: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_module_load) << "\n" | |
| 878 | + << "Break on exception: " << std::boolalpha << util::has_flag(o, debugger_options::break_on_exception) << "\n"; | |
| 886 | 879 | |
| 887 | 880 | return ss; |
| 888 | 881 | } |
| 889 | 882 | |
| 890 | −debugger::debugger(const debugger_options &opt) | |
| 883 | +debugger::debugger(const debugger_options opt) | |
| 891 | 884 | : _options{ opt } |
| 892 | 885 | , _tool_id{ 0 } |
| 893 | 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 | 891 | _tool_id = tool_id; |
| 899 | 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 | 896 | auto t = cxt.value1.thread; |
| 904 | 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 | 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 | 910 | auto ss = std::stringstream{}; |
| 918 | 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 | 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 | 920 | auto ss = std::stringstream{}; |
| 928 | 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 | 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 | 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 | 933 | auto ss = std::stringstream{}; |
| 941 | 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 | 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 | 944 | auto m = (*cxt.value2.module); |
| 952 | 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 | 955 | // If the break on enter flag was set, it will be true |
| 963 | 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 | 959 | // Reset the break on enter flag and set a breakpoint |
| 967 | 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 | 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 | 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 | 971 | auto ss = std::stringstream{}; |
| 979 | 972 | ss << "Breakpoint hit"; |