History

Set breakpoint now defaults to using the current module if module is not defined.

arr committed 10 years ago

Commit 551c5001 parent db76c0c1 file · +24 −20Browse files

Showing the changes to src/exec/debugger.cpp (1 of 1 file). Show all

Unified · Split

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