This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][DWARF] Set MSInheritanceAttr for record decl when it's using Microsoft compatible ABI.
AcceptedPublic

Authored by zequanwu on Aug 1 2022, 2:27 PM.

Details

Reviewers
rnk
labath
shafik
Summary

This is needed for object files with MS ABI and debug info in Dwarf.
MSInheritanceAttr is required for record decls under MS ABI.

Fixes #56458

Diff Detail

Event Timeline

zequanwu created this revision.Aug 1 2022, 2:27 PM
Herald added a project: Restricted Project. · View Herald Transcript
zequanwu requested review of this revision.Aug 1 2022, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2022, 2:27 PM

This looks sensible to me, although it might be good if someone else more familiar with this code has a look too.

labath accepted this revision.Aug 3 2022, 6:06 AM

Makes sense to me. For my education, what is the effect of not providing a specific inheritance attribute, like it's being done in the pdb code (which, I presume, is not possible because that information is not encoded in dwarf)?

This revision is now accepted and ready to land.Aug 3 2022, 6:06 AM
rnk added inline comments.Aug 3 2022, 10:30 AM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

I'm concerned that this isn't really the right fix. Changing the inheritance model changes the size of the member pointer representation, so the consequences of getting the wrong one could affect expression evaluation results. Zequan suggested guessing the inheritance model from the class definition, but we really ought to write down the inheritance model in the DWARF when using the MS ABI. This probably needs its own DWARF attribute.

mstorsjo added inline comments.Aug 3 2022, 11:26 AM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

FWIW, there’s two use cases at play here:

  1. The executable actually is using the itanium ABI, but is being (mis)interpreted with the MSVC ABI. When this happens, we currently crash, which is a terrible user experience. In this case, there’s probably no good solution (we can’t really get it right at this point) - but pretty much anything is better than crashing. Before D127048, we always interpreted everything with the MSVC C++ ABI; now we probably are getting it right in a majority of cases at least.
  1. People intentionally using dwarf debug into with MSVC ABI. Not very common, but something that some people do use, as far as I know. Here we at least have a chance of getting right.
rnk added inline comments.Aug 5 2022, 2:15 PM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

I see, I thought we already knew we were in use case 2 not 1. Having this as a workaround to not crash seems fine, but we really ought to warn when LLDB encounters these conditions:

  1. MS C++ ABI is in use
  2. DWARF is in use
  3. A C++ source file is in use

Using DWARF for C code in the MS ABI model is fine, no need to warn in that case.

mstorsjo added inline comments.Aug 5 2022, 9:59 PM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

Some kind of warning would be great, yes. Is MS ABI C++ in dwarf essentially broken by definition (unless we’d extend our dwarf generation)?

mstorsjo added inline comments.Aug 18 2022, 4:43 AM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

Ping @zequanwu - do you want to follow up on this one?

zequanwu added inline comments.Aug 18 2022, 10:13 AM
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
1754

Hi, I don't think I have time to follow up on this recently.