Skip to content

[cherry-pick][stable/20230725] [lldb][ClangASTImporter] Import record layouts from origin if available #8306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Michael137
Copy link

Layout information for a record gets stored in the ClangASTImporter
associated with the DWARFASTParserClang that originally parsed the
record. LLDB sometimes moves clang types from one AST to another (in the
reproducer the origin AST was a precompiled-header and the destination
was the AST backing the executable). When clang then asks LLDB to
layoutRecordType, it will do so with the help of the
ClangASTImporter the type is associated with. If the type's origin is
actually in a different LLDB module (and thus a different
DWARFASTParserClang was used to set its layout info), we won't find
the layout info in our local ClangASTImporter.

In the reproducer this meant we would drop the alignment info of the
origin type and misread a variable's contents with frame var and
expr.

There is logic in ClangASTSource::layoutRecordType to import an
origin's layout info. This patch re-uses that infrastructure to import
an origin's layout from one ClangASTImporter instance to another.

rdar://123274144
(cherry picked from commit 07ffb7e)

llvm#83291)

This patch moves the logic for copying the layout info of a
`RecordDecl`s origin into a target AST.

A follow-up patch re-uses the logic from within the `ClangASTImporter`,
so the natural choice was to move it there.

(cherry picked from commit 8c10032)
…le (llvm#83295)

Layout information for a record gets stored in the `ClangASTImporter`
associated with the `DWARFASTParserClang` that originally parsed the
record. LLDB sometimes moves clang types from one AST to another (in the
reproducer the origin AST was a precompiled-header and the destination
was the AST backing the executable). When clang then asks LLDB to
`layoutRecordType`, it will do so with the help of the
`ClangASTImporter` the type is associated with. If the type's origin is
actually in a different LLDB module (and thus a different
`DWARFASTParserClang` was used to set its layout info), we won't find
the layout info in our local `ClangASTImporter`.

In the reproducer this meant we would drop the alignment info of the
origin type and misread a variable's contents with `frame var` and
`expr`.

There is logic in `ClangASTSource::layoutRecordType` to import an
origin's layout info. This patch re-uses that infrastructure to import
an origin's layout from one `ClangASTImporter` instance to another.

rdar://123274144
(cherry picked from commit 07ffb7e)
@Michael137 Michael137 changed the title [lldb][ClangASTImporter] Import record layouts from origin if available [cherry-pick][stable/20230725] [lldb][ClangASTImporter] Import record layouts from origin if available Feb 29, 2024
@Michael137
Copy link
Author

@swift-ci test

@Michael137 Michael137 merged commit aa5a99e into swiftlang:stable/20230725 Mar 1, 2024
@Michael137 Michael137 deleted the bugfix/lldb-origin-layout-tracking-to-20230725 branch March 1, 2024 08:08
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Mar 1, 2024
The return statement was dropped when resolving merge conflicts
in swiftlang#8306.
Michael137 added a commit that referenced this pull request Mar 1, 2024
…acking-mismerge-fix-to-20230725

[lldb][ClangASTImporter] Fix mismerge in LayoutRecordType

The return statement was dropped when resolving merge conflicts in #8306.
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