diff options
author | Dave Lee <davelee.com@gmail.com> | 2023-02-14 13:48:07 -0800 |
---|---|---|
committer | Dave Lee <davelee.com@gmail.com> | 2023-02-16 21:05:19 -0800 |
commit | 3328ee550c86458ade5b3daf5fb4ad97b6a99e6c (patch) | |
tree | bb2d65da364af78a273ba525658bdf434c43e9fa /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | b3215c8106170e586c59cc66a118329108cb72a4 (diff) | |
download | llvm-3328ee550c86458ade5b3daf5fb4ad97b6a99e6c.zip llvm-3328ee550c86458ade5b3daf5fb4ad97b6a99e6c.tar.gz llvm-3328ee550c86458ade5b3daf5fb4ad97b6a99e6c.tar.bz2 |
[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
<NSObject: 0x600000008000>
(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
<NSObject: 0x600000008000>
(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
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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); |