This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Move and clean-up the Declaration class (NFC)
ClosedPublic

Authored by mib on Apr 29 2021, 11:18 AM.

Details

Summary

This patch moves the Declaration class from the Symbol library to the
Core library. This will allow to use it in a more generic fashion and
aims to lower the dependency cycles when it comes to the linking.

The patch also does some cleaning up by making column information
permanent and removing the LLDB_ENABLE_DECLARATION_COLUMNS directives.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib created this revision.Apr 29 2021, 11:18 AM
mib requested review of this revision.Apr 29 2021, 11:18 AM

IIRC they were #ifdef's out because of memory concerns. Did you have a chance to benchmark this quickly (e.g., trying to attach to a debug Clang and see how much it increases memory)

Otherwise this LGTM.

FWIW, we also need this for the SourceLocation in Clang Decls feature I was working on some time ago.

JDevlieghere added inline comments.Apr 29 2021, 12:36 PM
lldb/include/lldb/Core/Declaration.h
129

Let's also add an operator bool that just calls IsValid() under the hood.

130
179–180

Move this above the variables.

mib marked 3 inline comments as done.Apr 29 2021, 5:20 PM
mib added a comment.Apr 29 2021, 6:09 PM

IIRC they were #ifdef's out because of memory concerns. Did you have a chance to benchmark this quickly (e.g., trying to attach to a debug Clang and see how much it increases memory)

Otherwise this LGTM.

FWIW, we also need this for the SourceLocation in Clang Decls feature I was working on some time ago.

I ran a benchmark as you suggested, attaching to a debug clang build, checking lldb's memory before starting the process (650MB), setting a breakpoint to main then launching the process (~1GB), and after the process stops, I tried evaluating the following expression : (lldb) expr std::string("This is a string.", 4) (4.83GB) and the memory usage matched in both scenarios.

mib updated this revision to Diff 341727.Apr 29 2021, 6:11 PM

Addressed @JDevlieghere comments.

JDevlieghere accepted this revision.Apr 29 2021, 8:20 PM

LGTM

lldb/include/lldb/Core/Declaration.h
161

Is this actually used? I don't think it's worth adding that if it's not.

180–188

This is useless.

This revision is now accepted and ready to land.Apr 29 2021, 8:20 PM
mib updated this revision to Diff 341758.Apr 29 2021, 8:37 PM
mib marked 2 inline comments as done.

Addressed @JDevlieghere comments.

teemperor accepted this revision.Apr 30 2021, 3:27 AM

IIRC they were #ifdef's out because of memory concerns. Did you have a chance to benchmark this quickly (e.g., trying to attach to a debug Clang and see how much it increases memory)

Otherwise this LGTM.

FWIW, we also need this for the SourceLocation in Clang Decls feature I was working on some time ago.

I ran a benchmark as you suggested, attaching to a debug clang build, checking lldb's memory before starting the process (650MB), setting a breakpoint to main then launching the process (~1GB), and after the process stops, I tried evaluating the following expression : (lldb) expr std::string("This is a string.", 4) (4.83GB) and the memory usage matched in both scenarios.

Thanks. I anyway realized we don't actually increase the memory consumption with that member as it just occupies what was previously tail padding (we actually still have padding left with this uint16_t member). I probably should have checked that before asking for benchmarks :)

LGTM, let's ship it.

lldb/include/lldb/Core/Declaration.h
180–188

I personally learned C++ by reading LLDB's comments such as "Destructor", "Constructor" and "member variables"

This revision was landed with ongoing or failed builds.May 4 2021, 9:35 AM
This revision was automatically updated to reflect the committed changes.