This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add support for DW_AT_calling_convention to the DWARF parser
ClosedPublic

Authored by teemperor on Aug 24 2021, 7:32 AM.

Details

Summary

This adds support for parsing DW_AT_calling_convention in the DWARF parser.

The generic DWARF parsing code already support extracting this attribute from A DIE and
TypeSystemClang already offers a parameter to add a calling convention to
a function type (as the PDB parser supports calling convention parsing), so this patch just converts
the DWARF enum value to the Clang enum value and adds a few tests.

There are two tests in this patch.:

  • A unit test for the added DWARF parsing code that should run on all platforms.
  • An API tests that covers the whole expression evaluation machinery by trying to call functions with non-standard calling conventions. The specific subtests are target specific as some calling conventions only work on e.g. win32 (or, if they work on other platforms they only really have observable differences on a specific target). The tests are also highly compiler-specific, so if GCC or Clang tell us that they don't support a specific calling convention then we just skip the test.

Note that some calling conventions are supported by Clang but aren't implemented in LLVM (e.g. pascal), so there we just test that if this ever gets implemented in LLVM that LLDB works too. There are also some more tricky/obscure conventions that are left out such as the different swift* conventions, some planned Obj-C conventions (Preserve*), AAPCS* conventions (as the DWARF->Clang conversion is ambiguous for AAPCS and APPCS-VFP) and conventions only used for OpenCL etc.

Diff Detail

Event Timeline

teemperor created this revision.Aug 24 2021, 7:32 AM
teemperor requested review of this revision.Aug 24 2021, 7:32 AM
aprantl accepted this revision.Aug 27 2021, 12:41 PM

Thanks, this looks good!

This revision is now accepted and ready to land.Aug 27 2021, 12:41 PM
This revision was landed with ongoing or failed builds.Oct 11 2021, 4:44 AM
This revision was automatically updated to reflect the committed changes.