Skip to content

Commit

Permalink
Fix infinite loop on EOF in the command line debugger
Browse files Browse the repository at this point in the history
When using the command line debugger (godot -d) on Unix systems, when
entering an EOF (ctrl+D), the debugger enters an infinite loop.

Adding a check for EOF in the debugger loop exits the debugger when EOF
is entered.

Fixes godotengine#50170.
  • Loading branch information
sbarkeha committed Jun 11, 2023
1 parent 37d1dfe commit 4ecad8d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/debugger/local_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
// Cache options
String variable_prefix = options["variable_prefix"];

if (line.is_empty()) {
if (line.is_empty() && !feof(stdin)) {
print_line("\nDebugger Break, Reason: '" + script_lang->debug_get_error() + "'");
print_line("*Frame " + itos(current_frame) + " - " + script_lang->debug_get_stack_level_source(current_frame) + ":" + itos(script_lang->debug_get_stack_level_line(current_frame)) + " in function '" + script_lang->debug_get_stack_level_function(current_frame) + "'");
print_line("Enter \"help\" for assistance.");
Expand Down Expand Up @@ -267,7 +267,8 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
print_line("Added breakpoint at " + source + ":" + itos(linenr));
}

} else if (line == "q" || line == "quit") {
} else if (line == "q" || line == "quit" ||
(line.is_empty() && feof(stdin))) {
// Do not stop again on quit
script_debugger->clear_breakpoints();
script_debugger->set_depth(-1);
Expand Down

0 comments on commit 4ecad8d

Please sign in to comment.