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);


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);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to