@@ -77,6 +77,7 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
77
77
78
78
if (num_attributes > 0 ) {
79
79
uint32_t i;
80
+ bool has_specification_of = false ;
80
81
for (i = 0 ; i < num_attributes; ++i) {
81
82
const dw_attr_t attr = attributes.AttributeAtIndex (i);
82
83
DWARFFormValue form_value;
@@ -95,9 +96,38 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
95
96
case DW_AT_name:
96
97
name.SetCString (form_value.AsCString ());
97
98
break ;
99
+ case DW_AT_specification:
100
+ has_specification_of = true ;
101
+ break ;
98
102
case DW_AT_linkage_name:
99
- case DW_AT_MIPS_linkage_name:
103
+ case DW_AT_MIPS_linkage_name: {
100
104
mangled_name.SetCString (form_value.AsCString ());
105
+ auto HasSpecificationOf = [&](){
106
+ if (has_specification_of)
107
+ return true ;
108
+ for (uint32_t j = i+1 ; j < num_attributes; ++j)
109
+ if (attributes.AttributeAtIndex (j) == DW_AT_specification)
110
+ return true ;
111
+ return false ;
112
+ };
113
+ // Is this a sized container with a specification? If yes,
114
+ // the linkage name we just got is the one of the
115
+ // specification die, which would be the unsubsituted
116
+ // type. The child contains the linkage name of the
117
+ // specialized type. We should define appropriate DWARF for
118
+ // this instead of relying on this heuristic.
119
+ if (die.Tag () == DW_TAG_structure_type && die.HasChildren () &&
120
+ HasSpecificationOf ()) {
121
+ DWARFDIE member_die = die.GetFirstChild ();
122
+ if (member_die.Tag () != DW_TAG_member || member_die.GetName ())
123
+ break ;
124
+ if (DWARFDIE inner_type_die =
125
+ member_die.GetAttributeValueAsReferenceDIE (DW_AT_type))
126
+ if (const char *s = inner_type_die.GetAttributeValueAsString (
127
+ DW_AT_name, nullptr ))
128
+ mangled_name.SetCString (s);
129
+ }
130
+ }
101
131
break ;
102
132
case DW_AT_byte_size:
103
133
dwarf_byte_size = form_value.Unsigned ();
@@ -106,7 +136,7 @@ lldb::TypeSP DWARFASTParserSwift::ParseTypeFromDWARF(const SymbolContext &sc,
106
136
if (die.Tag () == DW_TAG_const_type)
107
137
// This is how let bindings are represented. This doesn't
108
138
// change the underlying Swift type.
109
- return ParseTypeFromDWARF (sc, die. GetReferencedDIE (attr ),
139
+ return ParseTypeFromDWARF (sc, form_value. Reference ( ),
110
140
type_is_new_ptr);
111
141
break ;
112
142
default :
0 commit comments