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.

(cherry picked from commit 4ecad8d)
  • Loading branch information
sbarkeha authored and timothyqiu committed Aug 8, 2023
1 parent b776cf5 commit d1dcea7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/script_debugger_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void ScriptDebuggerLocal::debug(ScriptLanguage *p_script, bool p_can_continue, b
// Cache options
String variable_prefix = options["variable_prefix"];

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

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

0 comments on commit d1dcea7

Please sign in to comment.