This is an archive of the discontinued LLVM Phabricator instance.

[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter
ClosedPublic

Authored by Michael137 on May 23 2023, 4:07 PM.

Details

Summary

This mimicks the implementation of the libstd++ and libc++ std::unique_ptr
formatters.

This has been attempted several years ago in
0789722d85cf1f1fdbe2ffb2245ea0ba034a9f94 but was reverted in
e7dd3972094c2f2fb42dc9d4d5344e54a431e2ce.

The difference to the original patch is that we now maintain
a $$dereference$$ member and we only store weak pointers
to the other children inside the synthetic frontend. This is
what the libc++ formatters do to prevent the recursion mentioned
in the revert commit.

This patch addresses https://github.com/llvm/llvm-project/issues/62825

Diff Detail

Event Timeline

Michael137 created this revision.May 23 2023, 4:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2023, 4:07 PM
Michael137 requested review of this revision.May 23 2023, 4:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2023, 4:07 PM
Michael137 edited the summary of this revision. (Show Details)May 23 2023, 4:11 PM
aprantl accepted this revision.May 23 2023, 4:17 PM
This revision is now accepted and ready to land.May 23 2023, 4:17 PM

Fix expected string in test

antmo added a subscriber: antmo.May 25 2023, 12:14 AM

Hi Michael,
lldb-aarch64-windows bot is broken since yesterday: https://lab.llvm.org/buildbot/#/builders/219/builds/3012
I suspect this is due to this commit. Could you please take a look at this ?

Any chance someone with a working aarch64 windows 10 setup could take a look? (@compnerd ?) Or let me know how I might be able to set this up.

The place where we seem to crash in TestVarPath.py is:

# Make sure we don't crash when looking for non existant child     
# in type with synthetic children. This used to cause a crash.     
v = frame.GetValueForVariablePath('pt_sp->not_valid_child')        
self.assertTrue(v.GetError().Fail(),                               
                "Make sure we don't find 'pt_sp->not_valid_child'")

A crash that was previously addressed in 0d6f681292d5a. Interestingly, the code path that was added in that patch is the one that we used to take before adding support for $$dereference$$ in this patch.