From 3328ee550c86458ade5b3daf5fb4ad97b6a99e6c Mon Sep 17 00:00:00 2001 From: Dave Lee Date: Tue, 14 Feb 2023 13:48:07 -0800 Subject: [lldb] Suppress persistent result when running po Remove the persistent result variable after executing `po`. Without this change, the following behavior happens: ``` (lldb) p thing (NSObject *) $0 = 0x600000008000 (lldb) po thing (lldb) p thing (NSObject *) $2 = 0x600000008000 (lldb) p $1 (NSObject *) $1 = 0x600000008000 ``` Even though `po` hides the persistent result variable, it's still created - as $1 in this example. It can be accessed even though its existence is not evident. With this change, the persistent result is removed after the object description has printed. Instead, this is the behavior: ``` (lldb) p thing (NSObject *) $0 = 0x600000008000 (lldb) po thing (lldb) p thing (NSObject *) $1 = 0x600000008000 ``` The difference here is that the `po` doens't silently create a persistent result. Differential Revision: https://reviews.llvm.org/D144044 --- lldb/source/Commands/CommandObjectExpression.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lldb/source/Commands/CommandObjectExpression.cpp') diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 9cce009f..9402000 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -21,6 +21,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; @@ -346,6 +347,9 @@ EvaluateExpressionOptions CommandObjectExpression::GetEvalOptions(const Target &target) { EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); + if (m_command_options.m_verbosity == + eLanguageRuntimeDescriptionDisplayVerbosityCompact) + options.SetSuppressPersistentResult(m_varobj_options.use_objc); options.SetUnwindOnError(m_command_options.unwind_on_error); options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints); options.SetKeepInMemory(true); -- cgit v1.1