This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Suppress persistent result when running po
ClosedPublic

Authored by kastiglione on Feb 14 2023, 1:56 PM.

Details

Summary

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.

Diff Detail

Event Timeline

kastiglione created this revision.Feb 14 2023, 1:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2023, 1:56 PM
kastiglione requested review of this revision.Feb 14 2023, 1:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 14 2023, 1:56 PM

I'll update with a test.

Respect verbosity level

jingham accepted this revision.Feb 16 2023, 2:40 PM
This revision is now accepted and ready to land.Feb 16 2023, 2:40 PM
This revision was automatically updated to reflect the committed changes.