Skip to content

Conversation

@JDevlieghere
Copy link
Member

Reverts #171931 because the test is failing on Windows.

@JDevlieghere JDevlieghere enabled auto-merge (squash) December 12, 2025 23:35
@llvmbot llvmbot added the lldb label Dec 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 12, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Reverts llvm/llvm-project#171931 because the test is failing on Windows.


Full diff: https://github.com/llvm/llvm-project/pull/172110.diff

3 Files Affected:

  • (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+7-19)
  • (removed) lldb/test/Shell/Settings/Inputs/FailedCommand.in (-4)
  • (removed) lldb/test/Shell/Settings/TestEchoFailedCommands.test (-10)
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 9ccf22801d667..0198ddcfa31e0 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3371,15 +3371,14 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
     if (line.empty())
       return;
   }
-  bool echoed_command = false;
   if (!is_interactive) {
     // When using a non-interactive file handle (like when sourcing commands
     // from a file) we need to echo the command out so we don't just see the
     // command output and no command...
     if (EchoCommandNonInteractive(line, io_handler.GetFlags())) {
-      io_handler.GetOutputStreamFileSP()->Lock()
-          << io_handler.GetPrompt() << line << '\n';
-      echoed_command = true;
+      LockedStreamFile locked_stream =
+          io_handler.GetOutputStreamFileSP()->Lock();
+      locked_stream.Printf("%s%s\n", io_handler.GetPrompt(), line.c_str());
     }
   }
 
@@ -3399,21 +3398,10 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
   lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
-  const bool print_result =
-      result.Succeeded() &&
-      io_handler.GetFlags().Test(eHandleCommandFlagPrintResult);
-  const bool print_error =
-      io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors);
-
-  // Now emit the command output text from the command we just executed.
-  if (print_result || print_error) {
-    // If the command failed and we didn't echo it, echo it now so the user
-    // knows which command produced the error.
-    if (!echoed_command && !result.Succeeded() && print_error) {
-      io_handler.GetOutputStreamFileSP()->Lock()
-          << io_handler.GetPrompt() << line << '\n';
-    }
-
+  // Now emit the command output text from the command we just executed
+  if ((result.Succeeded() &&
+       io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
+      io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
     auto DefaultPrintCallback = [&](const CommandReturnObject &result) {
       // Display any inline diagnostics first.
       const bool inline_diagnostics = !result.GetImmediateErrorStream() &&
diff --git a/lldb/test/Shell/Settings/Inputs/FailedCommand.in b/lldb/test/Shell/Settings/Inputs/FailedCommand.in
deleted file mode 100644
index c3bc5c704fe34..0000000000000
--- a/lldb/test/Shell/Settings/Inputs/FailedCommand.in
+++ /dev/null
@@ -1,4 +0,0 @@
-# This should succeed and not be echoed.
-expr 1+2
-# This should fail and be echoed.
-bogus_command
diff --git a/lldb/test/Shell/Settings/TestEchoFailedCommands.test b/lldb/test/Shell/Settings/TestEchoFailedCommands.test
deleted file mode 100644
index 3bb465707a41d..0000000000000
--- a/lldb/test/Shell/Settings/TestEchoFailedCommands.test
+++ /dev/null
@@ -1,10 +0,0 @@
-# Test that failed commands are echoed even when echoing is disabled.
-# This ensures users can see which command produced an error.
-
-RUN: mkdir -p %t.home
-RUN: cp %S/Inputs/FailedCommand.in %t.home/.lldbinit
-RUN: env HOME=%t.home %lldb-init -b 2>&1 | FileCheck %s
-
-CHECK-NOT: expr 1+2
-CHECK: (lldb) bogus_command
-CHECK: error: 'bogus_command' is not a valid command

@JDevlieghere JDevlieghere merged commit 9878bac into main Dec 12, 2025
12 checks passed
@JDevlieghere JDevlieghere deleted the revert-171931-issue-171514 branch December 12, 2025 23:53
anonymouspc pushed a commit to anonymouspc/llvm that referenced this pull request Dec 15, 2025
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Dec 19, 2025
Priyanshu3820 pushed a commit to Priyanshu3820/llvm-project that referenced this pull request Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants