Showing the changes to src/exec/debugger.cpp (1 of 1 file). Show all
Unified · Split
| @@ -343,8 +343,8 @@ namespace · 342 unmodified lines | ||
| 343 | 343 | |
| 344 | 344 | void cmd_breakpoint_set(const std::vector<std::string> &a, dbg_cmd_cxt_t &cxt) |
| 345 | 345 | { |
| 346 | − if (a.size() < 3) | |
| 347 | − throw debug_cmd_error_t{ "Must supply an IP and module ID" }; | |
| 346 | + if (a.size() < 2) | |
| 347 | + throw debug_cmd_error_t{ "Must supply an IP" }; | |
| 348 | 348 | |
| 349 | 349 | vm_pc_t pc; |
| 350 | 350 | try |
| @@ -356,26 +356,30 @@ namespace · 5 unmodified lines | ||
| 356 | 356 | throw debug_cmd_error_t{ "Invalid IP format" }; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | − uint32_t module_id; | |
| 360 | − try | |
| 361 | − { | |
| 362 | − module_id = std::stoul(a[2]); | |
| 363 | − } | |
| 364 | − catch (...) | |
| 359 | + auto module = std::const_pointer_cast<vm_module_t>(cxt.current_register->module_ref->module); | |
| 360 | + if (a.size() > 2) | |
| 365 | 361 | { |
| 366 | − throw debug_cmd_error_t{ "Invalid module ID format" }; | |
| 367 | − } | |
| 362 | + module.reset(); | |
| 363 | + uint32_t module_id; | |
| 364 | + try | |
| 365 | + { | |
| 366 | + module_id = std::stoul(a[2]); | |
| 367 | + } | |
| 368 | + catch (...) | |
| 369 | + { | |
| 370 | + throw debug_cmd_error_t{ "Invalid module ID format" }; | |
| 371 | + } | |
| 368 | 372 | |
| 369 | − auto module = std::shared_ptr<vm_module_t>{}; | |
| 370 | − cxt.vm.enum_loaded_modules([module_id, &module](const loaded_vm_module_t &m) | |
| 371 | − { | |
| 372 | − if (module_id != m.load_id) | |
| 373 | − return true; | |
| 373 | + cxt.vm.enum_loaded_modules([module_id, &module](const loaded_vm_module_t &m) | |
| 374 | + { | |
| 375 | + if (module_id != m.load_id) | |
| 376 | + return true; | |
| 374 | 377 | |
| 375 | − // Found the matching ID so stop | |
| 376 | − module = m.module.lock(); | |
| 377 | − return false; | |
| 378 | − }); | |
| 378 | + // Found the matching ID so stop | |
| 379 | + module = m.module.lock(); | |
| 380 | + return false; | |
| 381 | + }); | |
| 382 | + } | |
| 379 | 383 | |
| 380 | 384 | if (module == nullptr) |
| 381 | 385 | { |
| @@ -743,7 +747,7 @@ namespace · 361 unmodified lines | ||
| 743 | 747 | { "t", "Print all threads", nullptr, nullptr, cmd_print_threads }, |
| 744 | 748 | { "m", "Print all loaded modules", nullptr, nullptr, cmd_print_modules }, |
| 745 | 749 | |
| 746 | − { "bs", "Set breakpoint at the specified IP in a loaded module", "bs [0-9]+ [0-9]+", "bs 3 5 (Breakpoint at IP 3 in module 5)", cmd_breakpoint_set }, | |
| 750 | + { "bs", "Set breakpoint at the specified IP in a loaded module", "bs [0-9]+ [0-9]*", "bs 3 5 (Breakpoint at IP 3 in module 5), bs 4 (Breakpoint at IP 4 in current module)", cmd_breakpoint_set }, | |
| 747 | 751 | { "bc", "Clear breakpoint(s)", "bc ([0-9]+|\\*)", "bc 3, bc *", cmd_breakpoint_clear }, |
| 748 | 752 | { "bl", "List breakpoints", nullptr, nullptr, cmd_breakpoint_list }, |
| 749 | 753 | |