[Lldb-commits] [PATCH] D144044: [lldb] Suppress persistent result when running po

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 14 13:56:59 PST 2023


kastiglione created this revision.
kastiglione added reviewers: jingham, Michael137, augusto2112.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144044

Files:
  lldb/source/Commands/CommandObjectExpression.cpp


Index: lldb/source/Commands/CommandObjectExpression.cpp
===================================================================
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -346,6 +346,7 @@
 CommandObjectExpression::GetEvalOptions(const Target &target) {
   EvaluateExpressionOptions options;
   options.SetCoerceToId(m_varobj_options.use_objc);
+  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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144044.497434.patch
Type: text/x-patch
Size: 642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230214/cff95c9b/attachment-0001.bin>


More information about the lldb-commits mailing list