This is an archive of the discontinued LLVM Phabricator instance.

[lldb][DebugNamesDWARF] Also use mangled name when matching regex
ClosedPublic

Authored by fdeazeve on Jul 6 2023, 8:21 AM.

Details

Summary

When LLDB queries the debug names index with a regex, we should use the
Mangled class wrapper, which attempts to match regex first against the mangled
name and then against the demangled name. This is what is done for the Apple
index as well.

This fixes test/API/lang/cpp/class_static/main.cpp when compiled with DWARF 5.

Diff Detail

Event Timeline

fdeazeve created this revision.Jul 6 2023, 8:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 8:21 AM
Herald added a subscriber: arphaman. · View Herald Transcript
fdeazeve requested review of this revision.Jul 6 2023, 8:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2023, 8:21 AM
mib accepted this revision as: mib.Jul 6 2023, 12:18 PM
This revision is now accepted and ready to land.Jul 6 2023, 12:18 PM

Is the reason this is necessary because the apple accelerator tables would emit an entry for both the mangled and demangled name?

Is the reason this is necessary because the apple accelerator tables would emit an entry for both the mangled and demangled name?

Not quite. The name inside the accelerator table (Apple or DWARF 5) is always mangled.
So if we want a user to be able to do frame var --regex A::, the only way this can possibly work is if we demangle the table entry prior to matching against the regex. This is what the test mentioned in the commit message is testing.

In the implementation of AppleDWARFIndex.cpp, we also do this.

JDevlieghere accepted this revision.Jul 6 2023, 1:18 PM

Is the reason this is necessary because the apple accelerator tables would emit an entry for both the mangled and demangled name?

Not quite. The name inside the accelerator table (Apple or DWARF 5) is always mangled.
So if we want a user to be able to do frame var --regex A::, the only way this can possibly work is if we demangle the table entry prior to matching against the regex. This is what the test mentioned in the commit message is testing.

In the implementation of AppleDWARFIndex.cpp, we also do this.

Cool, might be worth mentioning that in the commit message. LGMT.

Cool, might be worth mentioning that in the commit message. LGMT.

Agreed! I'll update it prior to merging