This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Don't model std::atomic as a transparent data structure in the data formatter
ClosedPublic

Authored by teemperor on Feb 10 2020, 4:30 AM.

Details

Summary

Currently the data formatter is treating std::atomic variables as transparent wrappers
around their underlying value type. This causes that when printing std::atomic<A *>, the data
formatter will forward all requests for the children of the atomic variable to the A * pointer type
which will then return the respective members of A. If A in turn has a member that contains
the original atomic variable, this causes LLDB to infinitely recurse when printing an object with
such a std::atomic pointer member.

We could implement a workaround similar to whatever we do for pointer values but this patch
just implements the std::atomic formatter in the same way as we already implement other
formatters (e.g. smart pointers or std::optional) that just model the contents of the as a child
"Value". This way LLDB knows when it actually prints a pointer and can just use its normal
workaround if "Value" is a recursive pointer.

Fixes rdar://59189235

Diff Detail

Event Timeline

teemperor created this revision.Feb 10 2020, 4:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2020, 4:30 AM
shafik accepted this revision.Feb 10 2020, 3:06 PM
shafik added a subscriber: shafik.

LGTM otherwise.

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
70

What about inspecting p and p.child.parent?

This revision is now accepted and ready to land.Feb 10 2020, 3:06 PM
teemperor updated this revision to Diff 245109.Feb 18 2020, 2:16 AM
  • Expand tests as suggested by Shafik (thanks!)
This revision was automatically updated to reflect the committed changes.