Skip to content

Commit 5b25d9d

Browse files
Merge pull request #6959 from apple/dl/lldb-Prevent-dwim-print-from-showing-kNoResult-error
[lldb] Prevent dwim-print from showing kNoResult error
2 parents c8e31f7 + 816aa78 commit 5b25d9d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lldb/source/Commands/CommandObjectDWIMPrint.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "lldb/Core/ValueObject.h"
1212
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
1313
#include "lldb/Expression/ExpressionVariable.h"
14+
#include "lldb/Expression/UserExpression.h"
1415
#include "lldb/Interpreter/CommandInterpreter.h"
1516
#include "lldb/Interpreter/CommandObject.h"
1617
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -178,7 +179,8 @@ bool CommandObjectDWIMPrint::DoExecute(StringRef command,
178179
expr);
179180
}
180181

181-
valobj_sp->Dump(result.GetOutputStream(), dump_options);
182+
if (valobj_sp->GetError().GetError() != UserExpression::kNoResult)
183+
valobj_sp->Dump(result.GetOutputStream(), dump_options);
182184

183185
if (suppress_result)
184186
if (auto result_var_sp =

lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,9 @@ def test_summary_strings(self):
138138
self.runCmd("type summary add -e -s 'stub summary' Structure")
139139
self._expect_cmd(f"dwim-print s", "frame variable")
140140
self._expect_cmd(f"dwim-print (struct Structure)s", "expression")
141+
142+
def test_void_result(self):
143+
"""Test dwim-print does not surface an error message for void expressions."""
144+
self.build()
145+
lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c"))
146+
self.expect("dwim-print (void)15", matching=False, patterns=["(?i)error"])

0 commit comments

Comments
 (0)