This is an archive of the discontinued LLVM Phabricator instance.

Add data formatter for libstdc++ shared_ptr and weak_ptr
ClosedPublic

Authored by tberghammer on Jul 5 2016, 2:48 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

tberghammer updated this revision to Diff 62728.Jul 5 2016, 2:48 AM
tberghammer retitled this revision from to Add data formatter for libstdc++ shared_ptr and weak_ptr.
tberghammer updated this object.
tberghammer added reviewers: labath, granata.enrico.
tberghammer added a subscriber: lldb-commits.
tberghammer updated this revision to Diff 62730.Jul 5 2016, 3:24 AM

Apply clang-format

granata.enrico added inline comments.Jul 5 2016, 10:57 AM
source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
665 ↗(On Diff #62730)

Is there any reason to hide the children for a type that you provide synthetic children for?

tberghammer added inline comments.Jul 5 2016, 11:12 AM
source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
665 ↗(On Diff #62730)

Without hiding the children the content of the shard_ptr will be displayed 2 times. Once in the first line as part of the summary and then 2nd time as a children. I think it is cleaner if we display the value only once but it can make it more difficult to access to the content of the shared pointer.

If you think displaying the children is better then I am happy with that option too.

The 2 possible output for a type Foo:

(std::shared_ptr<Foo>) f = Foo @ 0x0000000000606118 {
  _M_ptr = 0x0000000000606118
}
(std::shared_ptr<Foo>) f = Foo @ 0x0000000000606118

The 2 possible output for an std::string:

(std::shared_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >) s = "123456" {
  _M_ptr = "123456"
}
(std::shared_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >) s = "123456"
granata.enrico added inline comments.Jul 5 2016, 11:19 AM
source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
665 ↗(On Diff #62730)

Oh, I see. Yeah, I had to solve a similar problem for Swift Optionals.

Essentially, you're discovering that for shared_ptr<T>, T can have combinations of values, summaries, synthetic values, ...

Unfortunately right now there is no automated formatter for the concept of a box<T> that handles all those intricacies automatically for you. It would be a nice thing to add, but it's probably beyond the scope of your change

Feel free to pick your favorite solution for now, and I'll try to get to a universal box formatter at some point.

tberghammer added inline comments.Jul 6 2016, 2:54 AM
source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
665 ↗(On Diff #62730)

I decided to remove it to be in sync with the libc++ shared_ptr/weak_ptr summary provider but having a formatter for box<T> would be nice but I am not sure what should be the exact semantic of it. If you won't beat me with it I might take a look in the future but don't know when I will have time for it.

This revision was automatically updated to reflect the committed changes.