mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
Debugger: Add 'examine' command
This command outputs the memory contents of a given address as an unsigned int. LibDebug already had support for this, so just a matter of intergating it in sdb. Very useful :)
This commit is contained in:
parent
a8cfb83d08
commit
711c42e25e
Notes:
sideshowbarker
2024-07-19 00:52:10 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/711c42e25eb Pull-request: https://github.com/SerenityOS/serenity/pull/3738 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling
|
@ -148,6 +148,29 @@ static bool handle_breakpoint_command(const String& command)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool handle_examine_command(const String& command)
|
||||
{
|
||||
auto parts = command.split(' ');
|
||||
if (parts.size() != 2)
|
||||
return false;
|
||||
|
||||
auto argument = parts[1];
|
||||
if (argument.is_empty())
|
||||
return false;
|
||||
|
||||
if (!(argument.starts_with("0x"))) {
|
||||
return false;
|
||||
}
|
||||
u32 address = strtoul(argument.characters() + 2, nullptr, 16);
|
||||
auto res = g_debug_session->peek((u32*)address);
|
||||
if (!res.has_value()) {
|
||||
printf("could not examine memory at address 0x%x\n", address);
|
||||
return true;
|
||||
}
|
||||
printf("0x%x\n", res.value());
|
||||
return true;
|
||||
}
|
||||
|
||||
static void print_help()
|
||||
{
|
||||
out("Options:\n"
|
||||
|
@ -157,7 +180,8 @@ static void print_help()
|
|||
"line - show the position of the current instruction in the source code\n"
|
||||
"regs - Print registers\n"
|
||||
"dis [number of instructions] - Print disassembly\n"
|
||||
"bp <address/symbol/file:line> - Insert a breakpoint\n");
|
||||
"bp <address/symbol/file:line> - Insert a breakpoint\n"
|
||||
"x <address> - examine dword in memory\n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -263,6 +287,8 @@ int main(int argc, char** argv)
|
|||
|
||||
} else if (command.starts_with("bp")) {
|
||||
success = handle_breakpoint_command(command);
|
||||
} else if (command.starts_with("x")) {
|
||||
success = handle_examine_command(command);
|
||||
}
|
||||
|
||||
if (success && !command.is_empty()) {
|
||||
|
|
Loading…
Reference in a new issue