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
343343
344344 void cmd_breakpoint_set(const std::vector<std::string> &a, dbg_cmd_cxt_t &cxt)
345345 {
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" };
348348
349349 vm_pc_t pc;
350350 try
@@ -356,26 +356,30 @@ namespace · 5 unmodified lines
356356 throw debug_cmd_error_t{ "Invalid IP format" };
357357 }
358358
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)
365361 {
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+ }
368372
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;
374377
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+ }
379383
380384 if (module == nullptr)
381385 {
@@ -743,7 +747,7 @@ namespace · 361 unmodified lines
743747 { "t", "Print all threads", nullptr, nullptr, cmd_print_threads },
744748 { "m", "Print all loaded modules", nullptr, nullptr, cmd_print_modules },
745749
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 },
747751 { "bc", "Clear breakpoint(s)", "bc ([0-9]+|\\*)", "bc 3, bc *", cmd_breakpoint_clear },
748752 { "bl", "List breakpoints", nullptr, nullptr, cmd_breakpoint_list },
749753