Skip to content

Commit bc20919

Browse files
authored
Merge pull request #7667 from augusto2112/cp-GetTypeForDIE
Cherry pick GetTypeForDIE changes
2 parents 57d6673 + 3eaea18 commit bc20919

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DWARFASTParser.h"
1010
#include "DWARFAttribute.h"
1111
#include "DWARFDIE.h"
12+
#include "SymbolFileDWARF.h"
1213

1314
#include "lldb/Core/ValueObject.h"
1415
#include "lldb/Symbol/SymbolFile.h"
@@ -99,6 +100,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
99100
return array_info;
100101
}
101102

103+
Type *DWARFASTParser::GetTypeForDIE(const DWARFDIE &die) {
104+
if (!die)
105+
return nullptr;
106+
107+
SymbolFileDWARF *dwarf = die.GetDWARF();
108+
if (!dwarf)
109+
return nullptr;
110+
111+
DWARFAttributes attributes = die.GetAttributes();
112+
if (attributes.Size() == 0)
113+
return nullptr;
114+
115+
DWARFFormValue type_die_form;
116+
for (size_t i = 0; i < attributes.Size(); ++i) {
117+
dw_attr_t attr = attributes.AttributeAtIndex(i);
118+
DWARFFormValue form_value;
119+
120+
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
121+
return dwarf->ResolveTypeUID(form_value.Reference(), true);
122+
}
123+
124+
return nullptr;
125+
}
126+
102127
AccessType
103128
DWARFASTParser::GetAccessTypeFromDWARF(uint32_t dwarf_accessibility) {
104129
switch (dwarf_accessibility) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class DWARFASTParser {
6666
ParseChildArrayInfo(const DWARFDIE &parent_die,
6767
const lldb_private::ExecutionContext *exe_ctx = nullptr);
6868

69+
lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
70+
6971
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
7072

7173
Kind GetKind() const { return m_kind; }

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,30 +3182,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
31823182
return arg_idx;
31833183
}
31843184

3185-
Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
3186-
if (!die)
3187-
return nullptr;
3188-
3189-
SymbolFileDWARF *dwarf = die.GetDWARF();
3190-
if (!dwarf)
3191-
return nullptr;
3192-
3193-
DWARFAttributes attributes = die.GetAttributes();
3194-
if (attributes.Size() == 0)
3195-
return nullptr;
3196-
3197-
DWARFFormValue type_die_form;
3198-
for (size_t i = 0; i < attributes.Size(); ++i) {
3199-
dw_attr_t attr = attributes.AttributeAtIndex(i);
3200-
DWARFFormValue form_value;
3201-
3202-
if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
3203-
return dwarf->ResolveTypeUID(form_value.Reference(), true);
3204-
}
3205-
3206-
return nullptr;
3207-
}
3208-
32093185
clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
32103186
if (!die)
32113187
return nullptr;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ class DWARFASTParserClang : public DWARFASTParser {
180180
const DWARFDIE &die,
181181
ParsedDWARFTypeAttributes &attrs);
182182

183-
lldb_private::Type *GetTypeForDIE(const DWARFDIE &die);
184-
185183
clang::Decl *GetClangDeclForDIE(const DWARFDIE &die);
186184

187185
clang::DeclContext *GetClangDeclContextForDIE(const DWARFDIE &die);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon {
8080
friend class DebugMapModule;
8181
friend class DWARFCompileUnit;
8282
friend class DWARFDIE;
83+
friend class DWARFASTParser;
8384
friend class DWARFASTParserClang;
8485
friend class DWARFASTParserSwift;
8586

0 commit comments

Comments
 (0)