This is an archive of the discontinued LLVM Phabricator instance.

[lldb][gnustep][PDB] Parse ObjC base classes and recognize NSObject type
Needs ReviewPublic

Authored by sgraenitz on Mar 17 2023, 7:17 AM.

Details

Summary

While C++ base classes are registered with CreateBaseClassSpecifier(), we have to use SetObjCSuperClass() for ObjC. The isa member of NSObject is a zero-length UDT. Special handling for ObjC id type will be added in one of the next patches.

Diff Detail

Event Timeline

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

I don't know anything about Objective C internals, perhaps you can provide some reference that talks about this?

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

Could you use label in the source so you don't have to update this line number each each time?

I forget if labels are included in the debug info. In the python tests we have this more heavyweight thing that searches for a particular comment to find the line.

I don't know anything about Objective C internals, perhaps you can provide some reference that talks about this?

Honestly, I am mostly looking what the DWARF parser does and try to mimic it in PDB. I haven't done much research for a formal reference. My impression is that the implementation is the reference here. (Please correct me if I am wrong!)

Yeah, let's wait and see if I get feedback from ObjC and PDB maintainers.

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

Maybe this is ok without a dedicated language type check? IIUC the worst thing that could happen, in case we really have zero-length types with such names in C++ code, is a small performance drop.

BTW the reference for this seems to be: https://github.com/llvm/llvm-project/blob/release/16.x/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L709-L710 😄

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

It's a minor effort on my side to update the line number and it's solid. We cannot break on ok, since the function name doesn't get parsed with a correct basename yet. Main would work, but it doesn't seem more readable:

-o "b main" -o "n" -o "n"

In the python tests we have this more heavyweight thing that searches for a particular comment to find the line.

If possible I'd like to stay away from the Python tests. I don't think we need their advanced features. lit is a lot easier for me (and more widespread in LLVM).

68

With this change we get base class and the member offsets right (all are zero-initialized).

compnerd added inline comments.Apr 25 2023, 8:11 AM
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
399

Does it make sense to drop a note here that the 0-length UDT is used as a marker for the NSObject root? Although, shouldn't NSObject's isa be NSObject? Or does GNUStep not do that?