-
Notifications
You must be signed in to change notification settings - Fork 349
Support Swift.Array in Embedded Swift #11486
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
base: swift/release/6.2.1
Are you sure you want to change the base?
Support Swift.Array in Embedded Swift #11486
Conversation
c1392fc
to
fb8e256
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp
Show resolved
Hide resolved
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwiftDescriptorFinder.cpp
Outdated
Show resolved
Hide resolved
} | ||
if (!parent_die) | ||
return {}; | ||
for (DWARFDIE child_die : parent_die.children()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that you need this because we might not have debug info for a typealias declared inside a substituted generic type.
But instead of finding the parent and looking for the typealias as one of it's children, would it be possible instead to:
- Map the generic typealias out of context first (we'd need to add a new function for this).
- Look up the mapped out typealias directly.
So if we're looking for the typealias [Int]._Buffer (mangled name $eSa7_BufferaySi_GD
), we'd first map that out of context [τ_0_0]._Buffer (mangled name $eSa7_Bufferayx_GD
), and FindTypes should be able to find this in DWARF directly.
This would support typealias declared at greater depths than 1.
We could do it as a follow up patch though since this one is already quite big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map the generic typealias out of context first (we'd need to add a new function for this).
Do we have enough info to do this? We know what the linearization of the substitutions is, but we don't know the depth of any of the parameters. Is that something we could reconstruct from what we have in DWARF today?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I'm looking at the debug info for this program:
struct A<T> {
struct B<U, V> {
struct C<W> {
let t: T
let u: U
let v: V
let w: W
}
}
}
func f() {
let c = A<Int>.B<Double, Float>.C<String>(t: 4, u: 4.2, v: 4.2, w: "Hi")
}
f()
The specification of C
for c
is:
0x00000736: DW_TAG_structure_type
DW_AT_specification (0x000006f4 "$e1a1AV1BV1CVyx_qd__qd_0__qd0__GD")
0x0000073f: DW_TAG_member
DW_AT_type (0x00000746 "a::$e1a1AVyxGD::$e1a1AV1BVyx_qd__qd_0_GD::$e1a1AV1BV1CVySi_SdSf_SSGD<Swift::String, Swift::Double, Swift::Float, Swift::Int>")
(This debug info looks pretty odd and very redundant, we should change what the compiler emits to cut down on the useless information).
$e1a1AV1BV1CVySi_SdSf_SSGD
demangles to:
➜ lldb-macosx-arm64 xcrun swift-demangle e1a1AV1BV1CVySi_SdSf_SSGD
$e1a1AV1BV1CVySi_SdSf_SSGD ---> a.A<Swift.Int>.B<Swift.Double, Swift.Float>.C<Swift.String>
The debug info for C (unsubstituted is):
0x000006f4: DW_TAG_structure_type
DW_AT_name ("C")
DW_AT_linkage_name ("$e1a1AV1BV1CVyx_qd__qd_0__qd0__GD")
$e1a1AV1BV1CVyx_qd__qd_0__qd0__GD
demangles to:
➜ lldb-macosx-arm64 xcrun swift-demangle e1a1AV1BV1CVyx_qd__qd_0__qd0__GD
$e1a1AV1BV1CVyx_qd__qd_0__qd0__GD ---> a.A<A>.B<A1, B1>.C<A2>
So it should be doable.
fb8e256
to
392248a
Compare
…d Swift In order to format a Swift.Array in Swift it is necessary to properly resolve type aliases to generic types from DWARF. This patch adds support for properly generic type aliases in and out of context when reconstructing them from DWARF. rdar://159429896
@swift-ci test |
392248a
to
f7b9123
Compare
@swift-ci test |
@swift-ci test |
No description provided.