[Lldb-commits] [PATCH] D40472: DWZ 07/11: Protect DWARFDebugInfo::m_compile_units by a new mutex
jankratochvil abandoned this revision. jankratochvil added a comment. Without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit` this patch is no longer needed, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40472 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40467: DWZ 03/11: Separate Offset also into FileOffset
jankratochvil abandoned this revision. jankratochvil added a comment. Without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit` this patch is no longer needed, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40467 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40468: DWZ 01/07: Support reading section ".gnu_debugaltlink"
jankratochvil updated this revision to Diff 143475. jankratochvil retitled this revision from "DWZ 04/11: Support reading section ".gnu_debugaltlink"" to "DWZ 01/07: Support reading section ".gnu_debugaltlink"". jankratochvil added a comment. It is now reworked without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit`, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40468 Files: include/lldb/lldb-enumerations.h source/Core/Section.cpp source/Expression/IRExecutionUnit.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp source/Symbol/ObjectFile.cpp Index: source/Symbol/ObjectFile.cpp === --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -363,6 +363,7 @@ case eSectionTypeDWARFAppleTypes: case eSectionTypeDWARFAppleNamespaces: case eSectionTypeDWARFAppleObjC: + case eSectionTypeDWARFGNUDebugAltLink: return eAddressClassDebug; case eSectionTypeEHFrame: case eSectionTypeARMexidx: Index: source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp === --- source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -134,7 +134,7 @@ eSectionTypeDWARFDebugMacInfo, eSectionTypeDWARFDebugPubNames, eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugStr, eSectionTypeDWARFDebugStrOffsets, - eSectionTypeELFSymbolTable, + eSectionTypeELFSymbolTable, eSectionTypeDWARFGNUDebugAltLink, }; for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]); ++idx) { Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -250,6 +250,7 @@ const lldb_private::DWARFDataExtractor &get_apple_types_data(); const lldb_private::DWARFDataExtractor &get_apple_namespaces_data(); const lldb_private::DWARFDataExtractor &get_apple_objc_data(); + const lldb_private::DWARFDataExtractor &get_gnu_debugaltlink(); DWARFDebugAbbrev *DebugAbbrev(); @@ -495,6 +496,7 @@ DWARFDataSegment m_data_apple_types; DWARFDataSegment m_data_apple_namespaces; DWARFDataSegment m_data_apple_objc; + DWARFDataSegment m_data_gnu_debugaltlink; // The unique pointer items below are generated on demand if and when someone // accesses Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -681,6 +681,11 @@ return GetCachedSectionData(eSectionTypeDWARFAppleObjC, m_data_apple_objc); } +const DWARFDataExtractor &SymbolFileDWARF::get_gnu_debugaltlink() { + return GetCachedSectionData(eSectionTypeDWARFGNUDebugAltLink, + m_data_gnu_debugaltlink); +} + DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() { if (m_abbr.get() == NULL) { const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data(); Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp === --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1212,6 +1212,7 @@ case eSectionTypeDWARFAppleTypes: case eSectionTypeDWARFAppleNamespaces: case eSectionTypeDWARFAppleObjC: + case eSectionTypeDWARFGNUDebugAltLink: return eAddressClassDebug; case eSectionTypeEHFrame: Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1823,6 +1823,7 @@ static ConstString g_sect_name_arm_exidx(".ARM.exidx"); static ConstString g_sect_name_arm_extab(".ARM.extab"); static ConstString g_sect_name_go_symtab(".gosymtab"); + static ConstString g_sect_name_dwarf_gnu_debugaltlink(".gnu_debugaltlink"); SectionType sect_type = eSectionTypeOther; @@ -1913,6 +1914,8 @@ sect_type = eSectionTypeARMextab; else if (name == g_sect_name_go_symtab) sect_type = eSectionTypeGoSymtab; + else if (nam
[Lldb-commits] [PATCH] D40469: DWZ 02/07: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched
jankratochvil updated this revision to Diff 143476. jankratochvil retitled this revision from "DWZ 05/11: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched" to "DWZ 02/07: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched". jankratochvil added a comment. It is now reworked without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit`, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40469 Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Index: source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp === --- source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -57,6 +57,7 @@ } break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: done = true; break; } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -381,6 +381,7 @@ 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: @@ -3109,6 +3110,7 @@ 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: @@ -3307,7 +3309,7 @@ // [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. @@ -3336,9 +3338,11 @@ #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 @@ -3940,7 +3944,8 @@ 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); @@ -3962,7 +3967,8 @@ // "(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; @@ -4220,6 +4226,7 @@ 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) { Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -804,6 +804,7 @@ break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: is_global_or_stat
[Lldb-commits] [PATCH] D40473: DWZ 04/07: Adjust existing code for the DWZ support.
jankratochvil updated this revision to Diff 143478. jankratochvil retitled this revision from "DWZ 08/11: Adjust existing code for the DWZ support." to "DWZ 04/07: Adjust existing code for the DWZ support.". jankratochvil added a comment. It is now reworked without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit`, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40473 Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -734,6 +734,8 @@ DWARFUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID()); +if (dwarf_cu) + dwarf_cu = dwarf_cu->GetMainCU(); if (dwarf_cu && dwarf_cu->GetUserData() == NULL) dwarf_cu->SetUserData(comp_unit); return dwarf_cu; @@ -763,6 +765,7 @@ uint32_t cu_idx) { CompUnitSP cu_sp; if (dwarf_cu) { +dwarf_cu = dwarf_cu->GetMainCU(); CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData(); if (comp_unit) { // We already parsed this compile unit, had out a shared pointer to it @@ -1370,6 +1373,9 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed) { + // this can be neither die.GetDWARF() nor die.GetMainDWARF(). + if (die.GetMainDWARF() != this) +return die.GetMainDWARF()->ResolveTypeUID(die, assert_not_being_parsed); if (die) { Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log) @@ -1482,6 +1488,10 @@ Type *SymbolFileDWARF::ResolveType(const DWARFDIE &die, bool assert_not_being_parsed, bool resolve_function_context) { + // this can be neither die.GetDWARF() nor die.GetMainDWARF(). + if (die.GetMainDWARF() != this) +return die.GetMainDWARF()->ResolveType( +die, assert_not_being_parsed, resolve_function_context); if (die) { Type *type = GetTypeForDIE(die, resolve_function_context).get(); @@ -1502,6 +1512,7 @@ CompileUnit * SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu, uint32_t cu_idx) { + dwarf_cu = dwarf_cu->GetMainCU(); // Check if the symbol vendor already knows about this compile unit? if (dwarf_cu->GetUserData() == NULL) { // The symbol vendor doesn't know about this compile unit, we Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -132,6 +132,11 @@ dw_offset_t GetBaseObjOffset() const; + // DW_TAG_compile_unit with DW_TAG_imported_unit for this DW_TAG_partial_unit. + DWARFUnit *GetMainCU() const { +return const_cast(this); + } + protected: DWARFUnit(SymbolFileDWARF *dwarf); Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -445,6 +445,9 @@ } TypeSystem *DWARFUnit::GetTypeSystem() { + if (GetMainCU() != this) +return GetMainCU()->GetTypeSystem(); + if (m_dwarf) return m_dwarf->GetTypeSystemForLanguage(GetLanguageType()); else @@ -495,7 +498,7 @@ // Don't specify the compile unit offset as we don't know it because the // DIE belongs to // a different compile unit in the same symbol file. - return m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset); + return GetMainCU()->m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset); } } m_dwarf->GetObjectFile()->GetModule()->ReportError( @@ -633,6 +636,9 @@ } LanguageType DWARFUnit::GetLanguageType() { + if (GetMainCU() != this) +return GetMainCU()->GetLanguageType(); + if (m_language_type != eLanguageTypeUnknown) return m_language_type; Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -569,7 +569,8 @@ if (ranges.IsEmpty() || name
[Lldb-commits] [PATCH] D40470: DWZ 03/07: Protect DWARFCompileUnit::m_die_array by a new mutex
jankratochvil updated this revision to Diff 143477. jankratochvil retitled this revision from "DWZ 06/11: Protect DWARFCompileUnit::m_die_array by a new mutex" to "DWZ 03/07: Protect DWARFCompileUnit::m_die_array by a new mutex". jankratochvil added a comment. It is now reworked without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit`, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40470 Files: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -141,6 +141,8 @@ void *m_user_data = nullptr; // The compile unit debug information entry item DWARFDebugInfoEntry::collection m_die_array; + // Prevent m_extractdies_mutex lock overhead for most cases. + std::atomic_size_t m_die_array_size_atomic { 0 }; // A table similar to the .debug_aranges table, but this one points to the // exact DW_TAG_subprogram DIEs std::unique_ptr m_func_aranges_ap; @@ -160,6 +162,7 @@ // If this is a dwo compile unit this is the offset of the base compile unit // in the main object file dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; + std::mutex m_extractdies_mutex; static void IndexPrivate(DWARFUnit *dwarf_cu, const lldb::LanguageType cu_language, Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -42,9 +42,19 @@ // done. //-- size_t DWARFUnit::ExtractDIEsIfNeeded(bool cu_die_only) { - const size_t initial_die_array_size = m_die_array.size(); - if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1) -return 0; // Already parsed + size_t initial_die_array_size; + auto already_parsed = [cu_die_only, &initial_die_array_size, this]() -> bool { +initial_die_array_size = m_die_array_size_atomic; +return (cu_die_only && initial_die_array_size > 0) +|| initial_die_array_size > 1; + }; + if (already_parsed()) +return 0; + std::lock_guard guard(m_extractdies_mutex); + if (already_parsed()) +return 0; + std::shared_ptr m_die_array_finished_set(nullptr, + [&](void*){ m_die_array_size_atomic = m_die_array.size(); }); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( @@ -307,6 +317,8 @@ void DWARFUnit::ClearDIEs(bool keep_compile_unit_die) { if (m_die_array.size() > 1) { +std::lock_guard guard(m_extractdies_mutex); + // std::vectors never get any smaller when resized to a smaller size, // or when clear() or erase() are called, the size will report that it // is smaller, but the memory allocated remains intact (call capacity() @@ -318,8 +330,11 @@ // Save at least the compile unit DIE DWARFDebugInfoEntry::collection tmp_array; m_die_array.swap(tmp_array); -if (keep_compile_unit_die) +m_die_array_size_atomic = 0; +if (keep_compile_unit_die) { m_die_array.push_back(tmp_array.front()); + ++m_die_array_size_atomic; +} } if (m_dwo_symbol_file) Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -141,6 +141,8 @@ void *m_user_data = nullptr; // The compile unit debug information entry item DWARFDebugInfoEntry::collection m_die_array; + // Prevent m_extractdies_mutex lock overhead for most cases. + std::atomic_size_t m_die_array_size_atomic { 0 }; // A table similar to the .debug_aranges table, but this one points to the // exact DW_TAG_subprogram DIEs std::unique_ptr m_func_aranges_ap; @@ -160,6 +162,7 @@ // If this is a dwo compile unit this is the offset of the base compile unit // in the main object file dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; + std::mutex m_extractdies_mutex; static void IndexPrivate(DWARFUnit *dwarf_cu, const lldb::LanguageType cu_language, Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -42,9 +42,19 @@ // done. //-- size_t DWARFUnit::ExtractDIEsIfNeeded(bool cu_die_only) { - const size_t initial_die_array_size = m_die_array.size(); - if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1) -
[Lldb-commits] [PATCH] D40474: DWZ 05/07: Main functionality
jankratochvil updated this revision to Diff 143479. jankratochvil retitled this revision from "DWZ 09/11: Main functionality" to "DWZ 05/07: Main functionality". jankratochvil added a comment. It is now reworked without `FileOffset` and the remapping to unique DIE offsets for each `DW_TAG_partial_unit` inclusion by `DW_TAG_imported_unit`, as discussed in: https://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180409/040324.html https://reviews.llvm.org/D40474 Files: include/lldb/Utility/ConstString.h include/lldb/Utility/FileSpec.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Utility/DataEncoder.cpp source/Utility/DataExtractor.cpp Index: source/Utility/DataExtractor.cpp === --- source/Utility/DataExtractor.cpp +++ source/Utility/DataExtractor.cpp @@ -232,7 +232,8 @@ if (data != nullptr) { const uint8_t *data_bytes = data->GetBytes(); if (data_bytes != nullptr) { -assert(m_start >= data_bytes); +// For DWARFDataExtractor::OffsetData we need to return negative value. +// assert(m_start >= data_bytes); return m_start - data_bytes; } } Index: source/Utility/DataEncoder.cpp === --- source/Utility/DataEncoder.cpp +++ source/Utility/DataEncoder.cpp @@ -81,7 +81,8 @@ if (data != nullptr) { const uint8_t *data_bytes = data->GetBytes(); if (data_bytes != nullptr) { -assert(m_start >= data_bytes); +// For DWARFDataExtractor::OffsetData we need to return negative value. +// assert(m_start >= data_bytes); return m_start - data_bytes; } } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -18,10 +18,12 @@ #include #include #include +#include // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Threading.h" +#include "llvm/Support/RWMutex.h" #include "lldb/Utility/Flags.h" @@ -312,6 +314,13 @@ // the method returns a pointer to the base compile unit. virtual DWARFUnit *GetBaseCompileUnit(); + SymbolFileDWARF *GetDWZSymbolFile() const { +if (!m_dwz_common_file) + return nullptr; +return m_dwz_common_file->SymbolFile(); + } + bool GetIsDWZ() const { return m_is_dwz; } + protected: typedef llvm::DenseMap DIEToTypePtr; @@ -473,6 +482,45 @@ SymbolFileDWARFDwp *GetDwpSymbolFile(); + void InitializeDWZ(); + + class DWZCommonFile { + public: +// C++14: Use heterogenous lookup. +DWZCommonFile(const lldb_private::FileSpec &filespec_ref); +DWZCommonFile(std::unique_ptr symbol_file, +lldb::ObjectFileSP obj_file, lldb::ModuleSP module); +SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); } + +bool operator==(const DWZCommonFile &rhs) const { + return m_filespec_ref == rhs.m_filespec_ref; +} +bool operator!=(const DWZCommonFile &rhs) const { return !(*this == rhs); } +class Hasher { +public: + size_t operator()(const DWZCommonFile &key) const { +return lldb_private::FileSpec::Hasher()(key.m_filespec_ref); + } +}; + +size_t m_use_count = 0; + + private: +std::unique_ptr m_symbol_file; +lldb::ObjectFileSP m_obj_file; +lldb::ModuleSP m_module; +const lldb_private::FileSpec &m_filespec_ref; + +DISALLOW_COPY_AND_ASSIGN(DWZCommonFile); + }; + DWZCommonFile *m_dwz_common_file = nullptr; + void DWZCommonFileSet(DWZCommonFile *dwz_common_file); + void DWZCommonFileClear(); + static std::unordered_set + m_filespec_to_dwzcommonfile; + static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex; + bool m_is_dwz = false; + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap *m_debug_map_symfile; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -410,7 +410,9 @@ m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map() {} -S
[Lldb-commits] [PATCH] D40475: DWZ 06/07: DWZ test mode
jankratochvil updated this revision to Diff 143480. jankratochvil retitled this revision from "DWZ 10/11: DWZ test mode" to "DWZ 06/07: DWZ test mode". https://reviews.llvm.org/D40475 Files: packages/Python/lldbsuite/test/dotest.py packages/Python/lldbsuite/test/lldbinline.py packages/Python/lldbsuite/test/lldbtest.py packages/Python/lldbsuite/test/make/Makefile.rules packages/Python/lldbsuite/test/plugins/builder_base.py packages/Python/lldbsuite/test/test_categories.py unittests/SymbolFile/CMakeLists.txt unittests/SymbolFile/DWZ/CMakeLists.txt unittests/SymbolFile/DWZ/Inputs/dwztest.c unittests/SymbolFile/DWZ/Inputs/dwztest.debug unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz unittests/SymbolFile/DWZ/Inputs/dwztest.out unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp === --- /dev/null +++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp @@ -0,0 +1,89 @@ +//===-- SymbolFileDWZTests.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "gtest/gtest.h" + +#include "TestingSupport/TestUtilities.h" + +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "lldb/Core/Module.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/FileSpec.h" + +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include +#endif + +#include + +using namespace lldb_private; + +class SymbolFileDWZTests : public testing::Test { +public: + void SetUp() override { +// Initialize and TearDown the plugin every time, so we get a brand new +// AST every time so that modifications to the AST from each test don't +// leak into the next test. +#if defined(_MSC_VER) +::CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif + +HostInfo::Initialize(); +SymbolFileDWARF::Initialize(); +ClangASTContext::Initialize(); +ObjectFileELF::Initialize(); +SymbolVendorELF::Initialize(); + +m_dwztest_out = GetInputFilePath("dwztest.out"); + } + + void TearDown() override { +SymbolVendorELF::Terminate(); +ObjectFileELF::Terminate(); +ClangASTContext::Terminate(); +SymbolFileDWARF::Terminate(); +HostInfo::Terminate(); + +#if defined(_MSC_VER) +::CoUninitialize(); +#endif + } + +protected: + std::string m_dwztest_out; +}; + +TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) { + FileSpec fspec(m_dwztest_out.c_str(), false); + ArchSpec aspec("x86_64-pc-linux"); + lldb::ModuleSP module = std::make_shared(fspec, aspec); + + SymbolVendor *plugin = module->GetSymbolVendor(); + EXPECT_NE(nullptr, plugin); + SymbolFile *symfile = plugin->GetSymbolFile(); + EXPECT_NE(nullptr, symfile); + EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); + SymbolContext sc; + llvm::DenseSet searched_files; + TypeMap results; + EXPECT_EQ(1u, + symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr, + false, 0, searched_files, results)); + EXPECT_EQ(1u, results.GetSize()); + lldb::TypeSP udt_type = results.GetTypeAtIndex(0); + EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName()); + CompilerType compiler_type = udt_type->GetForwardCompilerType(); + EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType())); +} Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c === --- /dev/null +++ unittests/SymbolFile/DWZ/Inputs/dwztest.c @@ -0,0 +1,9 @@ +// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out + +struct StructMovedToDWZCommonFile { + int i1, i2, i3, i4, i5, i6, i7, i8, i9; +} VarWithStructMovedToDWZCommonFile; +static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile); +int main() { + return sizeof_StructMovedToDWZCommonFile; +} Index: unittests/SymbolFile/DWZ/CMakeLists.txt === --- /dev/null +++ unittests/SymbolFile/DWZ/CMakeLists.txt @@ -0,0 +1,21 @@ +add_lldb_unittest(SymbolFileDWZTests + SymbolFileDWZTests.cpp + + LINK_LIBS +lldbCore +lldbHost +lldbSymbol +lldbPluginSymbolFileDWARF +lldbUtilityHelpers +lldbPluginObjectFileELF +lldbPluginSymbolVendorELF + LIN
[Lldb-commits] [PATCH] D43512: DWZ 07/07: Fix for symlinked .build-id/**.debug files
jankratochvil updated this revision to Diff 143481. jankratochvil retitled this revision from "DWZ 11/11: Fix for symlinked .build-id/**.debug files" to "DWZ 07/07: Fix for symlinked .build-id/**.debug files". https://reviews.llvm.org/D43512 Files: packages/Python/lldbsuite/test/decorators.py packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py packages/Python/lldbsuite/test/linux/buildidsymlink/main.c source/Host/common/Symbols.cpp Index: source/Host/common/Symbols.cpp === --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -283,6 +283,8 @@ if (llvm::sys::fs::equivalent(file_spec.GetPath(), module_file_spec.GetPath())) continue; +if (FileSystem::ResolveSymbolicLink(file_spec, file_spec).Fail()) + continue; if (file_spec.Exists()) { lldb_private::ModuleSpecList specs; Index: packages/Python/lldbsuite/test/linux/buildidsymlink/main.c === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/main.c @@ -0,0 +1,6 @@ +struct s { + int i1, i2, i3, i4, i5, i6, i7, i8, i9; +} v; +int main() { + return 0; +} Index: packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py @@ -0,0 +1,24 @@ +""" Testing separate debug info loading for base binary with a symlink. """ +import os +import time +import lldb +import sys +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTargetSymbolsBuildidSymlink(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test # Prevent the genaration of the dwarf version of this test +@skipUnlessPlatform(['linux']) +@skipIf(hostoslist=["windows"]) +@skipIfRemote # llvm.org/pr36237 +@skipUnlessDWZInstalled +def test_target_symbols_buildid_symlink(self): +self.build(clean=True) +exe = self.getBuildArtifact("stripped.out") + +lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe) Index: packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile @@ -0,0 +1,24 @@ +LEVEL = ../../make +C_SOURCES := main.c +LD_EXTRAS += -Wl,--build-id=sha1 + +all: .build-id + +.PHONY: .build-id +stripped.out stripped.debug stripped.debug.dwz: a.out + eu-strip --remove-comment -f stripped.debug -F stripped.debugx -o stripped.out $< + cp -p stripped.debug stripped.debug.dup + dwz -m stripped.debug.dwz stripped.debug stripped.debug.dup + +.build-id: stripped.debug + $(OBJCOPY) -j .note.gnu.build-id -O binary $< tmp + rm -rf .build-id + fn=`od -An -tx1 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40474: DWZ 05/07: Main functionality
jankratochvil updated this revision to Diff 143483. https://reviews.llvm.org/D40474 Files: include/lldb/Utility/ConstString.h include/lldb/Utility/FileSpec.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Utility/DataEncoder.cpp source/Utility/DataExtractor.cpp Index: source/Utility/DataExtractor.cpp === --- source/Utility/DataExtractor.cpp +++ source/Utility/DataExtractor.cpp @@ -232,7 +232,8 @@ if (data != nullptr) { const uint8_t *data_bytes = data->GetBytes(); if (data_bytes != nullptr) { -assert(m_start >= data_bytes); +// For DWARFDataExtractor::OffsetData we need to return negative value. +// assert(m_start >= data_bytes); return m_start - data_bytes; } } Index: source/Utility/DataEncoder.cpp === --- source/Utility/DataEncoder.cpp +++ source/Utility/DataEncoder.cpp @@ -81,7 +81,8 @@ if (data != nullptr) { const uint8_t *data_bytes = data->GetBytes(); if (data_bytes != nullptr) { -assert(m_start >= data_bytes); +// For DWARFDataExtractor::OffsetData we need to return negative value. +// assert(m_start >= data_bytes); return m_start - data_bytes; } } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -18,10 +18,12 @@ #include #include #include +#include // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Threading.h" +#include "llvm/Support/RWMutex.h" #include "lldb/Utility/Flags.h" @@ -312,6 +314,13 @@ // the method returns a pointer to the base compile unit. virtual DWARFUnit *GetBaseCompileUnit(); + SymbolFileDWARF *GetDWZSymbolFile() const { +if (!m_dwz_common_file) + return nullptr; +return m_dwz_common_file->SymbolFile(); + } + bool GetIsDWZ() const { return m_is_dwz; } + protected: typedef llvm::DenseMap DIEToTypePtr; @@ -473,6 +482,45 @@ SymbolFileDWARFDwp *GetDwpSymbolFile(); + void InitializeDWZ(); + + class DWZCommonFile { + public: +// C++14: Use heterogenous lookup. +DWZCommonFile(const lldb_private::FileSpec &filespec_ref); +DWZCommonFile(std::unique_ptr symbol_file, +lldb::ObjectFileSP obj_file, lldb::ModuleSP module); +SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); } + +bool operator==(const DWZCommonFile &rhs) const { + return m_filespec_ref == rhs.m_filespec_ref; +} +bool operator!=(const DWZCommonFile &rhs) const { return !(*this == rhs); } +class Hasher { +public: + size_t operator()(const DWZCommonFile &key) const { +return lldb_private::FileSpec::Hasher()(key.m_filespec_ref); + } +}; + +size_t m_use_count = 0; + + private: +std::unique_ptr m_symbol_file; +lldb::ObjectFileSP m_obj_file; +lldb::ModuleSP m_module; +const lldb_private::FileSpec &m_filespec_ref; + +DISALLOW_COPY_AND_ASSIGN(DWZCommonFile); + }; + DWZCommonFile *m_dwz_common_file = nullptr; + void DWZCommonFileSet(DWZCommonFile *dwz_common_file); + void DWZCommonFileClear(); + static std::unordered_set + m_filespec_to_dwzcommonfile; + static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex; + bool m_is_dwz = false; + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap *m_debug_map_symfile; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -410,7 +410,9 @@ m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map() {} -SymbolFileDWARF::~SymbolFileDWARF() {} +SymbolFileDWARF::~SymbolFileDWARF() { + DWZCommonFileClear(); +} static const ConstString &GetDWARFMachOSegmentName() { static ConstString g_dwarf_section_name("__DWARF"); @@ -426,6 +428,7 @@ } TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) { + lldbassert(!GetIsDWZ()); SymbolFileDWARFDebugMap *debug_map_sy