Skip to content
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

[lldb][NFC] Move DWARFASTParserClang::GetTypeForDIE to DWARFASTParser #69764

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DWARFASTParser.h"
#include "DWARFAttribute.h"
#include "DWARFDIE.h"
#include "SymbolFileDWARF.h"

#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/SymbolFile.h"
Expand Down Expand Up @@ -100,6 +101,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die,
return array_info;
}

Type *DWARFASTParser::GetTypeForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;

SymbolFileDWARF *dwarf = die.GetDWARF();
if (!dwarf)
return nullptr;

DWARFAttributes attributes = die.GetAttributes();
if (attributes.Size() == 0)
return nullptr;

DWARFFormValue type_die_form;
for (size_t i = 0; i < attributes.Size(); ++i) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;

if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
return dwarf->ResolveTypeUID(form_value.Reference(), true);
}

return nullptr;
}

AccessType
DWARFASTParser::GetAccessTypeFromDWARF(uint32_t dwarf_accessibility) {
switch (dwarf_accessibility) {
Expand Down
3 changes: 3 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class DWARFASTParser {
ParseChildArrayInfo(const DWARFDIE &parent_die,
const ExecutionContext *exe_ctx = nullptr);

lldb_private::Type *
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
};
} // namespace dwarf
Expand Down
24 changes: 0 additions & 24 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3292,30 +3292,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
return arg_idx;
}

Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;

SymbolFileDWARF *dwarf = die.GetDWARF();
if (!dwarf)
return nullptr;

DWARFAttributes attributes = die.GetAttributes();
if (attributes.Size() == 0)
return nullptr;

DWARFFormValue type_die_form;
for (size_t i = 0; i < attributes.Size(); ++i) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;

if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, form_value))
return dwarf->ResolveTypeUID(form_value.Reference(), true);
}

return nullptr;
}

clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
if (!die)
return nullptr;
Expand Down
3 changes: 0 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ class DWARFASTParserClang : public lldb_private::plugin::dwarf::DWARFASTParser {
const lldb_private::plugin::dwarf::DWARFDIE &die,
ParsedDWARFTypeAttributes &attrs);

lldb_private::Type *
GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

clang::Decl *
GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);

Expand Down