From 12eba08f8c80f701382d615e5c8705b5ea62d473 Mon Sep 17 00:00:00 2001 From: Simon Barkehanai Date: Sun, 11 Jun 2023 04:20:22 -0700 Subject: [PATCH] Fix infinite loop on EOF in the command line debugger 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 #50170. (cherry picked from commit 4ecad8dea30859a5acbac41fe0e647c7bb6a53cc) --- core/object/script_debugger_local.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/object/script_debugger_local.cpp b/core/object/script_debugger_local.cpp index ea28d29ed..5b7ecb853 100644 --- a/core/object/script_debugger_local.cpp +++ b/core/object/script_debugger_local.cpp @@ -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."); @@ -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);