Author: jankratochvil Date: Mon Apr 30 09:04:32 2018 New Revision: 331194 URL: http://llvm.org/viewvc/llvm-project?rev=331194&view=rev Log: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched
Code commonly checks if the parent DIE is DW_TAG_compile_unit. But DW_TAG_partial_unit also acts as DW_TAG_compile_unit for DWZ as DWZ is using DW_TAG_imported_unit only at the top unit level. Differential revision: https://reviews.llvm.org/D40469 Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Mon Apr 30 09:04:32 2018 @@ -1925,7 +1925,8 @@ TypeSP DWARFASTParserClang::ParseTypeFro dw_tag_t sc_parent_tag = sc_parent_die.Tag(); SymbolContextScope *symbol_context_scope = NULL; - if (sc_parent_tag == DW_TAG_compile_unit) { + if (sc_parent_tag == DW_TAG_compile_unit || + sc_parent_tag == DW_TAG_partial_unit) { symbol_context_scope = sc.comp_unit; } else if (sc.function != NULL && sc_parent_die) { symbol_context_scope = @@ -2745,7 +2746,8 @@ Function *DWARFASTParserClang::ParseFunc Mangled func_name; if (mangled) 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) && Language::LanguageIsCPlusPlus(die.GetLanguage()) && name && strcmp(name, "main") != 0) { // If the mangled name is not present in the DWARF, generate the @@ -3838,6 +3840,7 @@ DWARFASTParserClang::GetClangDeclContext bool try_parsing_type = true; switch (die.Tag()) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: decl_ctx = m_ast.GetTranslationUnitDecl(); try_parsing_type = false; break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp Mon Apr 30 09:04:32 2018 @@ -431,7 +431,8 @@ TypeSP DWARFASTParserGo::ParseTypeFromDW dw_tag_t sc_parent_tag = sc_parent_die.Tag(); SymbolContextScope *symbol_context_scope = NULL; - if (sc_parent_tag == DW_TAG_compile_unit) { + if (sc_parent_tag == DW_TAG_compile_unit || + sc_parent_tag == DW_TAG_partial_unit) { symbol_context_scope = sc.comp_unit; } else if (sc.function != NULL && sc_parent_die) { symbol_context_scope = Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp Mon Apr 30 09:04:32 2018 @@ -324,7 +324,8 @@ lldb::TypeSP DWARFASTParserJava::ParseTy dw_tag_t sc_parent_tag = sc_parent_die.Tag(); SymbolContextScope *symbol_context_scope = nullptr; - if (sc_parent_tag == DW_TAG_compile_unit) { + if (sc_parent_tag == DW_TAG_compile_unit || + sc_parent_tag == DW_TAG_partial_unit) { symbol_context_scope = sc.comp_unit; } else if (sc.function != nullptr && sc_parent_die) { symbol_context_scope = Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp Mon Apr 30 09:04:32 2018 @@ -98,7 +98,8 @@ lldb::TypeSP DWARFASTParserOCaml::ParseT dw_tag_t sc_parent_tag = sc_parent_die.Tag(); SymbolContextScope *symbol_context_scope = nullptr; - if (sc_parent_tag == DW_TAG_compile_unit) { + if (sc_parent_tag == DW_TAG_compile_unit || + sc_parent_tag == DW_TAG_partial_unit) { symbol_context_scope = sc.comp_unit; } else if (sc.function != nullptr && sc_parent_die) { symbol_context_scope = Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp Mon Apr 30 09:04:32 2018 @@ -262,7 +262,7 @@ void DWARFDIE::GetDWARFDeclContext(DWARF void DWARFDIE::GetDWOContext(std::vector<CompilerContext> &context) const { const dw_tag_t tag = Tag(); - if (tag == DW_TAG_compile_unit) + if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit) return; DWARFDIE parent = GetParent(); if (parent) @@ -369,7 +369,7 @@ DWARFDIE::GetContainingDWOModuleDIE() co const dw_tag_t tag = parent.Tag(); if (tag == DW_TAG_module) top_module_die = parent; - else if (tag == DW_TAG_compile_unit) + else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit) break; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Mon Apr 30 09:04:32 2018 @@ -218,7 +218,8 @@ bool DWARFDebugInfoEntry::Extract(Symbol m_tag = abbrevDecl->Tag(); m_has_children = abbrevDecl->HasChildren(); - bool isCompileUnitTag = m_tag == DW_TAG_compile_unit; + bool isCompileUnitTag = (m_tag == DW_TAG_compile_unit || + m_tag == DW_TAG_partial_unit); if (cu && isCompileUnitTag) const_cast<DWARFUnit *>(cu)->SetBaseAddress(0); @@ -770,7 +771,7 @@ size_t DWARFDebugInfoEntry::GetAttribute const DWARFAbbreviationDeclaration *abbrevDecl = nullptr; lldb::offset_t offset = 0; if (cu) { - if (m_tag != DW_TAG_compile_unit) { + if (m_tag != DW_TAG_compile_unit && m_tag != DW_TAG_partial_unit) { SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile(); if (dwo_symbol_file) return GetAttributes(dwo_symbol_file->GetCompileUnit(), @@ -851,7 +852,8 @@ dw_offset_t DWARFDebugInfoEntry::GetAttr dw_offset_t *end_attr_offset_ptr, bool check_specification_or_abstract_origin) const { SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile(); - if (dwo_symbol_file && m_tag != DW_TAG_compile_unit) + if (dwo_symbol_file && m_tag != DW_TAG_compile_unit && + m_tag != DW_TAG_partial_unit) return GetAttributeValue(dwo_symbol_file, dwo_symbol_file->GetCompileUnit(), attr, form_value, end_attr_offset_ptr, check_specification_or_abstract_origin); @@ -1382,11 +1384,12 @@ void DWARFDebugInfoEntry::GetDWARFDeclCo SymbolFileDWARF *dwarf2Data, DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const { const dw_tag_t tag = Tag(); - if (tag != DW_TAG_compile_unit) { + if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) { dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu)); DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(dwarf2Data, cu); 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.GetDIE()->GetDWARFDeclContext( parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx); @@ -1424,6 +1427,7 @@ DWARFDebugInfoEntry::GetParentDeclContex if (die.GetDIE() != this) { switch (die.Tag()) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: case DW_TAG_namespace: case DW_TAG_structure_type: case DW_TAG_union_type: @@ -1661,6 +1665,7 @@ bool DWARFDebugInfoEntry::LookupAddress( case DW_TAG_unspecified_type: break; case DW_TAG_partial_unit: + match_addr_range = true; break; case DW_TAG_imported_unit: break; @@ -1684,6 +1689,7 @@ bool DWARFDebugInfoEntry::LookupAddress( // puts("***MATCH***"); switch (m_tag) { case DW_TAG_compile_unit: // File + case DW_TAG_partial_unit: // File check_children = ((function_die != NULL) || (block_die != NULL)); break; @@ -1709,7 +1715,8 @@ bool DWARFDebugInfoEntry::LookupAddress( } else { // compile units may not have a valid high/low pc when there // are address gaps in subroutines so we must always search // if there is no valid high and low PC - check_children = (m_tag == DW_TAG_compile_unit) && + check_children = (m_tag == DW_TAG_compile_unit || + m_tag == DW_TAG_partial_unit) && ((function_die != NULL) || (block_die != NULL)); } } else { @@ -1728,6 +1735,7 @@ bool DWARFDebugInfoEntry::LookupAddress( // puts("***MATCH***"); switch (m_tag) { case DW_TAG_compile_unit: // File + case DW_TAG_partial_unit: // File check_children = ((function_die != NULL) || (block_die != NULL)); break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp Mon Apr 30 09:04:32 2018 @@ -801,6 +801,7 @@ void DWARFUnit::IndexPrivate( break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: is_global_or_static_variable = true; parent_die = NULL; // Terminate the while loop. break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Apr 30 09:04:32 2018 @@ -382,6 +382,7 @@ SymbolFileDWARF::GetParentSymbolContextD switch (tag) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: case DW_TAG_subprogram: case DW_TAG_inlined_subroutine: case DW_TAG_lexical_block: @@ -3110,6 +3111,7 @@ SymbolFileDWARF::GetDeclContextDIEContai if (orig_die != die) { switch (die.Tag()) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: case DW_TAG_namespace: case DW_TAG_structure_type: case DW_TAG_union_type: @@ -3308,7 +3310,7 @@ bool SymbolFileDWARF::DIEDeclContextsMat // [0] DW_TAG_class_type for "B" // [1] DW_TAG_class_type for "A" // [2] DW_TAG_namespace for "lldb" - // [3] DW_TAG_compile_unit for the source file. + // [3] DW_TAG_compile_unit or DW_TAG_partial_unit for the source file. // // We grab both contexts and make sure that everything matches // all the way back to the compiler unit. @@ -3337,9 +3339,11 @@ bool SymbolFileDWARF::DIEDeclContextsMat #if defined LLDB_CONFIGURATION_DEBUG // Make sure the top item in the decl context die array is always - // DW_TAG_compile_unit. If it isn't then something went wrong in - // the DWARFDIE::GetDeclContextDIEs() function... - assert(decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag() == DW_TAG_compile_unit); + // DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then something + // went wrong in the DWARFDIE::GetDeclContextDIEs() function... + dw_tag_t cu_tag = decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag(); + UNUSED_IF_ASSERT_DISABLED(cu_tag); + assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit); #endif // Always skip the compile unit when comparing by only iterating up to @@ -3941,7 +3945,8 @@ VariableSP SymbolFileDWARF::ParseVariabl const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die); const dw_tag_t parent_tag = die.GetParent().Tag(); bool is_static_member = - parent_tag == DW_TAG_compile_unit && + (parent_tag == DW_TAG_compile_unit || + parent_tag == DW_TAG_partial_unit) && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type); @@ -3963,7 +3968,8 @@ VariableSP SymbolFileDWARF::ParseVariabl // "(int) A::B::j = 4". If the compiler does not emit a linkage name, we // should be able // to generate a fully qualified name from the declaration context. - if (parent_tag == DW_TAG_compile_unit && + if ((parent_tag == DW_TAG_compile_unit || + parent_tag == DW_TAG_partial_unit) && Language::LanguageIsCPlusPlus(die.GetLanguage())) { DWARFDeclContext decl_ctx; @@ -4221,6 +4227,7 @@ size_t SymbolFileDWARF::ParseVariables(c dw_tag_t parent_tag = sc_parent_die.Tag(); switch (parent_tag) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: if (sc.comp_unit != NULL) { variable_list_sp = sc.comp_unit->GetVariableList(false); if (variable_list_sp.get() == NULL) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp?rev=331194&r1=331193&r2=331194&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Mon Apr 30 09:04:32 2018 @@ -57,6 +57,7 @@ bool UniqueDWARFASTTypeList::Find(const } break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: done = true; break; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits