https://github.com/hawkinsw created https://github.com/llvm/llvm-project/pull/215650
When DWIM printing, lldb will usually output explanatory feedback about the actual command used to generate the printed output (when the user has set the DWIM print verbosity to `true`). However, when DWIM printing a persistent variable, that note was omitted. This patch adds the explanatory message in that case. >From 7f2ca7e36f90ea0811e06c8d09e736e98695eb02 Mon Sep 17 00:00:00 2001 From: Will Hawkins <[email protected]> Date: Tue, 11 Aug 2026 16:02:21 -0400 Subject: [PATCH] [lldb] Note Command Used For DWIM Printing Of Persistent Variable When DWIM printing, lldb will usually output explanatory feedback about the actual command used to generate the printed output (when the user has set the DWIM print verbosity to `true`). However, when DWIM printing a persistent variable, that note was omitted. This patch adds the explanatory message in that case. Signed-off-by: Will Hawkins <[email protected]> --- lldb/source/Commands/CommandObjectDWIMPrint.cpp | 9 +++++++++ lldb/test/Shell/Commands/command-dwim-print.test | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp b/lldb/source/Commands/CommandObjectDWIMPrint.cpp index 1b0b4c7881cfc..5a9524e7d2e02 100644 --- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp +++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp @@ -197,6 +197,15 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command, language.AsLanguageType())) if (auto var_sp = state->GetVariable(expr)) if (auto valobj_sp = var_sp->GetValueObject()) { + + if (verbosity == eDWIMPrintVerbosityFull) { + StringRef flags; + if (args.HasArgs()) + flags = args.GetArgStringWithDelimiter(); + result.AppendNoteWithFormatv("ran `expression {0}{1}`", flags, + expr); + } + dump_val_object(*valobj_sp); return; } diff --git a/lldb/test/Shell/Commands/command-dwim-print.test b/lldb/test/Shell/Commands/command-dwim-print.test index 8c2697d8ebf8c..21c0cb440d958 100644 --- a/lldb/test/Shell/Commands/command-dwim-print.test +++ b/lldb/test/Shell/Commands/command-dwim-print.test @@ -14,3 +14,11 @@ # RUN: echo quit | %lldb -o "settings set show-inline-diagnostics false" \ # RUN: -o "dwim-print a" 2>&1 | FileCheck %s --check-prefix=CHECK4 # CHECK4: error: <user expression 0>:1:1: use of undeclared identifier +# RUN: echo "int main(){int x = 1; return 0;}">%t.c +# RUN: %clang_host %t.c -g -O0 -o %t.exe +# RUN: echo quit | %lldb %t.exe -o "b main" -o "run" -o \ +# RUN: "dwim-print --persistent-result true -- x" -o \ +# RUN: "settings set dwim-print-verbosity full" -o \ +# RUN: "dwim-print -l C11 -- $0" 2>&1 | FileCheck %s --check-prefix=CHECK5 +# (lldb) dwim-print $0 +# CHECK5:note: ran `expression -l C11 -- $0` _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
