Skip to content

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Nov 1, 2024

Naive implementation of all the parts of following RFC:
https://discourse.llvm.org/t/rfc-lldb-handling-abi-tagged-constructors-destructors-in-expression-evaluator/82816

Main changes:

  1. Instead of relying on linkage names to resolve function symbols, encode the exact function DIE and module in the AsmLabelAttr. Currently we just put the Module pointer value into the label, which may be not sufficient if those could disappear under the expression evaluator's feet.
  2. Teach the LLDB symbol resolver about (1)
  3. Introduce new Clang attribute to allow specifying multiple asm labels for ctors/dtors (one for each variant)
  4. Attach the new attribute in (3), where the mangled names use the format from (1), to function decls that LLDB creates (this prototype doesn't actually do this for methods yet, just free-functions and constructors). To determine which variant a DIE corresponds to we add a new API to the ItaniumPartialDemangler (though could be made into a DWARF attribute for quicker determination).

Example constructor decl would look like the following:

| `-CXXConstructorDecl 0x246e6f8 <<invalid sloc>> <invalid sloc> Bar 'void ()'
|   `-StructorMangledNamesAttr 0x246e7c0 <<invalid sloc>> Implicit 2:$__lldb_func_0x00000000014B6560:257 1:$__lldb_func_0x00000000014B6560:294

D->getAttr<StructorMangledNamesAttr>()) {
CXXConstructorDecl const *Ctor = dyn_cast<CXXConstructorDecl>(D);
CXXDestructorDecl const *Dtor = dyn_cast<CXXDestructorDecl>(D);
assert(Ctor || Dtor);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this won't look like this. But shows where I intend the mangler changes to go for the new attribute.

@Michael137 Michael137 force-pushed the lldb/abi-tag-structors-prototype branch from 6b3b5ef to 7f18d96 Compare November 1, 2024 11:26
Implements all the parts of following RFC:
https://discourse.llvm.org/t/rfc-lldb-handling-abi-tagged-constructors-destructors-in-expression-evaluator/82816

Main changes:
1. Instead of relying on linkage names to resolve function symbols,
   encode the exact function DIE and module in the `AsmLabelAttr`
2. Teach the LLDB symbol resolve about (1)
3. Introduce new Clang attribute to allow specifying multiple `asm`
   labels for ctors/dtors (one for each variant)
4. Attach the new attribute in (3), where the mangled names use the
   format from (1). To determine which variant a DIE corresponds to we
add a new API to the `ItaniumPartialDemangler` (though could be made
into a DWARF attribute for quicker determination).
@Michael137 Michael137 force-pushed the lldb/abi-tag-structors-prototype branch from 7f18d96 to 9337e17 Compare November 1, 2024 11:28
@Michael137
Copy link
Member Author

Landed in #148877

@Michael137 Michael137 closed this Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant