This is an archive of the discontinued LLVM Phabricator instance.

[lldb][gnustep][PDB] Recognize ObjC classes and start definition only once the complete type is requested
Needs ReviewPublic

Authored by sgraenitz on Mar 17 2023, 5:58 AM.

Details

Summary

This patch allows the PDB parser to recognize UDT symbols as ObjCInterfaceDecls and delay the definition process until we resolve the complete compiler type. This corresponds to the approach in the DWARF parser: https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L1869-L1871

In order to cache forward declarations for both, CXXRecordDecl and ObjCInterfaceDecl, the map type is changed to store NamedDecls now (first common base). The test shows that we get the names of type and members for a simple ObjC class now.

Diff Detail

Event Timeline

sgraenitz created this revision.Mar 17 2023, 5:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 5:58 AM
sgraenitz requested review of this revision.Mar 17 2023, 5:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 5:58 AM

In order to run the test yourself locally, you also need to apply D146058, D146154 and D146221 first (right now they are still in review).

lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
414

I am not an ObjC expert, but from those who are I know that in practice this should holds for all common scenarios. So far it works reliably.

Right now I'd like to avoid patching the PDB contents from the compiler side. Would be great to see how far we get without. If there's a better way to do the same based on current PDB info, please let me know.

lldb/test/Shell/Expr/objc-gnustep-print-pdb.m
1

This test is supposed to demonstrate what works with this patch. I will remove it once we match the features in the Linux/DWARF baseline proposed in: D146154 test objc-gnustep-print.m