Skip to content

Commit 6f1192a

Browse files
committed
[lldb] Add support for Derived types
1 parent 78f464e commit 6f1192a

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserD.cpp

+43-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "DWARFASTParserD.h"
1010
#include "DWARFASTParserClang.h"
11+
#include "DWARFASTParser.h"
1112
#include "DWARFDebugInfo.h"
1213
#include "DWARFDeclContext.h"
1314
#include "DWARFDefines.h"
@@ -69,6 +70,8 @@ TypeSP DWARFASTParserD::ParseTypeFromDWARF(const SymbolContext &sc,
6970
type_sp = ParseSimpleType(sc, die, attrs);
7071
break;
7172
case DW_TAG_typedef:
73+
type_sp = ParseDerivedType(sc, die, attrs);
74+
break;
7275
case DW_TAG_pointer_type:
7376
case DW_TAG_reference_type:
7477
case DW_TAG_rvalue_reference_type:
@@ -94,22 +97,52 @@ DWARFASTParserD::ParseSimpleType(const lldb_private::SymbolContext &sc,
9497
{
9598
SymbolFileDWARF *dwarf = die.GetDWARF();
9699
CompilerType cp_type;
97-
Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
98-
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
99100

101+
cp_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
102+
attrs.name.GetStringRef(),
103+
attrs.encoding, attrs.byte_size.getValueOr(0) * 8);
104+
105+
return std::make_shared<Type>(
106+
die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
107+
dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID, &attrs.decl,
108+
cp_type, Type::ResolveState::Full);
109+
}
110+
111+
112+
TypeSP
113+
DWARFASTParserD::ParseTypeFromModule(const lldb_private::SymbolContext &sc,
114+
const DWARFDIE &die) {
115+
return TypeSP();
116+
}
117+
118+
lldb::TypeSP
119+
DWARFASTParserD::ParseDerivedType(const lldb_private::SymbolContext &sc,
120+
const DWARFDIE &die,
121+
ParsedDWARFTypeAttributes &attrs) {
122+
SymbolFileDWARF *dwarf = die.GetDWARF();
100123
const dw_tag_t tag = die.Tag();
101-
switch(tag)
102-
{
103-
case DW_TAG_base_type:
104-
cp_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
105-
attrs.name.GetStringRef(),
106-
attrs.encoding, attrs.byte_size.getValueOr(0) * 8);
124+
CompilerType cp_type;
125+
Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
126+
127+
switch(tag) {
128+
case DW_TAG_typedef: {
129+
const DWARFDIE encoding_die = attrs.type.Reference();
130+
if (encoding_die &&
131+
encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
132+
TypeSP type_sp = ParseTypeFromModule(sc, die);
133+
if (type_sp)
134+
return type_sp;
135+
}
136+
137+
break;
138+
}
139+
default:
107140
break;
108-
default: break;
109141
}
142+
110143
return std::make_shared<Type>(
111144
die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
112-
dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
145+
dwarf->GetUID(attrs.type.Reference()), GetEncodingFromDWARFTypeTag(tag), &attrs.decl,
113146
cp_type, resolve_state);
114147
}
115148

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserD.h

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class DWARFASTParserD : public DWARFASTParser {
5454
const DWARFDIE &die,
5555
ParsedDWARFTypeAttributes &attrs);
5656

57+
lldb::TypeSP ParseDerivedType(const lldb_private::SymbolContext &sc,
58+
const DWARFDIE &die,
59+
ParsedDWARFTypeAttributes &attrs);
60+
lldb::TypeSP ParseTypeFromModule(const lldb_private::SymbolContext &sc,
61+
const DWARFDIE &die);
62+
5763
lldb_private::TypeSystemD &m_ast;
5864
};
5965

0 commit comments

Comments
 (0)