Skip to content

Conversation

adrian-prantl
Copy link

No description provided.

@adrian-prantl adrian-prantl requested a review from a team as a code owner September 24, 2025 00:43
@adrian-prantl adrian-prantl force-pushed the 159429896-6.2 branch 2 times, most recently from c1392fc to fb8e256 Compare September 26, 2025 21:07
Copy link

@augusto2112 augusto2112 left a 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!

}
if (!parent_die)
return {};
for (DWARFDIE child_die : parent_die.children()) {

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.

Copy link
Author

@adrian-prantl adrian-prantl Sep 27, 2025

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?

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.

@adrian-prantl adrian-prantl changed the title [WIP] Support Swift.Array in Embedded Swift Support Swift.Array in Embedded Swift Sep 29, 2025
@adrian-prantl
Copy link
Author

@swift-ci test

@adrian-prantl
Copy link
Author

@swift-ci test

1 similar comment
@adrian-prantl
Copy link
Author

@swift-ci test

…Embedded 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
@adrian-prantl
Copy link
Author

@swift-ci test

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.

2 participants