[Lldb-commits] [lldb] [lldb] Still echo the command if we print the error. (PR #171931)

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 11 15:51:51 PST 2025


================
@@ -3398,10 +3312,22 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
   lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
   HandleCommand(line.c_str(), eLazyBoolCalculate, result);
 
-  // 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)) {
+  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) {
+      LockedStreamFile locked_stream =
+          io_handler.GetOutputStreamFileSP()->Lock();
+      locked_stream.Printf("%s%s\n", io_handler.GetPrompt(), line.c_str());
----------------
adrian-prantl wrote:

not important, but 
`locked_stream << io_handler.GetPrompt() << line << "\n";`
would avoid a bunch of length computation.

https://github.com/llvm/llvm-project/pull/171931


More information about the lldb-commits mailing list