forked from OSchip/llvm-project
[lldb] Move non-DWARF code: DWARFUnit -> SymbolFileDWARF
This patchset is removing non-DWARF code from DWARFUnit for better future merge with LLVM DWARF as discussed with @labath. Differential revision: https://reviews.llvm.org/D70646
This commit is contained in:
parent
49e424e08e
commit
789beeeca3
|
@ -155,7 +155,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
|
||||||
|
|
||||||
// The type in the Clang module must have the same language as the current CU.
|
// The type in the Clang module must have the same language as the current CU.
|
||||||
LanguageSet languages;
|
LanguageSet languages;
|
||||||
languages.Insert(die.GetCU()->GetLanguageType());
|
languages.Insert(SymbolFileDWARF::GetLanguage(*die.GetCU()));
|
||||||
llvm::DenseSet<SymbolFile *> searched_symbol_files;
|
llvm::DenseSet<SymbolFile *> searched_symbol_files;
|
||||||
clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
|
clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
|
||||||
searched_symbol_files, pcm_types);
|
searched_symbol_files, pcm_types);
|
||||||
|
@ -504,7 +504,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
|
||||||
DWARF_LOG_LOOKUPS));
|
DWARF_LOG_LOOKUPS));
|
||||||
SymbolFileDWARF *dwarf = die.GetDWARF();
|
SymbolFileDWARF *dwarf = die.GetDWARF();
|
||||||
const dw_tag_t tag = die.Tag();
|
const dw_tag_t tag = die.Tag();
|
||||||
LanguageType cu_language = die.GetLanguage();
|
LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
|
||||||
Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
|
Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
|
||||||
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
|
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
|
||||||
TypeSP type_sp;
|
TypeSP type_sp;
|
||||||
|
@ -726,8 +726,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
|
||||||
if (type_sp)
|
if (type_sp)
|
||||||
return type_sp;
|
return type_sp;
|
||||||
|
|
||||||
DWARFDeclContext die_decl_ctx;
|
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
die.GetDWARFDeclContext(die_decl_ctx);
|
|
||||||
|
|
||||||
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
|
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
|
||||||
|
|
||||||
|
@ -1383,7 +1382,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
|
||||||
CompilerType clang_type;
|
CompilerType clang_type;
|
||||||
const dw_tag_t tag = die.Tag();
|
const dw_tag_t tag = die.Tag();
|
||||||
SymbolFileDWARF *dwarf = die.GetDWARF();
|
SymbolFileDWARF *dwarf = die.GetDWARF();
|
||||||
LanguageType cu_language = die.GetLanguage();
|
LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
|
||||||
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_TYPE_COMPLETION |
|
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_TYPE_COMPLETION |
|
||||||
DWARF_LOG_LOOKUPS);
|
DWARF_LOG_LOOKUPS);
|
||||||
|
|
||||||
|
@ -1515,8 +1514,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
|
||||||
if (type_sp)
|
if (type_sp)
|
||||||
return type_sp;
|
return type_sp;
|
||||||
|
|
||||||
DWARFDeclContext die_decl_ctx;
|
DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
die.GetDWARFDeclContext(die_decl_ctx);
|
|
||||||
|
|
||||||
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
|
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
|
||||||
// type_name_const_str);
|
// type_name_const_str);
|
||||||
|
@ -2311,9 +2309,11 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
|
||||||
func_name.SetValue(ConstString(mangled), true);
|
func_name.SetValue(ConstString(mangled), true);
|
||||||
else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
|
else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
|
||||||
die.GetParent().Tag() == DW_TAG_partial_unit) &&
|
die.GetParent().Tag() == DW_TAG_partial_unit) &&
|
||||||
Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
|
Language::LanguageIsCPlusPlus(
|
||||||
!Language::LanguageIsObjC(die.GetLanguage()) && name &&
|
SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
|
||||||
strcmp(name, "main") != 0) {
|
!Language::LanguageIsObjC(
|
||||||
|
SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
|
||||||
|
name && strcmp(name, "main") != 0) {
|
||||||
// If the mangled name is not present in the DWARF, generate the
|
// If the mangled name is not present in the DWARF, generate the
|
||||||
// demangled name using the decl context. We skip if the function is
|
// demangled name using the decl context. We skip if the function is
|
||||||
// "main" as its name is never mangled.
|
// "main" as its name is never mangled.
|
||||||
|
@ -2323,10 +2323,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
|
||||||
unsigned type_quals = 0;
|
unsigned type_quals = 0;
|
||||||
std::vector<CompilerType> param_types;
|
std::vector<CompilerType> param_types;
|
||||||
std::vector<clang::ParmVarDecl *> param_decls;
|
std::vector<clang::ParmVarDecl *> param_decls;
|
||||||
DWARFDeclContext decl_ctx;
|
|
||||||
StreamString sstr;
|
StreamString sstr;
|
||||||
|
|
||||||
die.GetDWARFDeclContext(decl_ctx);
|
DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
|
||||||
sstr << decl_ctx.GetQualifiedName();
|
sstr << decl_ctx.GetQualifiedName();
|
||||||
|
|
||||||
clang::DeclContext *containing_decl_ctx =
|
clang::DeclContext *containing_decl_ctx =
|
||||||
|
@ -3274,7 +3273,7 @@ clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
|
||||||
SymbolFileDWARF *dwarf = die.GetDWARF();
|
SymbolFileDWARF *dwarf = die.GetDWARF();
|
||||||
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
|
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
|
||||||
if (imported_uid) {
|
if (imported_uid) {
|
||||||
CompilerDecl imported_decl = imported_uid.GetDecl();
|
CompilerDecl imported_decl = SymbolFileDWARF::GetDecl(imported_uid);
|
||||||
if (imported_decl) {
|
if (imported_decl) {
|
||||||
clang::DeclContext *decl_context =
|
clang::DeclContext *decl_context =
|
||||||
TypeSystemClang::DeclContextGetAsDeclContext(
|
TypeSystemClang::DeclContextGetAsDeclContext(
|
||||||
|
@ -3293,7 +3292,8 @@ clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
|
||||||
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
|
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
|
||||||
|
|
||||||
if (imported_uid) {
|
if (imported_uid) {
|
||||||
CompilerDeclContext imported_decl_ctx = imported_uid.GetDeclContext();
|
CompilerDeclContext imported_decl_ctx =
|
||||||
|
SymbolFileDWARF::GetDeclContext(imported_uid);
|
||||||
if (imported_decl_ctx) {
|
if (imported_decl_ctx) {
|
||||||
clang::DeclContext *decl_context =
|
clang::DeclContext *decl_context =
|
||||||
TypeSystemClang::DeclContextGetAsDeclContext(
|
TypeSystemClang::DeclContextGetAsDeclContext(
|
||||||
|
@ -3641,9 +3641,9 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
|
||||||
}
|
}
|
||||||
|
|
||||||
DWARFASTParserClang *src_dwarf_ast_parser =
|
DWARFASTParserClang *src_dwarf_ast_parser =
|
||||||
(DWARFASTParserClang *)src_die.GetDWARFParser();
|
(DWARFASTParserClang *)SymbolFileDWARF::GetDWARFParser(*src_die.GetCU());
|
||||||
DWARFASTParserClang *dst_dwarf_ast_parser =
|
DWARFASTParserClang *dst_dwarf_ast_parser =
|
||||||
(DWARFASTParserClang *)dst_die.GetDWARFParser();
|
(DWARFASTParserClang *)SymbolFileDWARF::GetDWARFParser(*dst_die.GetCU());
|
||||||
|
|
||||||
// Now do the work of linking the DeclContexts and Types.
|
// Now do the work of linking the DeclContexts and Types.
|
||||||
if (fast_path) {
|
if (fast_path) {
|
||||||
|
|
|
@ -74,13 +74,6 @@ const char *DWARFBaseDIE::GetName() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
lldb::LanguageType DWARFBaseDIE::GetLanguage() const {
|
|
||||||
if (IsValid())
|
|
||||||
return m_cu->GetLanguageType();
|
|
||||||
else
|
|
||||||
return lldb::eLanguageTypeUnknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
lldb::ModuleSP DWARFBaseDIE::GetModule() const {
|
lldb::ModuleSP DWARFBaseDIE::GetModule() const {
|
||||||
SymbolFileDWARF *dwarf = GetDWARF();
|
SymbolFileDWARF *dwarf = GetDWARF();
|
||||||
if (dwarf)
|
if (dwarf)
|
||||||
|
@ -103,24 +96,6 @@ SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Expected<lldb_private::TypeSystem &> DWARFBaseDIE::GetTypeSystem() const {
|
|
||||||
if (!m_cu)
|
|
||||||
return llvm::make_error<llvm::StringError>(
|
|
||||||
"Unable to get TypeSystem, no compilation unit available",
|
|
||||||
llvm::inconvertibleErrorCode());
|
|
||||||
return m_cu->GetTypeSystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
DWARFASTParser *DWARFBaseDIE::GetDWARFParser() const {
|
|
||||||
auto type_system_or_err = GetTypeSystem();
|
|
||||||
if (auto err = type_system_or_err.takeError()) {
|
|
||||||
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
|
||||||
std::move(err), "Unable to get DWARFASTParser");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return type_system_or_err->GetDWARFParser();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DWARFBaseDIE::HasChildren() const {
|
bool DWARFBaseDIE::HasChildren() const {
|
||||||
return m_die && m_die->HasChildren();
|
return m_die && m_die->HasChildren();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,6 @@ public:
|
||||||
|
|
||||||
llvm::Optional<DIERef> GetDIERef() const;
|
llvm::Optional<DIERef> GetDIERef() const;
|
||||||
|
|
||||||
llvm::Expected<lldb_private::TypeSystem &> GetTypeSystem() const;
|
|
||||||
|
|
||||||
DWARFASTParser *GetDWARFParser() const;
|
|
||||||
|
|
||||||
void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
|
void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
|
||||||
if (cu && die) {
|
if (cu && die) {
|
||||||
m_cu = cu;
|
m_cu = cu;
|
||||||
|
@ -98,8 +94,6 @@ public:
|
||||||
|
|
||||||
const char *GetName() const;
|
const char *GetName() const;
|
||||||
|
|
||||||
lldb::LanguageType GetLanguage() const;
|
|
||||||
|
|
||||||
lldb::ModuleSP GetModule() const;
|
lldb::ModuleSP GetModule() const;
|
||||||
|
|
||||||
// Getting attribute values from the DIE.
|
// Getting attribute values from the DIE.
|
||||||
|
|
|
@ -372,15 +372,6 @@ std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
|
|
||||||
if (IsValid()) {
|
|
||||||
dwarf_decl_ctx.SetLanguage(GetLanguage());
|
|
||||||
m_die->GetDWARFDeclContext(GetCU(), dwarf_decl_ctx);
|
|
||||||
} else {
|
|
||||||
dwarf_decl_ctx.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DWARFDIE::GetDeclContext(
|
void DWARFDIE::GetDeclContext(
|
||||||
llvm::SmallVectorImpl<lldb_private::CompilerContext> &context) const {
|
llvm::SmallVectorImpl<lldb_private::CompilerContext> &context) const {
|
||||||
const dw_tag_t tag = Tag();
|
const dw_tag_t tag = Tag();
|
||||||
|
@ -457,27 +448,3 @@ bool DWARFDIE::GetDIENamesAndRanges(
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompilerDecl DWARFDIE::GetDecl() const {
|
|
||||||
DWARFASTParser *dwarf_ast = GetDWARFParser();
|
|
||||||
if (dwarf_ast)
|
|
||||||
return dwarf_ast->GetDeclForUIDFromDWARF(*this);
|
|
||||||
else
|
|
||||||
return CompilerDecl();
|
|
||||||
}
|
|
||||||
|
|
||||||
CompilerDeclContext DWARFDIE::GetDeclContext() const {
|
|
||||||
DWARFASTParser *dwarf_ast = GetDWARFParser();
|
|
||||||
if (dwarf_ast)
|
|
||||||
return dwarf_ast->GetDeclContextForUIDFromDWARF(*this);
|
|
||||||
else
|
|
||||||
return CompilerDeclContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
CompilerDeclContext DWARFDIE::GetContainingDeclContext() const {
|
|
||||||
DWARFASTParser *dwarf_ast = GetDWARFParser();
|
|
||||||
if (dwarf_ast)
|
|
||||||
return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this);
|
|
||||||
else
|
|
||||||
return CompilerDeclContext();
|
|
||||||
}
|
|
||||||
|
|
|
@ -70,8 +70,6 @@ public:
|
||||||
// DeclContext related functions
|
// DeclContext related functions
|
||||||
std::vector<DWARFDIE> GetDeclContextDIEs() const;
|
std::vector<DWARFDIE> GetDeclContextDIEs() const;
|
||||||
|
|
||||||
void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
|
|
||||||
|
|
||||||
/// Return this DIE's decl context as it is needed to look up types
|
/// Return this DIE's decl context as it is needed to look up types
|
||||||
/// in Clang's -gmodules debug info format.
|
/// in Clang's -gmodules debug info format.
|
||||||
void GetDeclContext(
|
void GetDeclContext(
|
||||||
|
@ -90,14 +88,6 @@ public:
|
||||||
int &decl_line, int &decl_column, int &call_file,
|
int &decl_line, int &decl_column, int &call_file,
|
||||||
int &call_line, int &call_column,
|
int &call_line, int &call_column,
|
||||||
lldb_private::DWARFExpression *frame_base) const;
|
lldb_private::DWARFExpression *frame_base) const;
|
||||||
|
|
||||||
// CompilerDecl related functions
|
|
||||||
|
|
||||||
lldb_private::CompilerDecl GetDecl() const;
|
|
||||||
|
|
||||||
lldb_private::CompilerDeclContext GetDeclContext() const;
|
|
||||||
|
|
||||||
lldb_private::CompilerDeclContext GetContainingDeclContext() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SymbolFileDWARF_DWARFDIE_h_
|
#endif // SymbolFileDWARF_DWARFDIE_h_
|
||||||
|
|
|
@ -868,19 +868,20 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugInfoEntry::GetDWARFDeclContext(
|
DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const {
|
||||||
DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
|
DWARFDeclContext dwarf_decl_ctx;
|
||||||
const dw_tag_t tag = Tag();
|
const dw_tag_t tag = Tag();
|
||||||
if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
|
if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
|
||||||
dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
|
|
||||||
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
|
DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
|
||||||
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
|
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
|
||||||
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
|
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
|
||||||
parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
|
parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
|
||||||
parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
|
dwarf_decl_ctx = parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
|
||||||
parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
|
parent_decl_ctx_die.GetCU());
|
||||||
}
|
}
|
||||||
|
dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
|
||||||
}
|
}
|
||||||
|
return dwarf_decl_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWARFDIE
|
DWARFDIE
|
||||||
|
|
|
@ -158,8 +158,7 @@ public:
|
||||||
return HasChildren() ? this + 1 : nullptr;
|
return HasChildren() ? this + 1 : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetDWARFDeclContext(DWARFUnit *cu,
|
DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
|
||||||
DWARFDeclContext &dwarf_decl_ctx) const;
|
|
||||||
|
|
||||||
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
|
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
|
||||||
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
|
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
|
||||||
|
|
|
@ -514,10 +514,6 @@ lldb::ByteOrder DWARFUnit::GetByteOrder() const {
|
||||||
return m_dwarf.GetObjectFile()->GetByteOrder();
|
return m_dwarf.GetObjectFile()->GetByteOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Expected<TypeSystem &> DWARFUnit::GetTypeSystem() {
|
|
||||||
return m_dwarf.GetTypeSystemForLanguage(GetLanguageType());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
|
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
|
||||||
|
|
||||||
// Compare function DWARFDebugAranges::Range structures
|
// Compare function DWARFDebugAranges::Range structures
|
||||||
|
@ -655,28 +651,17 @@ uint32_t DWARFUnit::GetProducerVersionUpdate() {
|
||||||
ParseProducerInfo();
|
ParseProducerInfo();
|
||||||
return m_producer_version_update;
|
return m_producer_version_update;
|
||||||
}
|
}
|
||||||
LanguageType DWARFUnit::LanguageTypeFromDWARF(uint64_t val) {
|
|
||||||
// Note: user languages between lo_user and hi_user must be handled
|
|
||||||
// explicitly here.
|
|
||||||
switch (val) {
|
|
||||||
case DW_LANG_Mips_Assembler:
|
|
||||||
return eLanguageTypeMipsAssembler;
|
|
||||||
case DW_LANG_GOOGLE_RenderScript:
|
|
||||||
return eLanguageTypeExtRenderScript;
|
|
||||||
default:
|
|
||||||
return static_cast<LanguageType>(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LanguageType DWARFUnit::GetLanguageType() {
|
uint64_t DWARFUnit::GetDWARFLanguageType() {
|
||||||
if (m_language_type != eLanguageTypeUnknown)
|
if (m_language_type)
|
||||||
return m_language_type;
|
return *m_language_type;
|
||||||
|
|
||||||
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
|
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
|
||||||
if (die)
|
if (!die)
|
||||||
m_language_type = LanguageTypeFromDWARF(
|
m_language_type = 0;
|
||||||
die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0));
|
else
|
||||||
return m_language_type;
|
m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
|
||||||
|
return *m_language_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFUnit::GetIsOptimized() {
|
bool DWARFUnit::GetIsOptimized() {
|
||||||
|
|
|
@ -152,8 +152,6 @@ public:
|
||||||
|
|
||||||
lldb::ByteOrder GetByteOrder() const;
|
lldb::ByteOrder GetByteOrder() const;
|
||||||
|
|
||||||
llvm::Expected<lldb_private::TypeSystem &> GetTypeSystem();
|
|
||||||
|
|
||||||
const DWARFDebugAranges &GetFunctionAranges();
|
const DWARFDebugAranges &GetFunctionAranges();
|
||||||
|
|
||||||
void SetBaseAddress(dw_addr_t base_addr);
|
void SetBaseAddress(dw_addr_t base_addr);
|
||||||
|
@ -190,9 +188,7 @@ public:
|
||||||
|
|
||||||
uint32_t GetProducerVersionUpdate();
|
uint32_t GetProducerVersionUpdate();
|
||||||
|
|
||||||
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
|
uint64_t GetDWARFLanguageType();
|
||||||
|
|
||||||
lldb::LanguageType GetLanguageType();
|
|
||||||
|
|
||||||
bool GetIsOptimized();
|
bool GetIsOptimized();
|
||||||
|
|
||||||
|
@ -304,7 +300,7 @@ protected:
|
||||||
uint32_t m_producer_version_major = 0;
|
uint32_t m_producer_version_major = 0;
|
||||||
uint32_t m_producer_version_minor = 0;
|
uint32_t m_producer_version_minor = 0;
|
||||||
uint32_t m_producer_version_update = 0;
|
uint32_t m_producer_version_update = 0;
|
||||||
lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
|
llvm::Optional<uint64_t> m_language_type;
|
||||||
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
|
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
|
||||||
llvm::Optional<lldb_private::FileSpec> m_comp_dir;
|
llvm::Optional<lldb_private::FileSpec> m_comp_dir;
|
||||||
llvm::Optional<lldb_private::FileSpec> m_file_spec;
|
llvm::Optional<lldb_private::FileSpec> m_file_spec;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
|
||||||
unit.GetOffset());
|
unit.GetOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
const LanguageType cu_language = unit.GetLanguageType();
|
const LanguageType cu_language = SymbolFileDWARF::GetLanguage(unit);
|
||||||
|
|
||||||
IndexUnitImpl(unit, cu_language, set);
|
IndexUnitImpl(unit, cu_language, set);
|
||||||
|
|
||||||
|
|
|
@ -670,7 +670,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
|
||||||
cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
|
cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
|
||||||
}
|
}
|
||||||
|
|
||||||
LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
|
LanguageType cu_language = SymbolFileDWARF::LanguageTypeFromDWARF(
|
||||||
cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
|
cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
|
||||||
|
|
||||||
bool is_optimized = dwarf_cu.GetNonSkeletonUnit().GetIsOptimized();
|
bool is_optimized = dwarf_cu.GetNonSkeletonUnit().GetIsOptimized();
|
||||||
|
@ -748,8 +748,7 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
|
||||||
if (!die.IsValid())
|
if (!die.IsValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto type_system_or_err =
|
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
|
||||||
GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
|
|
||||||
if (auto err = type_system_or_err.takeError()) {
|
if (auto err = type_system_or_err.takeError()) {
|
||||||
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
||||||
std::move(err), "Unable to parse function");
|
std::move(err), "Unable to parse function");
|
||||||
|
@ -781,7 +780,7 @@ lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
|
||||||
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
|
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
|
||||||
if (dwarf_cu)
|
if (dwarf_cu)
|
||||||
return dwarf_cu->GetLanguageType();
|
return GetLanguage(*dwarf_cu);
|
||||||
else
|
else
|
||||||
return eLanguageTypeUnknown;
|
return eLanguageTypeUnknown;
|
||||||
}
|
}
|
||||||
|
@ -1272,7 +1271,7 @@ CompilerDecl SymbolFileDWARF::GetDeclForUID(lldb::user_id_t type_uid) {
|
||||||
// SymbolFileDWARF::GetDIE(). See comments inside the
|
// SymbolFileDWARF::GetDIE(). See comments inside the
|
||||||
// SymbolFileDWARF::GetDIE() for details.
|
// SymbolFileDWARF::GetDIE() for details.
|
||||||
if (DWARFDIE die = GetDIE(type_uid))
|
if (DWARFDIE die = GetDIE(type_uid))
|
||||||
return die.GetDecl();
|
return GetDecl(die);
|
||||||
return CompilerDecl();
|
return CompilerDecl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,7 +1284,7 @@ SymbolFileDWARF::GetDeclContextForUID(lldb::user_id_t type_uid) {
|
||||||
// SymbolFileDWARF::GetDIE(). See comments inside the
|
// SymbolFileDWARF::GetDIE(). See comments inside the
|
||||||
// SymbolFileDWARF::GetDIE() for details.
|
// SymbolFileDWARF::GetDIE() for details.
|
||||||
if (DWARFDIE die = GetDIE(type_uid))
|
if (DWARFDIE die = GetDIE(type_uid))
|
||||||
return die.GetDeclContext();
|
return GetDeclContext(die);
|
||||||
return CompilerDeclContext();
|
return CompilerDeclContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,7 +1295,7 @@ SymbolFileDWARF::GetDeclContextContainingUID(lldb::user_id_t type_uid) {
|
||||||
// SymbolFileDWARF::GetDIE(). See comments inside the
|
// SymbolFileDWARF::GetDIE(). See comments inside the
|
||||||
// SymbolFileDWARF::GetDIE() for details.
|
// SymbolFileDWARF::GetDIE() for details.
|
||||||
if (DWARFDIE die = GetDIE(type_uid))
|
if (DWARFDIE die = GetDIE(type_uid))
|
||||||
return die.GetContainingDeclContext();
|
return GetContainingDeclContext(die);
|
||||||
return CompilerDeclContext();
|
return CompilerDeclContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1427,8 +1426,7 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
|
||||||
dwarf_die.GetID(), dwarf_die.GetTagAsCString(),
|
dwarf_die.GetID(), dwarf_die.GetTagAsCString(),
|
||||||
type->GetName().AsCString());
|
type->GetName().AsCString());
|
||||||
assert(compiler_type);
|
assert(compiler_type);
|
||||||
DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*dwarf_die.GetCU()))
|
||||||
if (dwarf_ast)
|
|
||||||
return dwarf_ast->CompleteTypeFromDWARF(dwarf_die, type, compiler_type);
|
return dwarf_ast->CompleteTypeFromDWARF(dwarf_die, type, compiler_type);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2099,8 +2097,7 @@ void SymbolFileDWARF::FindGlobalVariables(
|
||||||
sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
|
sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
|
||||||
|
|
||||||
if (parent_decl_ctx) {
|
if (parent_decl_ctx) {
|
||||||
DWARFASTParser *dwarf_ast = die.GetDWARFParser();
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
|
||||||
if (dwarf_ast) {
|
|
||||||
CompilerDeclContext actual_parent_decl_ctx =
|
CompilerDeclContext actual_parent_decl_ctx =
|
||||||
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
|
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
|
||||||
if (!actual_parent_decl_ctx ||
|
if (!actual_parent_decl_ctx ||
|
||||||
|
@ -2258,11 +2255,9 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (die) {
|
if (die) {
|
||||||
DWARFASTParser *dwarf_ast = die.GetDWARFParser();
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
|
||||||
if (dwarf_ast) {
|
if (CompilerDeclContext actual_decl_ctx =
|
||||||
CompilerDeclContext actual_decl_ctx =
|
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die))
|
||||||
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
|
|
||||||
if (actual_decl_ctx)
|
|
||||||
return decl_ctx->IsContainedInLookup(actual_decl_ctx);
|
return decl_ctx->IsContainedInLookup(actual_decl_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2509,7 +2504,7 @@ void SymbolFileDWARF::FindTypes(
|
||||||
m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
|
m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!languages[die.GetCU()->GetLanguageType()])
|
if (!languages[GetLanguage(*die.GetCU())])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
llvm::SmallVector<CompilerContext, 4> die_context;
|
llvm::SmallVector<CompilerContext, 4> die_context;
|
||||||
|
@ -2566,8 +2561,7 @@ SymbolFileDWARF::FindNamespace(ConstString name,
|
||||||
if (!DIEInDeclContext(parent_decl_ctx, die))
|
if (!DIEInDeclContext(parent_decl_ctx, die))
|
||||||
continue; // The containing decl contexts don't match
|
continue; // The containing decl contexts don't match
|
||||||
|
|
||||||
DWARFASTParser *dwarf_ast = die.GetDWARFParser();
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
|
||||||
if (dwarf_ast) {
|
|
||||||
namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
|
namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
|
||||||
if (namespace_decl_ctx)
|
if (namespace_decl_ctx)
|
||||||
break;
|
break;
|
||||||
|
@ -2928,7 +2922,7 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
|
||||||
// looking for. We don't want to find a "Foo" type from Java if we
|
// looking for. We don't want to find a "Foo" type from Java if we
|
||||||
// are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
|
// are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
|
||||||
if (type_system &&
|
if (type_system &&
|
||||||
!type_system->SupportsLanguage(type_die.GetLanguage()))
|
!type_system->SupportsLanguage(GetLanguage(*type_die.GetCU())))
|
||||||
continue;
|
continue;
|
||||||
bool try_resolving_type = false;
|
bool try_resolving_type = false;
|
||||||
|
|
||||||
|
@ -2962,8 +2956,8 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (try_resolving_type) {
|
if (try_resolving_type) {
|
||||||
DWARFDeclContext type_dwarf_decl_ctx;
|
DWARFDeclContext type_dwarf_decl_ctx =
|
||||||
type_die.GetDWARFDeclContext(type_dwarf_decl_ctx);
|
GetDWARFDeclContext(type_die);
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
GetObjectFile()->GetModule()->LogMessage(
|
GetObjectFile()->GetModule()->LogMessage(
|
||||||
|
@ -3013,8 +3007,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
|
||||||
if (!die)
|
if (!die)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto type_system_or_err =
|
auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
|
||||||
GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
|
|
||||||
if (auto err = type_system_or_err.takeError()) {
|
if (auto err = type_system_or_err.takeError()) {
|
||||||
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
||||||
std::move(err), "Unable to parse type");
|
std::move(err), "Unable to parse type");
|
||||||
|
@ -3381,12 +3374,10 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
|
||||||
// declaration context.
|
// declaration context.
|
||||||
if ((parent_tag == DW_TAG_compile_unit ||
|
if ((parent_tag == DW_TAG_compile_unit ||
|
||||||
parent_tag == DW_TAG_partial_unit) &&
|
parent_tag == DW_TAG_partial_unit) &&
|
||||||
Language::LanguageIsCPlusPlus(die.GetLanguage())) {
|
Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
|
||||||
DWARFDeclContext decl_ctx;
|
mangled = GetDWARFDeclContext(die)
|
||||||
|
.GetQualifiedNameAsConstString()
|
||||||
die.GetDWARFDeclContext(decl_ctx);
|
.GetCString();
|
||||||
mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag == DW_TAG_formal_parameter)
|
if (tag == DW_TAG_formal_parameter)
|
||||||
|
@ -3954,3 +3945,62 @@ SymbolFileDWARFDwp *SymbolFileDWARF::GetDwpSymbolFile() {
|
||||||
});
|
});
|
||||||
return m_dwp_symfile.get();
|
return m_dwp_symfile.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
llvm::Expected<TypeSystem &> SymbolFileDWARF::GetTypeSystem(DWARFUnit &unit) {
|
||||||
|
return unit.GetSymbolFileDWARF().GetTypeSystemForLanguage(GetLanguage(unit));
|
||||||
|
}
|
||||||
|
|
||||||
|
DWARFASTParser *SymbolFileDWARF::GetDWARFParser(DWARFUnit &unit) {
|
||||||
|
auto type_system_or_err = GetTypeSystem(unit);
|
||||||
|
if (auto err = type_system_or_err.takeError()) {
|
||||||
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
|
||||||
|
std::move(err), "Unable to get DWARFASTParser");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return type_system_or_err->GetDWARFParser();
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilerDecl SymbolFileDWARF::GetDecl(const DWARFDIE &die) {
|
||||||
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
|
||||||
|
return dwarf_ast->GetDeclForUIDFromDWARF(die);
|
||||||
|
return CompilerDecl();
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilerDeclContext SymbolFileDWARF::GetDeclContext(const DWARFDIE &die) {
|
||||||
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
|
||||||
|
return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
|
||||||
|
return CompilerDeclContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilerDeclContext
|
||||||
|
SymbolFileDWARF::GetContainingDeclContext(const DWARFDIE &die) {
|
||||||
|
if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
|
||||||
|
return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
|
||||||
|
return CompilerDeclContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
|
||||||
|
if (!die.IsValid())
|
||||||
|
return {};
|
||||||
|
DWARFDeclContext dwarf_decl_ctx =
|
||||||
|
die.GetDIE()->GetDWARFDeclContext(die.GetCU());
|
||||||
|
dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
|
||||||
|
return dwarf_decl_ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
|
||||||
|
// Note: user languages between lo_user and hi_user must be handled
|
||||||
|
// explicitly here.
|
||||||
|
switch (val) {
|
||||||
|
case DW_LANG_Mips_Assembler:
|
||||||
|
return eLanguageTypeMipsAssembler;
|
||||||
|
case DW_LANG_GOOGLE_RenderScript:
|
||||||
|
return eLanguageTypeExtRenderScript;
|
||||||
|
default:
|
||||||
|
return static_cast<LanguageType>(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LanguageType SymbolFileDWARF::GetLanguage(DWARFUnit &unit) {
|
||||||
|
return LanguageTypeFromDWARF(unit.GetDWARFLanguageType());
|
||||||
|
}
|
||||||
|
|
|
@ -301,6 +301,26 @@ public:
|
||||||
|
|
||||||
lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
|
lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
|
||||||
|
|
||||||
|
static llvm::Expected<lldb_private::TypeSystem &>
|
||||||
|
GetTypeSystem(DWARFUnit &unit);
|
||||||
|
|
||||||
|
static DWARFASTParser *GetDWARFParser(DWARFUnit &unit);
|
||||||
|
|
||||||
|
// CompilerDecl related functions
|
||||||
|
|
||||||
|
static lldb_private::CompilerDecl GetDecl(const DWARFDIE &die);
|
||||||
|
|
||||||
|
static lldb_private::CompilerDeclContext GetDeclContext(const DWARFDIE &die);
|
||||||
|
|
||||||
|
static lldb_private::CompilerDeclContext
|
||||||
|
GetContainingDeclContext(const DWARFDIE &die);
|
||||||
|
|
||||||
|
static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
|
||||||
|
|
||||||
|
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
|
||||||
|
|
||||||
|
static lldb::LanguageType GetLanguage(DWARFUnit &unit);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
|
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
|
||||||
DIEToTypePtr;
|
DIEToTypePtr;
|
||||||
|
|
Loading…
Reference in New Issue