summaryrefslogtreecommitdiff
path: root/Applications/Debugger
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2020-04-13 18:09:24 +0300
committerAndreas Kling <kling@serenityos.org>2020-04-13 23:20:59 +0200
commit109c24ae977316333c5719382116d4f0cfffe7e0 (patch)
tree00af084ec49418b4eba559853cb24b56cea59417 /Applications/Debugger
parent312559b13164a781a351eb1dabf867b5f67ac812 (diff)
downloadserenity-109c24ae977316333c5719382116d4f0cfffe7e0.zip
Debugger: Repeat previous command when an empty command is entered
Diffstat (limited to 'Applications/Debugger')
-rw-r--r--Applications/Debugger/main.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/Applications/Debugger/main.cpp b/Applications/Debugger/main.cpp
index 2ffbe8d8cd..97740181ee 100644
--- a/Applications/Debugger/main.cpp
+++ b/Applications/Debugger/main.cpp
@@ -205,6 +205,8 @@ int main(int argc, char** argv)
bool rc = g_debug_session->insert_breakpoint(g_debug_session->elf().entry().as_ptr());
ASSERT(rc);
+ String previous_command;
+
g_debug_session->run([&](DebugSession::DebugBreakReason reason, Optional<PtraceRegisters> optional_regs) {
if (reason == DebugSession::DebugBreakReason::Exited) {
printf("Program exited.\n");
@@ -219,12 +221,18 @@ int main(int argc, char** argv)
for (;;) {
auto command = get_command();
bool success = false;
+ Optional<DebugSession::DebugDecision> decision;
+ if (command.is_empty() && !previous_command.is_empty()) {
+ command = previous_command;
+ }
if (command == "cont") {
- return DebugSession::DebugDecision::Continue;
+ decision = DebugSession::DebugDecision::Continue;
+ success = true;
}
if (command == "s") {
- return DebugSession::DebugDecision::SingleStep;
+ decision = DebugSession::DebugDecision::SingleStep;
+ success = true;
}
if (command == "regs") {
@@ -238,8 +246,14 @@ int main(int argc, char** argv)
success = handle_breakpoint_command(command);
}
- if (!success)
+ if (success && !command.is_empty()) {
+ previous_command = command;
+ }
+ if (!success) {
print_help();
+ }
+ if (decision.has_value())
+ return decision.value();
}
});
}