mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
Debugger: Repeat previous command when an empty command is entered
This commit is contained in:
parent
312559b131
commit
109c24ae97
1 changed files with 17 additions and 3 deletions
|
@ -205,6 +205,8 @@ int main(int argc, char** argv)
|
||||||
bool rc = g_debug_session->insert_breakpoint(g_debug_session->elf().entry().as_ptr());
|
bool rc = g_debug_session->insert_breakpoint(g_debug_session->elf().entry().as_ptr());
|
||||||
ASSERT(rc);
|
ASSERT(rc);
|
||||||
|
|
||||||
|
String previous_command;
|
||||||
|
|
||||||
g_debug_session->run([&](DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
|
g_debug_session->run([&](DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
|
||||||
if (reason == DebugSession::DebugBreakReason::Exited) {
|
if (reason == DebugSession::DebugBreakReason::Exited) {
|
||||||
printf("Program exited.\n");
|
printf("Program exited.\n");
|
||||||
|
@ -219,12 +221,18 @@ int main(int argc, char** argv)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
auto command = get_command();
|
auto command = get_command();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
Optional<DebugSession::DebugDecision> decision;
|
||||||
|
|
||||||
|
if (command.is_empty() && !previous_command.is_empty()) {
|
||||||
|
command = previous_command;
|
||||||
|
}
|
||||||
if (command == "cont") {
|
if (command == "cont") {
|
||||||
return DebugSession::DebugDecision::Continue;
|
decision = DebugSession::DebugDecision::Continue;
|
||||||
|
success = true;
|
||||||
}
|
}
|
||||||
if (command == "s") {
|
if (command == "s") {
|
||||||
return DebugSession::DebugDecision::SingleStep;
|
decision = DebugSession::DebugDecision::SingleStep;
|
||||||
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "regs") {
|
if (command == "regs") {
|
||||||
|
@ -238,8 +246,14 @@ int main(int argc, char** argv)
|
||||||
success = handle_breakpoint_command(command);
|
success = handle_breakpoint_command(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success)
|
if (success && !command.is_empty()) {
|
||||||
|
previous_command = command;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
print_help();
|
print_help();
|
||||||
}
|
}
|
||||||
|
if (decision.has_value())
|
||||||
|
return decision.value();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue