diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -25,6 +25,7 @@ #include "llvm/Support/DJB.h" #include "llvm/Support/Debug.h" #include +#include #include /// \file @@ -312,7 +313,7 @@ void emitDWARF5AccelTable( AsmPrinter *Asm, AccelTable &Contents, - ArrayRef CUs, + ArrayRef> CUs, llvm::function_ref getCUIndexForEntry); diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -213,7 +213,7 @@ Header Header; DenseMap> Abbreviations; - ArrayRef CompUnits; + ArrayRef> CompUnits; llvm::function_ref getCUIndexForEntry; MCSymbol *ContributionEnd = nullptr; MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start"); @@ -235,7 +235,7 @@ public: Dwarf5AccelTableWriter( AsmPrinter *Asm, const AccelTableBase &Contents, - ArrayRef CompUnits, + ArrayRef> CompUnits, llvm::function_ref GetCUIndexForEntry); void emit(); @@ -419,7 +419,10 @@ void Dwarf5AccelTableWriter::emitCUList() const { for (const auto &CU : enumerate(CompUnits)) { Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index())); - Asm->emitDwarfSymbolReference(CU.value()); + if (std::holds_alternative(CU.value())) + Asm->emitDwarfSymbolReference(std::get(CU.value())); + else + Asm->emitDwarfLengthOrOffset(std::get(CU.value())); } } @@ -508,7 +511,7 @@ template Dwarf5AccelTableWriter::Dwarf5AccelTableWriter( AsmPrinter *Asm, const AccelTableBase &Contents, - ArrayRef CompUnits, + ArrayRef> CompUnits, llvm::function_ref getCUIndexForEntry) : AccelTableWriter(Asm, Contents, false), Header(CompUnits.size(), Contents.getBucketCount(), @@ -545,7 +548,7 @@ void llvm::emitDWARF5AccelTable( AsmPrinter *Asm, AccelTable &Contents, const DwarfDebug &DD, ArrayRef> CUs) { - std::vector CompUnits; + std::vector> CompUnits; SmallVector CUIndex(CUs.size()); int Count = 0; for (const auto &CU : enumerate(CUs)) { @@ -581,7 +584,7 @@ void llvm::emitDWARF5AccelTable( AsmPrinter *Asm, AccelTable &Contents, - ArrayRef CUs, + ArrayRef> CUs, llvm::function_ref getCUIndexForEntry) { Contents.finalize(Asm, "names"); diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp --- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp +++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp @@ -276,7 +276,7 @@ return; // Build up data structures needed to emit this section. - std::vector CompUnits; + std::vector> CompUnits; DenseMap UniqueIdToCuMap; unsigned Id = 0; for (auto &CU : EmittedUnits) { diff --git a/llvm/lib/DWARFLinkerParallel/ArrayList.h b/llvm/lib/DWARFLinkerParallel/ArrayList.h --- a/llvm/lib/DWARFLinkerParallel/ArrayList.h +++ b/llvm/lib/DWARFLinkerParallel/ArrayList.h @@ -18,35 +18,39 @@ /// This class is a simple list of T structures. It keeps elements as /// pre-allocated groups to save memory for each element's next pointer. /// It allocates internal data using specified per-thread BumpPtrAllocator. +/// Method add() can be called asynchronously. template class ArrayList { public: - /// Copy specified \p Item into the list. - T ¬eItem(const T &Item) { + /// Add specified \p Item to the list. + T &add(const T &Item) { assert(Allocator != nullptr); - ItemsGroup *CurGroup = LastGroup; - - if (CurGroup == nullptr) { - // Allocate first ItemsGroup. - LastGroup = Allocator->Allocate(); - LastGroup->ItemsCount = 0; - LastGroup->Next = nullptr; - GroupsHead = LastGroup; - CurGroup = LastGroup; + // Allocate head group if it is not allocated yet. + while (LastGroup == nullptr) { + if (allocateNewGroup(GroupsHead, nullptr)) + LastGroup = GroupsHead.load(); } - if (CurGroup->ItemsCount == ItemsGroupSize) { - // Allocate next ItemsGroup if current one is full. - LastGroup = Allocator->Allocate(); - LastGroup->ItemsCount = 0; - LastGroup->Next = nullptr; - CurGroup->Next = LastGroup; + ItemsGroup *CurGroup; + size_t CurItemsCount; + do { CurGroup = LastGroup; - } + CurItemsCount = CurGroup->ItemsCount.fetch_add(1); + + // Check whether current group is full. + if (CurItemsCount < ItemsGroupSize) + break; - // Copy item into the next position inside current ItemsGroup. - CurGroup->Items[CurGroup->ItemsCount] = Item; - return CurGroup->Items[CurGroup->ItemsCount++]; + // Allocate next group if necessary. + if (CurGroup->Next == nullptr) + allocateNewGroup(CurGroup->Next, nullptr); + + LastGroup.compare_exchange_weak(CurGroup, CurGroup->Next); + } while (true); + + // Store item into the current group. + CurGroup->Items[CurItemsCount] = Item; + return CurGroup->Items[CurItemsCount]; } using ItemHandlerTy = function_ref; @@ -55,9 +59,8 @@ void forEach(ItemHandlerTy Handler) { for (ItemsGroup *CurGroup = GroupsHead; CurGroup != nullptr; CurGroup = CurGroup->Next) { - for (size_t Idx = 0; Idx < CurGroup->ItemsCount; Idx++) { + for (size_t Idx = 0; Idx < CurGroup->getItemsCount(); Idx++) Handler(CurGroup->Items[Idx]); - } } } @@ -77,12 +80,41 @@ protected: struct ItemsGroup { std::array Items; - ItemsGroup *Next = nullptr; - size_t ItemsCount = 0; + std::atomic Next = nullptr; + std::atomic ItemsCount = 0; + + size_t getItemsCount() const { + return std::min(ItemsCount.load(), ItemsGroupSize); + } }; - ItemsGroup *GroupsHead = nullptr; - ItemsGroup *LastGroup = nullptr; + bool allocateNewGroup(std::atomic &AtomicGroup, + ItemsGroup *Group) { + // Allocate new group. + ItemsGroup *NewGroup = Allocator->Allocate(); + NewGroup->ItemsCount = 0; + NewGroup->Next = nullptr; + + // Try to replace current group with allocated one. + if (AtomicGroup.compare_exchange_weak(Group, NewGroup)) + return true; + + // Put allocated group as next group. + ItemsGroup *NextGroup = Group; + while (NextGroup != nullptr) { + NextGroup = NextGroup->Next; + + if (NextGroup == nullptr) { + if (NextGroup->Next.compare_exchange_weak(NextGroup, NewGroup)) + break; + } + } + + return false; + } + + std::atomic GroupsHead = nullptr; + std::atomic LastGroup = nullptr; parallel::PerThreadBumpPtrAllocator *Allocator = nullptr; }; diff --git a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h b/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h --- a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h +++ b/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.h @@ -17,6 +17,31 @@ namespace llvm { namespace dwarflinker_parallel { +/// Information gathered and exchanged between the various +/// clone*Attr helpers about the attributes of a particular DIE. +struct AttributesInfo { + AttributesInfo() { + HasLiveAddress = false; + IsDeclaration = false; + HasRanges = false; + } + + /// Short Name. + StringEntry *Name = nullptr; + + /// Mangled Name. + StringEntry *MangledName = nullptr; + + /// Does the DIE have an address pointing to live code section? + bool HasLiveAddress : 1; + + /// Is this DIE only a declaration? + bool IsDeclaration : 1; + + /// Does the DIE have a ranges attribute? + bool HasRanges : 1; +}; + /// This class creates clones of input DIE attributes. /// It enumerates attributes of input DIE, creates clone for each /// attribute, adds cloned attribute to the output DIE. @@ -43,26 +68,7 @@ /// Create abbreviations for the output DIE after all attributes are cloned. unsigned finalizeAbbreviations(bool HasChildrenToClone); - /// Information gathered and exchanged between the various - /// clone*Attr helpers about the attributes of a particular DIE. - /// /// Cannot be used concurrently. - struct AttributesInfo { - /// Names. - StringEntry *Name = nullptr; - StringEntry *MangledName = nullptr; - StringEntry *NameWithoutTemplate = nullptr; - - /// Does the DIE have a low_pc attribute? - bool HasLowPc = false; - - /// Is this DIE only a declaration? - bool IsDeclaration = false; - - /// Does the DIE have a ranges attribute? - bool HasRanges = false; - }; - AttributesInfo AttrInfo; protected: diff --git a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp b/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp --- a/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp +++ b/llvm/lib/DWARFLinkerParallel/DIEAttributeCloner.cpp @@ -285,6 +285,11 @@ } } + if (AttrSpec.Attr == dwarf::DW_AT_const_value && + (InputDieEntry->getTag() == dwarf::DW_TAG_variable || + InputDieEntry->getTag() == dwarf::DW_TAG_constant)) + AttrInfo.HasLiveAddress = true; + if (CU.getGlobalData().getOptions().UpdateIndexTablesOnly) { if (auto OptionalValue = Val.getAsUnsignedConstant()) Value = *OptionalValue; @@ -450,6 +455,11 @@ (AttrOutOffset + (FinalAttributeSize - Bytes.size())); } + if (HasLocationExpressionAddress) + AttrInfo.HasLiveAddress = + VarAddressAdjustment.has_value() || + CU.getGlobalData().getOptions().UpdateIndexTablesOnly; + return FinalAttributeSize; } @@ -457,7 +467,7 @@ const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec) { if (AttrSpec.Attr == dwarf::DW_AT_low_pc) - AttrInfo.HasLowPc = true; + AttrInfo.HasLiveAddress = true; if (CU.getGlobalData().getOptions().UpdateIndexTablesOnly) return Generator diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h --- a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h +++ b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.h @@ -35,10 +35,12 @@ template class AccelTable; class MCCodeEmitter; -class DWARFDebugMacro; namespace dwarflinker_parallel { +using DebugNamesUnitsOffsets = std::vector>; +using CompUnitIDToIdx = DenseMap; + /// This class emits DWARF data to the output stream. It emits already /// generated section data and specific data, which could not be generated /// by CompileUnit. @@ -82,9 +84,13 @@ void emitZeroString(); /// Emit strings into the .debug_str section. - void emitStrings(ArrayList &StringPatches, + template + void emitStrings(ArrayList &StringPatches, const StringEntryToDwarfStringPoolEntryMap &Strings, - uint64_t &NextOffset); + uint64_t &NextOffset) { + emitStringsImpl(StringPatches, Strings, NextOffset, + MOFI->getDwarfStrSection()); + } /// Emit strings into the .debug_line_str section. void emitLineStrings(ArrayList &StringPatches, @@ -100,6 +106,23 @@ /// Returns size of generated .debug_info section. uint64_t getDebugInfoSectionSize() const { return DebugInfoSectionSize; } + /// Emits .debug_names section according to the specified \p Table. + void emitDebugNames(AccelTable &Table, + DebugNamesUnitsOffsets &CUOffsets, + CompUnitIDToIdx &UnitIDToIdxMap); + + /// Emits .apple_names section according to the specified \p Table. + void emitAppleNames(AccelTable &Table); + + /// Emits .apple_namespaces section according to the specified \p Table. + void emitAppleNamespaces(AccelTable &Table); + + /// Emits .apple_objc section according to the specified \p Table. + void emitAppleObjc(AccelTable &Table); + + /// Emits .apple_types section according to the specified \p Table. + void emitAppleTypes(AccelTable &Table); + private: // Enumerate all string patches and write them into the destination section. // Order of patches is the same as in original input file. To avoid emitting diff --git a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp --- a/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp +++ b/llvm/lib/DWARFLinkerParallel/DWARFEmitterImpl.cpp @@ -164,6 +164,10 @@ .Case("debug_macro", MC->getObjectFileInfo()->getDwarfMacroSection()) .Case("debug_macinfo", MC->getObjectFileInfo()->getDwarfMacinfoSection()) .Case("debug_addr", MC->getObjectFileInfo()->getDwarfAddrSection()) + .Case("debug_pubnames", + MC->getObjectFileInfo()->getDwarfPubNamesSection()) + .Case("debug_pubtypes", + MC->getObjectFileInfo()->getDwarfPubTypesSection()) .Default(nullptr); } @@ -219,13 +223,6 @@ }); } -void DwarfEmitterImpl::emitStrings( - ArrayList &StringPatches, - const StringEntryToDwarfStringPoolEntryMap &Strings, uint64_t &NextOffset) { - emitStringsImpl(StringPatches, Strings, NextOffset, - MOFI->getDwarfStrSection()); -} - void DwarfEmitterImpl::emitLineStrings( ArrayList &StringPatches, const StringEntryToDwarfStringPoolEntryMap &Strings, uint64_t &NextOffset) { @@ -240,7 +237,7 @@ // Emit size of content not including length itself. The size has already // been computed in CompileUnit::computeOffsets(). Subtract 4 to that size to // account for the length field. - Asm->emitInt32(Unit.getHeaderSize() + Unit.getOutUnitDIE()->getSize() - 4); + Asm->emitInt32(Unit.getUnitSize() - 4); Asm->emitInt16(Unit.getVersion()); if (Unit.getVersion() >= 5) { @@ -263,5 +260,60 @@ DebugInfoSectionSize += Die.getSize(); } +void DwarfEmitterImpl::emitDebugNames( + AccelTable &Table, + DebugNamesUnitsOffsets &CUOffsets, CompUnitIDToIdx &CUidToIdx) { + if (CUOffsets.empty()) + return; + + Asm->OutStreamer->switchSection(MOFI->getDwarfDebugNamesSection()); + emitDWARF5AccelTable(Asm.get(), Table, CUOffsets, + [&CUidToIdx](const DWARF5AccelTableStaticData &Entry) { + return CUidToIdx[Entry.getCUIndex()]; + }); +} + +void DwarfEmitterImpl::emitAppleNamespaces( + AccelTable &Table) { + Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamespaceSection()); + auto *SectionBegin = Asm->createTempSymbol("namespac_begin"); + Asm->OutStreamer->emitLabel(SectionBegin); + emitAppleAccelTable(Asm.get(), Table, "namespac", SectionBegin); +} + +void DwarfEmitterImpl::emitAppleNames( + AccelTable &Table) { + Asm->OutStreamer->switchSection(MOFI->getDwarfAccelNamesSection()); + auto *SectionBegin = Asm->createTempSymbol("names_begin"); + Asm->OutStreamer->emitLabel(SectionBegin); + emitAppleAccelTable(Asm.get(), Table, "names", SectionBegin); +} + +void DwarfEmitterImpl::emitAppleObjc( + AccelTable &Table) { + Asm->OutStreamer->switchSection(MOFI->getDwarfAccelObjCSection()); + auto *SectionBegin = Asm->createTempSymbol("objc_begin"); + Asm->OutStreamer->emitLabel(SectionBegin); + emitAppleAccelTable(Asm.get(), Table, "objc", SectionBegin); +} + +void DwarfEmitterImpl::emitAppleTypes( + AccelTable &Table) { + Asm->OutStreamer->switchSection(MOFI->getDwarfAccelTypesSection()); + auto *SectionBegin = Asm->createTempSymbol("types_begin"); + Asm->OutStreamer->emitLabel(SectionBegin); + emitAppleAccelTable(Asm.get(), Table, "types", SectionBegin); +} + +template void DwarfEmitterImpl::emitStringsImpl( + ArrayList &StringPatches, + const StringEntryToDwarfStringPoolEntryMap &Strings, uint64_t &NextOffset, + MCSection *OutSection); + +template void DwarfEmitterImpl::emitStringsImpl( + ArrayList &StringPatches, + const StringEntryToDwarfStringPoolEntryMap &Strings, uint64_t &NextOffset, + MCSection *OutSection); + } // end of namespace dwarflinker_parallel } // namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.h @@ -18,6 +18,8 @@ using OffsetToUnitTy = function_ref; +struct AttributesInfo; + /// Stores all information related to a compile unit, be it in its original /// instance of the object file or its brand new cloned and generated DIE tree. class CompileUnit : public DwarfUnit { @@ -511,6 +513,14 @@ uint64_t OffsetToMacroTable, SectionDescriptor &Section, bool hasDWARFv5Header); + /// Store accelerator information for the \p InputDieEntry. + void rememberAcceleratorEntries(const DWARFDebugInfoEntry *InputDieEntry, + uint64_t OutOffset, AttributesInfo &AttrInfo); + + /// Store ObjC accelerator information for the \p InputDieEntry. + void rememberObjCAccelerator(const DWARFDebugInfoEntry *InputDieEntry, + uint64_t OutOffset, AttributesInfo &AttrInfo); + /// DWARFFile containing this compile unit. DWARFFile &File; @@ -526,9 +536,9 @@ ResolvedPathsMap ResolvedFullPaths; StringMap ResolvedParentPaths; - /// This field instructs compile unit to store DIE name with stripped - /// template parameters into the accelerator table. - bool CanStripTemplateName = false; + /// This field instructs compile unit to store DIE name + /// into the objc accelerator table. + bool needRememberObjCAccelerator = false; /// Address to index map. DenseMap AddrIndexMap; diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerCompileUnit.cpp @@ -10,6 +10,7 @@ #include "DIEAttributeCloner.h" #include "DIEGenerator.h" #include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h" +#include "llvm/Support/DJB.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatVariadic.h" @@ -24,8 +25,8 @@ if (getStage() <= Stage::Loaded) return; - for (DIEInfo &DieInfo : DieInfoArray) - DieInfo.unsetFlagsWhichSetDuringLiveAnalysis(); + for (DIEInfo &Info : DieInfoArray) + Info.unsetFlagsWhichSetDuringLiveAnalysis(); LowPc = std::nullopt; HighPc = 0; @@ -37,6 +38,7 @@ return; } + AcceleratorRecords.erase(); AbbreviationsSet.clear(); Abbreviations.clear(); OutUnitDIE = nullptr; @@ -1080,7 +1082,7 @@ if (!OrigUnitDIE.isValid()) return Error::success(); - CanStripTemplateName = + needRememberObjCAccelerator = llvm::is_contained(getGlobalData().getOptions().AccelTables, DWARFLinker::AccelTableKind::Apple); @@ -1115,6 +1117,11 @@ if (Error Err = emitDebugAddrSection()) return Err; + // Generate Pub accelerator tables. + if (llvm::is_contained(GlobalData.getOptions().AccelTables, + DWARFLinker::AccelTableKind::Pub)) + emitPubAccelerators(); + return emitAbbreviations(); } @@ -1161,6 +1168,10 @@ VarAddressAdjustment, HasLocationExpressionAddress); AttributesCloner.clone(); + // Remember accelerator info. + rememberAcceleratorEntries(InputDieEntry, OutOffset, + AttributesCloner.AttrInfo); + bool HasChildrenToClone = Info.getKeepChildren(); OutOffset = AttributesCloner.finalizeAbbreviations(HasChildrenToClone); @@ -1340,3 +1351,259 @@ llvm::errs() << "}\n"; } #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) + +static std::optional stripTemplateParameters(StringRef Name) { + // We are looking for template parameters to strip from Name. e.g. + // + // operator< + // + // We look for > at the end but if it does not contain any < then we + // have something like operator>>. We check for the operator<=> case. + if (!Name.endswith(">") || Name.count("<") == 0 || Name.endswith("<=>")) + return {}; + + // How many < until we have the start of the template parameters. + size_t NumLeftAnglesToSkip = 1; + + // If we have operator<=> then we need to skip its < as well. + NumLeftAnglesToSkip += Name.count("<=>"); + + size_t RightAngleCount = Name.count('>'); + size_t LeftAngleCount = Name.count('<'); + + // If we have more < than > we have operator< or operator<< + // we to account for their < as well. + if (LeftAngleCount > RightAngleCount) + NumLeftAnglesToSkip += LeftAngleCount - RightAngleCount; + + size_t StartOfTemplate = 0; + while (NumLeftAnglesToSkip--) + StartOfTemplate = Name.find('<', StartOfTemplate) + 1; + + return Name.substr(0, StartOfTemplate - 1); +} + +static uint32_t hashFullyQualifiedName(CompileUnit *InputCU, DWARFDie &InputDIE, + int ChildRecurseDepth = 0) { + const char *Name = nullptr; + CompileUnit *CU = InputCU; + std::optional RefVal; + + while (true) { + if (const char *CurrentName = InputDIE.getName(DINameKind::ShortName)) + Name = CurrentName; + + if (!(RefVal = InputDIE.find(dwarf::DW_AT_specification)) && + !(RefVal = InputDIE.find(dwarf::DW_AT_abstract_origin))) + break; + + if (!RefVal->isFormClass(DWARFFormValue::FC_Reference)) + break; + + std::optional> RefDie = + CU->resolveDIEReference(*RefVal); + if (!RefDie) + break; + + assert(RefDie->second != 0); + + CU = RefDie->first; + InputDIE = RefDie->first->getDIEAtIndex(RefDie->second); + } + + if (!Name && InputDIE.getTag() == dwarf::DW_TAG_namespace) + Name = "(anonymous namespace)"; + + DWARFDie ParentDie = InputDIE.getParent(); + if (!ParentDie.isValid() || + ParentDie.getTag() == dwarf::DW_TAG_compile_unit || + // FIXME: dsymutil-classic compatibility. Ignore modules. + ParentDie.getTag() == dwarf::DW_TAG_module) + return djbHash(Name ? Name : "", djbHash(ChildRecurseDepth ? "" : "::")); + + return djbHash( + (Name ? Name : ""), + djbHash((Name ? "::" : ""), + hashFullyQualifiedName(CU, ParentDie, ++ChildRecurseDepth))); +} + +static bool isObjCSelector(StringRef Name) { + return Name.size() > 2 && (Name[0] == '-' || Name[0] == '+') && + (Name[1] == '['); +} + +void CompileUnit::rememberAcceleratorEntries( + const DWARFDebugInfoEntry *InputDieEntry, uint64_t OutOffset, + AttributesInfo &AttrInfo) { + if (GlobalData.getOptions().AccelTables.empty()) + return; + + DWARFDie InputDIE = getDIE(InputDieEntry); + + // Look for short name recursively if short name is not known yet. + if (AttrInfo.Name == nullptr) + if (const char *ShortName = InputDIE.getShortName()) + AttrInfo.Name = getGlobalData().getStringPool().insert(ShortName).first; + + switch (InputDieEntry->getTag()) { + case dwarf::DW_TAG_array_type: + case dwarf::DW_TAG_class_type: + case dwarf::DW_TAG_enumeration_type: + case dwarf::DW_TAG_pointer_type: + case dwarf::DW_TAG_reference_type: + case dwarf::DW_TAG_string_type: + case dwarf::DW_TAG_structure_type: + case dwarf::DW_TAG_subroutine_type: + case dwarf::DW_TAG_typedef: + case dwarf::DW_TAG_union_type: + case dwarf::DW_TAG_ptr_to_member_type: + case dwarf::DW_TAG_set_type: + case dwarf::DW_TAG_subrange_type: + case dwarf::DW_TAG_base_type: + case dwarf::DW_TAG_const_type: + case dwarf::DW_TAG_constant: + case dwarf::DW_TAG_file_type: + case dwarf::DW_TAG_namelist: + case dwarf::DW_TAG_packed_type: + case dwarf::DW_TAG_volatile_type: + case dwarf::DW_TAG_restrict_type: + case dwarf::DW_TAG_atomic_type: + case dwarf::DW_TAG_interface_type: + case dwarf::DW_TAG_unspecified_type: + case dwarf::DW_TAG_shared_type: + case dwarf::DW_TAG_immutable_type: + case dwarf::DW_TAG_rvalue_reference_type: { + if (!AttrInfo.IsDeclaration && AttrInfo.Name != nullptr && + !AttrInfo.Name->getKey().empty()) { + uint32_t Hash = hashFullyQualifiedName(this, InputDIE); + + uint64_t RuntimeLang = + dwarf::toUnsigned(InputDIE.find(dwarf::DW_AT_APPLE_runtime_class)) + .value_or(0); + + bool ObjCClassIsImplementation = + (RuntimeLang == dwarf::DW_LANG_ObjC || + RuntimeLang == dwarf::DW_LANG_ObjC_plus_plus) && + dwarf::toUnsigned( + InputDIE.find(dwarf::DW_AT_APPLE_objc_complete_type)) + .value_or(0); + + rememberTypeForAccelerators(AttrInfo.Name, OutOffset, + InputDieEntry->getTag(), Hash, + ObjCClassIsImplementation); + } + } break; + case dwarf::DW_TAG_namespace: { + if (AttrInfo.Name == nullptr) + AttrInfo.Name = + getGlobalData().getStringPool().insert("(anonymous namespace)").first; + + rememberNamespaceForAccelerators(AttrInfo.Name, OutOffset, + InputDieEntry->getTag()); + } break; + case dwarf::DW_TAG_imported_declaration: { + if (AttrInfo.Name != nullptr) + rememberNamespaceForAccelerators(AttrInfo.Name, OutOffset, + InputDieEntry->getTag()); + } break; + case dwarf::DW_TAG_compile_unit: + case dwarf::DW_TAG_lexical_block: { + // Nothing to do. + } break; + default: + if (AttrInfo.HasLiveAddress || AttrInfo.HasRanges) { + if (AttrInfo.Name != nullptr) + rememberNameForAccelerators( + AttrInfo.Name, OutOffset, InputDieEntry->getTag(), + InputDieEntry->getTag() == dwarf::DW_TAG_inlined_subroutine); + + // Look for mangled name recursively if mangled name is not known yet. + if (AttrInfo.MangledName == nullptr) + if (const char *LinkageName = InputDIE.getLinkageName()) + AttrInfo.MangledName = + getGlobalData().getStringPool().insert(LinkageName).first; + + if (AttrInfo.MangledName != nullptr && + AttrInfo.MangledName != AttrInfo.Name) + rememberNameForAccelerators( + AttrInfo.MangledName, OutOffset, InputDieEntry->getTag(), + InputDieEntry->getTag() == dwarf::DW_TAG_inlined_subroutine); + + // Strip template parameters from the short name. + if (AttrInfo.Name != nullptr && AttrInfo.MangledName != AttrInfo.Name && + (InputDieEntry->getTag() != dwarf::DW_TAG_inlined_subroutine)) { + if (std::optional Name = + stripTemplateParameters(AttrInfo.Name->getKey())) { + StringEntry *NameWithoutTemplateParams = + getGlobalData().getStringPool().insert(*Name).first; + + rememberNameForAccelerators(NameWithoutTemplateParams, OutOffset, + InputDieEntry->getTag(), true); + } + } + + if (AttrInfo.Name && needRememberObjCAccelerator && + isObjCSelector(AttrInfo.Name->getKey())) + rememberObjCAccelerator(InputDieEntry, OutOffset, AttrInfo); + } + break; + } +} + +void CompileUnit::rememberObjCAccelerator( + const DWARFDebugInfoEntry *InputDieEntry, uint64_t OutOffset, + AttributesInfo &AttrInfo) { + assert(isObjCSelector(AttrInfo.Name->getKey()) && "not an objc selector"); + // Objective C method or class function. + // "- [Class(Category) selector :withArg ...]" + StringRef ClassNameStart(AttrInfo.Name->getKey().drop_front(2)); + size_t FirstSpace = ClassNameStart.find(' '); + if (FirstSpace == StringRef::npos) + return; + + StringRef SelectorStart(ClassNameStart.data() + FirstSpace + 1); + if (!SelectorStart.size()) + return; + + StringEntry *Selector = + getGlobalData() + .getStringPool() + .insert(StringRef(SelectorStart.data(), SelectorStart.size() - 1)) + .first; + rememberNameForAccelerators(Selector, OutOffset, InputDieEntry->getTag(), + true); + + // Add an entry for the class name that points to this + // method/class function. + StringEntry *ClassName = + getGlobalData() + .getStringPool() + .insert(StringRef(ClassNameStart.data(), FirstSpace)) + .first; + rememberObjCNameForAccelerators(ClassName, OutOffset, + InputDieEntry->getTag()); + + if (ClassName->getKey().ends_with(")")) { + size_t OpenParens = ClassName->getKey().find('('); + if (OpenParens != StringRef::npos) { + StringEntry *ClassNameNoCategory = + getGlobalData() + .getStringPool() + .insert(StringRef(ClassName->getKey().data(), OpenParens)) + .first; + rememberObjCNameForAccelerators(ClassNameNoCategory, OutOffset, + InputDieEntry->getTag()); + + std::string MethodNameNoCategoryStr(AttrInfo.Name->getKey().data(), + OpenParens + 2); + // FIXME: The missing space here may be a bug, but + // dsymutil-classic also does it this way. + MethodNameNoCategoryStr.append(std::string(SelectorStart)); + + StringEntry *MethodNameNoCategory = + getGlobalData().getStringPool().insert(MethodNameNoCategoryStr).first; + rememberNameForAccelerators(MethodNameNoCategory, OutOffset, + InputDieEntry->getTag(), true); + } + } +} diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.h @@ -339,12 +339,24 @@ void forEachSectionsSet( function_ref SectionsSetHandler); + /// Enumerates all comple units. + void forEachCompileUnit(function_ref UnitHandler); + /// Enumerates all patches and update them with the correct values. void patchOffsetsAndSizes(); + /// Create accelerator tables. + void buildAcceleratorTables(); + /// Enumerate all compile units and put their data into the output stream. void writeDWARFToTheOutput(); + std::unique_ptr> DebugNames; + std::unique_ptr> AppleNames; + std::unique_ptr> AppleNamespaces; + std::unique_ptr> AppleObjc; + std::unique_ptr> AppleTypes; + /// \defgroup Data members accessed asinchroniously. /// /// @{ diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerImpl.cpp @@ -742,7 +742,6 @@ uint64_t CurrentOffset = CU.getHeaderSize(); DIE *CUDie = ParentGenerator.createDIE(dwarf::DW_TAG_compile_unit, CurrentOffset); - CU.setOutUnitDIE(CUDie); DebugInfoSection.notePatchWithOffsetUpdate( DebugStrPatch{{CurrentOffset}, @@ -805,11 +804,7 @@ CurrentOffset += 1; // End of children CUDie->setSize(CurrentOffset - CUDie->getOffset()); - - uint64_t UnitSize = 0; - UnitSize += CU.getHeaderSize(); - UnitSize += CUDie->getSize(); - CU.setUnitSize(UnitSize); + CU.setOutUnitDIE(CUDie); if (GlobalData.getOptions().NoOutput) return Error::success(); @@ -831,7 +826,8 @@ // Patch size/offsets fields according to the assigned CU offsets. patchOffsetsAndSizes(); - // FIXME: Build accelerator tables. + // Build accelerator tables. + buildAcceleratorTables(); // Write debug tables from all object files/compile units into the // resulting file. @@ -921,13 +917,12 @@ uint64_t CurDebugLineStrOffset = 0; // To save space we do not create any separate string table. - // We use already allocated string patches and assign offsets - // to them in the natural order. + // We use already allocated string patches and accelerator entries: + // enumerate them in natural order and assign offsets. // ASSUMPTION: strings should be stored into .debug_str/.debug_line_str // sections in the same order as they were assigned offsets. - - forEachSectionsSet([&](OutputSections &SectionsSet) { - SectionsSet.forEach([&](SectionDescriptor &OutSection) { + forEachCompileUnit([&](CompileUnit *CU) { + CU->forEach([&](SectionDescriptor &OutSection) { assignOffsetsToStringsImpl(OutSection.ListDebugStrPatch, CurDebugStrIndex, CurDebugStrOffset, DebugStrStrings); @@ -935,6 +930,9 @@ CurDebugLineStrIndex, CurDebugLineStrOffset, DebugLineStrStrings); }); + + assignOffsetsToStringsImpl(CU->AcceleratorRecords, CurDebugStrIndex, + CurDebugStrOffset, DebugStrStrings); }); } @@ -985,6 +983,19 @@ } } +void DWARFLinkerImpl::forEachCompileUnit( + function_ref UnitHandler) { + // Enumerate module units. + for (const std::unique_ptr &Context : ObjectContexts) + for (LinkContext::RefModuleUnit &ModuleUnit : Context->ModulesCompileUnits) + UnitHandler(ModuleUnit.Unit.get()); + + // Enumerate compile units. + for (const std::unique_ptr &Context : ObjectContexts) + for (std::unique_ptr &CU : Context->CompileUnits) + UnitHandler(CU.get()); +} + void DWARFLinkerImpl::patchOffsetsAndSizes() { forEachSectionsSet([&](OutputSections &SectionsSet) { SectionsSet.forEach([&](SectionDescriptor &OutSection) { @@ -994,16 +1005,94 @@ }); } +void DWARFLinkerImpl::buildAcceleratorTables() { + parallel::TaskGroup TG; + + for (AccelTableKind CurAccelTable : GlobalData.Options.AccelTables) { + switch (CurAccelTable) { + case AccelTableKind::Apple: { + TG.spawn([&]() { + AppleNames = + std::make_unique>(); + AppleNamespaces = + std::make_unique>(); + AppleObjc = + std::make_unique>(); + AppleTypes = + std::make_unique>(); + + forEachCompileUnit([&](CompileUnit *CU) { + CU->AcceleratorRecords.forEach([&](const DwarfUnit::AccelInfo &Info) { + switch (Info.Type) { + case DwarfUnit::AccelType::None: { + assert(false); + } break; + case DwarfUnit::AccelType::Name: { + AppleNames->addName( + *DebugStrStrings.getExistingEntry(Info.String), + CU->getSectionDescriptor(DebugSectionKind::DebugInfo) + .StartOffset + + Info.OutOffset); + } break; + case DwarfUnit::AccelType::Namespace: { + AppleNamespaces->addName( + *DebugStrStrings.getExistingEntry(Info.String), + CU->getSectionDescriptor(DebugSectionKind::DebugInfo) + .StartOffset + + Info.OutOffset); + } break; + case DwarfUnit::AccelType::ObjC: { + AppleObjc->addName( + *DebugStrStrings.getExistingEntry(Info.String), + CU->getSectionDescriptor(DebugSectionKind::DebugInfo) + .StartOffset + + Info.OutOffset); + } break; + case DwarfUnit::AccelType::Type: { + AppleTypes->addName( + *DebugStrStrings.getExistingEntry(Info.String), + CU->getSectionDescriptor(DebugSectionKind::DebugInfo) + .StartOffset + + Info.OutOffset, + Info.Tag, + Info.ObjcClassImplementation + ? dwarf::DW_FLAG_type_implementation + : 0, + Info.QualifiedNameHash); + } break; + } + }); + }); + }); + } break; + case AccelTableKind::Pub: { + // Nothing to do. Already generated while compile units cloned. + } break; + case AccelTableKind::DebugNames: { + TG.spawn([&]() { + forEachCompileUnit([&](CompileUnit *CU) { + CU->AcceleratorRecords.forEach([&](const DwarfUnit::AccelInfo &Info) { + if (Info.OnlyAppleSections) + return; + + if (DebugNames.get() == nullptr) + DebugNames = + std::make_unique>(); + + DebugNames->addName(*DebugStrStrings.getExistingEntry(Info.String), + Info.OutOffset, Info.Tag, CU->getUniqueID()); + }); + }); + }); + } break; + } + } +} + void DWARFLinkerImpl::writeDWARFToTheOutput() { bool HasAbbreviations = false; - uint64_t DebugStrNextOffset = 0; - uint64_t DebugLineStrNextOffset = 0; - - // Emit zero length string. Accelerator tables does not work correctly - // if the first string is not zero length string. - TheDwarfEmitter->emitZeroString(); - DebugStrNextOffset++; + // Enumerate all sections and store them into the final emitter. forEachSectionsSet([&](OutputSections &Sections) { Sections.forEach([&](SectionDescriptor &OutSection) { if (OutSection.getContents().empty()) @@ -1017,23 +1106,70 @@ // Emit section content. TheDwarfEmitter->emitSectionContents(OutSection.getContents(), OutSection.getName()); + }); + }); + if (!HasAbbreviations) { + const SmallVector> Abbreviations; + TheDwarfEmitter->emitAbbrevs(Abbreviations, 3); + } + + // Enumerate all string patches and store strings into the final emitter. + uint64_t DebugStrNextOffset = 0; + uint64_t DebugLineStrNextOffset = 0; + + // Emit zero length string. Accelerator tables does not work correctly + // if the first string is not zero length string. + TheDwarfEmitter->emitZeroString(); + DebugStrNextOffset++; + + // ASSUMPTION: String patches are not used while generating objfile-common + // sections(like .debug_frame). Thus, only compile units and accelerator + // records are enumerated. + forEachCompileUnit([&](CompileUnit *CU) { + CU->forEach([&](SectionDescriptor &OutSection) { // Pass through string patches and emit them in order. if (!OutSection.ListDebugStrPatch.empty()) - TheDwarfEmitter->emitStrings(OutSection.ListDebugStrPatch, - DebugStrStrings, DebugStrNextOffset); + TheDwarfEmitter->emitStrings( + OutSection.ListDebugStrPatch, DebugStrStrings, DebugStrNextOffset); if (!OutSection.ListDebugLineStrPatch.empty()) TheDwarfEmitter->emitLineStrings(OutSection.ListDebugLineStrPatch, DebugLineStrStrings, DebugLineStrNextOffset); }); + + // Pass through accelerator entries and emit them in order. + TheDwarfEmitter->emitStrings( + CU->AcceleratorRecords, DebugStrStrings, DebugStrNextOffset); }); - if (!HasAbbreviations) { - const SmallVector> Abbreviations; - TheDwarfEmitter->emitAbbrevs(Abbreviations, 3); + if (DebugNames.get() != nullptr) { + DebugNamesUnitsOffsets CompUnits; + CompUnitIDToIdx CUidToIdx; + + unsigned Id = 0; + forEachCompileUnit([&](CompileUnit *CU) { + CompUnits.push_back( + CU->getSectionDescriptor(DebugSectionKind::DebugInfo).StartOffset); + + CUidToIdx[CU->getUniqueID()] = Id++; + }); + + TheDwarfEmitter->emitDebugNames(*DebugNames, CompUnits, CUidToIdx); } + + if (AppleNames.get() != nullptr) + TheDwarfEmitter->emitAppleNames(*AppleNames); + + if (AppleNamespaces.get() != nullptr) + TheDwarfEmitter->emitAppleNamespaces(*AppleNamespaces); + + if (AppleObjc.get() != nullptr) + TheDwarfEmitter->emitAppleObjc(*AppleObjc); + + if (AppleTypes.get() != nullptr) + TheDwarfEmitter->emitAppleTypes(*AppleTypes); } } // end of namespace dwarflinker_parallel diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.h @@ -33,6 +33,7 @@ : GlobalData(GlobalData), ID(ID), ClangModuleName(ClangModuleName), OutUnitDIE(nullptr) { setGlobalData(&GlobalData); + AcceleratorRecords.setAllocator(&GlobalData.getAllocator()); } /// Unique id of the unit. @@ -41,9 +42,6 @@ /// Return language of this unit. uint16_t getLanguage() const { return Language; } - /// Set size of this(newly generated) compile unit. - void setUnitSize(uint64_t UnitSize) { this->UnitSize = UnitSize; } - /// Returns size of this(newly generated) compile unit. uint64_t getUnitSize() const { return UnitSize; } @@ -81,7 +79,12 @@ DIE *getOutUnitDIE() { return OutUnitDIE; } /// Set output unit DIE. - void setOutUnitDIE(DIE *UnitDie) { OutUnitDIE = UnitDie; } + void setOutUnitDIE(DIE *UnitDie) { + OutUnitDIE = UnitDie; + + if (OutUnitDIE != nullptr) + UnitSize = getHeaderSize() + OutUnitDIE->getSize(); + } /// \defgroup Methods used to emit unit's debug info: /// @@ -97,18 +100,30 @@ const DWARFDebugLine::LineTable &OutLineTable); /// @} + /// \defgroup Methods used for reporting warnings and errors: + /// + /// @{ + void warn(const Twine &Warning) { GlobalData.warn(Warning, getUnitName()); } + + void error(const Twine &Err) { GlobalData.warn(Err, getUnitName()); } + /// @} + + /// \defgroup Methods and data members used for building accelerator tables: + /// + /// @{ + + enum class AccelType : uint8_t { None, Name, Namespace, ObjC, Type }; + /// This structure keeps fields which would be used for creating accelerator /// table. struct AccelInfo { - AccelInfo(StringEntry *Name, const DIE *Die, bool SkipPubSection = false); - AccelInfo(StringEntry *Name, const DIE *Die, uint32_t QualifiedNameHash, - bool ObjCClassIsImplementation); + AccelInfo() { + OnlyAppleSections = false; + ObjcClassImplementation = false; + } /// Name of the entry. - StringEntry *Name = nullptr; - - /// Tag of the DIE this entry describes. - dwarf::Tag Tag = dwarf::DW_TAG_null; + StringEntry *String = nullptr; /// Output offset of the DIE this entry describes. uint64_t OutOffset = 0; @@ -116,22 +131,75 @@ /// Hash of the fully qualified name. uint32_t QualifiedNameHash = 0; + /// Tag of the DIE this entry describes. + dwarf::Tag Tag = dwarf::DW_TAG_null; + /// Emit this entry only in the apple_* sections. - bool SkipPubSection = false; + bool OnlyAppleSections : 1; /// Is this an ObjC class implementation? - bool ObjcClassImplementation = false; + bool ObjcClassImplementation : 1; - /// Cloned Die containing acceleration info. - const DIE *Die = nullptr; + /// Type of this accelerator record. + AccelType Type = AccelType::None; }; - /// \defgroup Methods used for reporting warnings and errors: - /// - /// @{ - void warn(const Twine &Warning) { GlobalData.warn(Warning, getUnitName()); } + void rememberNameForAccelerators(StringEntry *Name, uint64_t OutOffset, + dwarf::Tag Tag, bool OnlyAppleSections) { + AccelInfo Info; + + Info.String = Name; + Info.OutOffset = OutOffset; + Info.Tag = Tag; + Info.OnlyAppleSections = OnlyAppleSections; + Info.Type = AccelType::Name; + + AcceleratorRecords.add(Info); + } + void rememberNamespaceForAccelerators(StringEntry *Name, uint64_t OutOffset, + dwarf::Tag Tag) { + AccelInfo Info; + + Info.String = Name; + Info.OutOffset = OutOffset; + Info.Tag = Tag; + Info.Type = AccelType::Namespace; + + AcceleratorRecords.add(Info); + } + void rememberObjCNameForAccelerators(StringEntry *Name, uint64_t OutOffset, + dwarf::Tag Tag) { + AccelInfo Info; + + Info.String = Name; + Info.OutOffset = OutOffset; + Info.Tag = Tag; + Info.OnlyAppleSections = true; + Info.Type = AccelType::ObjC; + + AcceleratorRecords.add(Info); + } + void rememberTypeForAccelerators(StringEntry *Name, uint64_t OutOffset, + dwarf::Tag Tag, uint32_t QualifiedNameHash, + bool ObjcClassImplementation) { + AccelInfo Info; + + Info.String = Name; + Info.OutOffset = OutOffset; + Info.Tag = Tag; + Info.QualifiedNameHash = QualifiedNameHash; + Info.ObjcClassImplementation = ObjcClassImplementation; + Info.Type = AccelType::Type; + + AcceleratorRecords.add(Info); + } + + /// Emit .debug_pubnames and .debug_pubtypes for \p Unit. + void emitPubAccelerators(); + + /// Accelerator tables data. + ArrayList AcceleratorRecords; - void error(const Twine &Err) { GlobalData.warn(Err, getUnitName()); } /// @} protected: @@ -139,6 +207,12 @@ void emitDwarfAbbrevEntry(const DIEAbbrev &Abbrev, SectionDescriptor &AbbrevSection); + /// Emit single pubnames/pubtypes accelerator entry. + std::optional + emitPubAcceleratorEntry(SectionDescriptor &OutSection, + DwarfUnit::AccelInfo &Info, + std::optional LengthOffset); + /// Linking global data. LinkingGlobalData &GlobalData; diff --git a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp --- a/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp +++ b/llvm/lib/DWARFLinkerParallel/DWARFLinkerUnit.cpp @@ -126,5 +126,85 @@ return DebugLineEmitter.emit(OutLineTable); } +/// Emit the pubnames or pubtypes section contribution for \p +/// Unit into \p Sec. The data is provided in \p Info. +std::optional +DwarfUnit::emitPubAcceleratorEntry(SectionDescriptor &OutSection, + DwarfUnit::AccelInfo &Info, + std::optional LengthOffset) { + if (!LengthOffset) { + // Emit the header. + OutSection.emitIntVal(0xBADDEF, + getFormParams().getDwarfOffsetByteSize()); // Length + LengthOffset = OutSection.OS.tell(); + + OutSection.emitIntVal(dwarf::DW_PUBNAMES_VERSION, 2); // Version + + OutSection.notePatch( + DebugOffsetPatch{OutSection.OS.tell(), + &getSectionDescriptor(DebugSectionKind::DebugInfo)}); + OutSection.emitOffset(0xBADDEF); // Unit offset + + OutSection.emitIntVal(getUnitSize(), 4); // Size + } + OutSection.emitOffset(Info.OutOffset); + + // Emit the string itself. + OutSection.emitInplaceString(Info.String->first()); + + return LengthOffset; +} + +/// Emit .debug_pubnames and .debug_pubtypes for \p Unit. +void DwarfUnit::emitPubAccelerators() { + if (AcceleratorRecords.empty()) + return; + + std::optional NamesLengthOffset; + std::optional TypesLengthOffset; + AcceleratorRecords.forEach([&](DwarfUnit::AccelInfo &Info) { + if (Info.OnlyAppleSections) + return; + + switch (Info.Type) { + case DwarfUnit::AccelType::Name: { + NamesLengthOffset = emitPubAcceleratorEntry( + getSectionDescriptor(DebugSectionKind::DebugPubNames), Info, + NamesLengthOffset); + } break; + case DwarfUnit::AccelType::Type: { + TypesLengthOffset = emitPubAcceleratorEntry( + getSectionDescriptor(DebugSectionKind::DebugPubTypes), Info, + TypesLengthOffset); + } break; + default: { + // Nothing to do. + } break; + } + }); + + if (NamesLengthOffset) { + SectionDescriptor &OutSection = + getSectionDescriptor(DebugSectionKind::DebugPubNames); + OutSection.emitIntVal(0, 4); // End marker. + + OutSection.apply(*NamesLengthOffset - + OutSection.getFormParams().getDwarfOffsetByteSize(), + dwarf::DW_FORM_sec_offset, + OutSection.OS.tell() - *NamesLengthOffset); + } + + if (TypesLengthOffset) { + SectionDescriptor &OutSection = + getSectionDescriptor(DebugSectionKind::DebugPubTypes); + OutSection.emitIntVal(0, 4); // End marker. + + OutSection.apply(*TypesLengthOffset - + OutSection.getFormParams().getDwarfOffsetByteSize(), + dwarf::DW_FORM_sec_offset, + OutSection.OS.tell() - *TypesLengthOffset); + } +} + } // end of namespace dwarflinker_parallel } // end of namespace llvm diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.h b/llvm/lib/DWARFLinkerParallel/OutputSections.h --- a/llvm/lib/DWARFLinkerParallel/OutputSections.h +++ b/llvm/lib/DWARFLinkerParallel/OutputSections.h @@ -44,6 +44,8 @@ DebugMacinfo, DebugMacro, DebugAddr, + DebugPubNames, + DebugPubTypes, NumberOfEnumEntries // must be last }; constexpr static size_t SectionKindsNum = @@ -143,7 +145,7 @@ /// Section patches. #define ADD_PATCHES_LIST(T) \ - T ¬ePatch(const T &Patch) { return List##T.noteItem(Patch); } \ + T ¬ePatch(const T &Patch) { return List##T.add(Patch); } \ ArrayList List##T; ADD_PATCHES_LIST(DebugStrPatch) @@ -202,7 +204,7 @@ /// Emit specified inplace string value into the current section contents. void emitInplaceString(StringRef String) { - OS << String; + OS << GlobalData->translateString(String); emitIntVal(0, 1); } diff --git a/llvm/lib/DWARFLinkerParallel/OutputSections.cpp b/llvm/lib/DWARFLinkerParallel/OutputSections.cpp --- a/llvm/lib/DWARFLinkerParallel/OutputSections.cpp +++ b/llvm/lib/DWARFLinkerParallel/OutputSections.cpp @@ -17,7 +17,7 @@ "debug_info", "debug_line", "debug_frame", "debug_ranges", "debug_rnglists", "debug_loc", "debug_loclists", "debug_aranges", "debug_abbrev", "debug_macinfo", "debug_macro", "debug_addr", -}; + "debug_pubnames", "debug_pubtypes"}; const StringLiteral &getSectionName(DebugSectionKind SectionKind) { return SectionNames[static_cast(SectionKind)]; @@ -50,6 +50,10 @@ DebugSectionKind::DebugMacro) .Case(getSectionName(DebugSectionKind::DebugAddr), DebugSectionKind::DebugAddr) + .Case(getSectionName(DebugSectionKind::DebugPubNames), + DebugSectionKind::DebugPubNames) + .Case(getSectionName(DebugSectionKind::DebugPubTypes), + DebugSectionKind::DebugPubTypes) .Default(std::nullopt); return std::nullopt; @@ -155,7 +159,7 @@ switch (StringForm) { case dwarf::DW_FORM_string: { - emitInplaceString(GlobalData->translateString(StringVal)); + emitInplaceString(StringVal); } break; case dwarf::DW_FORM_strp: { notePatch(DebugStrPatch{ diff --git a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-dwarf4-combination-macho.test b/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-dwarf4-combination-macho.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-dwarf4-combination-macho.test +++ /dev/null @@ -1,156 +0,0 @@ -; This test checks to ensure that if a DWARF v5 and DWARF v4 object file is used to -; generate a dsym, dsymutil correctly outputs the debug information, by keeping -; the DWARF v5 and DWARF v4 debug info distinct, and that all the section headers -; have the correct format. - -; 1.o was produced with the source file: - -; a.cpp -; __attribute__((section("1,__text_foo"))) void foo() {} -; -; int foo2(int a) { -; return a+5; -; } -; int main () { -; return 1; -; } - -; clang -g -c -O1 a.cpp -Xclang -gdwarf-5 -o 1.o - -; 2.o was produced with the following source file: - -; b.cpp -; __attribute__((section("1,__text_foo2"))) void foo2() {} -; -; int bar(int x) { -; int y = x + 2; -; return y; -; } - -; clang -g -c -O1 b.cpp -gdwarf-4 -o 2.o - - -RUN: rm -rf %t.dir && mkdir -p %t.dir -RUN: dsymutil --linker llvm -y %p/../dummy-debug-map-amr64.map \ -RUN: -oso-prepend-path=%p/../../Inputs/DWARF5-DWARF4-combination \ -RUN: -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM -RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM \ -RUN: -a --verbose | FileCheck %s - - -CHECK:.debug_abbrev contents: -CHECK-NEXT: Abbrev table for offset: 0x00000000 - -CHECK: .debug_info contents: -CHECK: 0x00000000: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGELIST_OFFSET:[0-9a-f]+]] -CHECK-NEXT: [0x[[RANGELIST_OFFSET_START:[0-9a-f]+]], 0x[[RANGELIST_OFFSET_END:[0-9a-f]+]])) -CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -CHECK: 0x00000037: DW_TAG_subprogram [2] * (0x0000000c) -CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x0000004d: DW_TAG_formal_parameter [3] (0x00000037) -CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOCLIST_OFFSET:[0-9a-f]+]]: -CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START:]], 0x[[#%.16x,LOCLIST_PAIR_END:]]): [[LOCLIST_EXPR:.*]] -CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START2:]], 0x[[#%.16x,LOCLIST_PAIR_END2:]]): [[LOCLIST_EXPR2:.*]]) - -CHECK: 0x00000065: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0058, addr_size = 0x08 -CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,RANGE_LOWPC:]]) -CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 -CHECK-NEXT: [0x[[#%.16x,RANGE_START:]], 0x[[#%.16x,RANGE_END:]])) -CHECK: 0x00000097: DW_TAG_subprogram {{.*}} * (0x00000070) -CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOC_LOWPC:]]) -CHECK: 0x000000b4: DW_TAG_formal_parameter [3] (0x00000097) -CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]: -CHECK-NEXT: [0x[[#%.16x,LOC_PAIR_START:]], 0x[[#%.16x,LOC_PAIR_END:]]): [[LOC_EXPR:.*]] -CHECK-NEXT: [0x[[#%.16x,LOC_PAIR_START2:]], 0x[[#%.16x,LOC_PAIR_END2:]]): [[LOC_EXPR2:.*]]) - -CHECK: .debug_loc contents: -CHECK-NEXT: 0x[[LOC_OFFSET]]: -CHECK-NEXT: (0x[[#sub(LOC_PAIR_START,LOC_LOWPC)]], 0x[[#sub(LOC_PAIR_END,LOC_LOWPC)]]): [[LOC_EXPR:.*]] -CHECK-NEXT: (0x[[#sub(LOC_PAIR_START2,LOC_LOWPC)]], 0x[[#sub(LOC_PAIR_END2,LOC_LOWPC)]]): [[LOC_EXPR2:.*]] - -CHECK: .debug_loclists contents: -CHECK-NEXT: 0x00000000: locations list header: length = 0x00000018, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 -CHECK-NEXT: 0x[[LOCLIST_OFFSET]]: -CHECK-NEXT: DW_LLE_base_addressx (0x0000000000000000) -CHECK-NEXT: DW_LLE_offset_pair (0x[[#sub(LOCLIST_PAIR_START,LOCLIST_LOWPC)]], 0x[[#sub(LOCLIST_PAIR_END,LOCLIST_LOWPC)]]) -CHECK-NEXT: DW_LLE_offset_pair (0x[[#sub(LOCLIST_PAIR_START2,LOCLIST_LOWPC)]], 0x[[#sub(LOCLIST_PAIR_END2,LOCLIST_LOWPC)]]) -CHECK-NEXT: DW_LLE_end_of_list () - -CHECK: .debug_line contents: -CHECK-NEXT: debug_line[0x00000000] -CHECK-NEXT: Line table prologue: -CHECK-NEXT: total_length: 0x00000048 -CHECK-NEXT: format: DWARF32 -CHECK-NEXT: version: 5 -CHECK-NEXT: address_size: 8 -CHECK-NEXT: seg_select_size: 0 -CHECK-NEXT: prologue_length: 0x00000025 -CHECK-NEXT: min_inst_length: 1 -CHECK-NEXT: max_ops_per_inst: 1 -CHECK-NEXT: default_is_stmt: 1 -CHECK-NEXT: line_base: -5 -CHECK-NEXT: line_range: 14 -CHECK-NEXT: opcode_base: 13 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1 -CHECK-NEXT: include_directories[ 0] = .debug_line_str[0x00000000] = "/Users/shubham/Development/test109275485" -CHECK-NEXT: file_names[ 0]: -CHECK-NEXT: name: .debug_line_str[0x00000029] = "a.cpp" -CHECK-NEXT: dir_index: 0 - -CHECK: debug_line[0x0000004c] -CHECK-NEXT: Line table prologue: -CHECK-NEXT: total_length: 0x0000003b -CHECK-NEXT: format: DWARF32 -CHECK-NEXT: version: 4 -CHECK-NEXT: prologue_length: 0x0000001d -CHECK-NEXT: min_inst_length: 1 -CHECK-NEXT: max_ops_per_inst: 1 -CHECK-NEXT: default_is_stmt: 1 -CHECK-NEXT: line_base: -5 -CHECK-NEXT: line_range: 14 -CHECK-NEXT: opcode_base: 13 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1 -CHECK-NEXT: file_names[ 1]: -CHECK-NEXT: name: "b.cpp" -CHECK-NEXT: dir_index: 0 -CHECK-NEXT: mod_time: 0x00000000 -CHECK-NEXT: length: 0x00000000 - -CHECK: .debug_str contents: - -CHECK: .debug_line_str contents: -CHECK-NEXT: 0x00000000: "/Users/shubham/Development/test109275485" -CHECK-NEXT: 0x00000029: "a.cpp" - -CHECK: .debug_ranges contents: -CHECK-NEXT: 00000000 [[#sub(RANGE_START,RANGE_LOWPC)]] [[#sub(RANGE_END,RANGE_LOWPC)]] - -CHECK: .debug_rnglists contents: -CHECK-NEXT: 0x00000000: range list header: length = 0x0000000e, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 -CHECK-NEXT: ranges: -CHECK-NEXT: [[RANGELIST_OFFSET]]: [DW_RLE_base_addressx]: 0x0000000000000000 -CHECK-NEXT: 0x0000000e: [DW_RLE_offset_pair ]: {{.*}}[0x[[RANGELIST_OFFSET_START]], 0x[[RANGELIST_OFFSET_END]]) -CHECK-NEXT: 0x00000011: [DW_RLE_end_of_list ] diff --git a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-macho.test b/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-macho.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/dwarf5-macho.test +++ /dev/null @@ -1,92 +0,0 @@ -; This test checks to that DWARF v5 debug info can be correctly linked -; into a dSYM bundle by dsymutil, with the correct section names and DWARF v5 -; headers for the different sections. - -; 1.o was produced with the source file: - -; a.cpp -; __attribute__((section("1,__text_foo"))) void foo() {} -; -; int foo2(int a) { -; return a+5; -; } -; int main () { -; return 1; -; } - -; clang -g -c -O1 a.cpp -Xclang -gdwarf-5 -o 1.o - - -RUN: rm -rf %t.dir && mkdir -p %t.dir -RUN: dsymutil --linker llvm -y %p/../dummy-debug-map-amr64.map \ -RUN: -oso-prepend-path=%p/../../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM -RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s - -CHECK:.debug_abbrev contents: -CHECK-NEXT: Abbrev table for offset: 0x00000000 - -CHECK: .debug_info contents: -CHECK-NEXT: Compile Unit: length = 0x00000061, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 -CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x[[RANGELIST_OFFSET:[0-9a-f]+]] -CHECK-NEXT: [0x[[RANGELIST_OFFSET_START:[0-9a-f]+]], 0x[[RANGELIST_OFFSET_END:[0-9a-f]+]])) -CHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008) -CHECK: 0x00000037: DW_TAG_subprogram [2] * (0x0000000c) -CHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000000) address = 0x[[#%.16x,LOCLIST_LOWPC:]]) -CHECK: 0x0000004d: DW_TAG_formal_parameter [3] (0x00000037) -CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]: -CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START:]], 0x[[#%.16x,LOCLIST_PAIR_END:]]): [[LOCLIST_EXPR:.*]] -CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START2:]], 0x[[#%.16x,LOCLIST_PAIR_END2:]]): [[LOCLIST_EXPR2:.*]]) - -CHECK: .debug_loclists contents: -CHECK-NEXT: 0x00000000: locations list header: length = 0x00000018, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 -CHECK-NEXT: 0x[[LOC_OFFSET]]: -CHECK-NEXT: DW_LLE_base_addressx (0x0000000000000000) -CHECK-NEXT: DW_LLE_offset_pair (0x[[#sub(LOCLIST_PAIR_START,LOCLIST_LOWPC)]], 0x[[#sub(LOCLIST_PAIR_END,LOCLIST_LOWPC)]]) -CHECK-NEXT: DW_LLE_offset_pair (0x[[#sub(LOCLIST_PAIR_START2,LOCLIST_LOWPC)]], 0x[[#sub(LOCLIST_PAIR_END2,LOCLIST_LOWPC)]]) -CHECK-NEXT: DW_LLE_end_of_list () - -CHECK: .debug_line contents: -CHECK-NEXT: debug_line[0x00000000] -CHECK-NEXT: Line table prologue: -CHECK-NEXT: total_length: 0x00000048 -CHECK-NEXT: format: DWARF32 -CHECK-NEXT: version: 5 -CHECK-NEXT: address_size: 8 -CHECK-NEXT: seg_select_size: 0 -CHECK-NEXT: prologue_length: 0x00000025 -CHECK-NEXT: min_inst_length: 1 -CHECK-NEXT: max_ops_per_inst: 1 -CHECK-NEXT: default_is_stmt: 1 -CHECK-NEXT: line_base: -5 -CHECK-NEXT: line_range: 14 -CHECK-NEXT: opcode_base: 13 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_copy] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_advance_line] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_file] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_column] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_negate_stmt] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_basic_block] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_const_add_pc] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_prologue_end] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0 -CHECK-NEXT: standard_opcode_lengths[DW_LNS_set_isa] = 1 -CHECK-NEXT: include_directories[ 0] = .debug_line_str[0x00000000] = "/Users/shubham/Development/test109275485" -CHECK-NEXT: file_names[ 0]: -CHECK-NEXT: name: .debug_line_str[0x00000029] = "a.cpp" -CHECK-NEXT: dir_index: 0 - - -CHECK: .debug_str contents: - -CHECK: .debug_line_str contents: -CHECK-NEXT: 0x00000000: "/Users/shubham/Development/test109275485" -CHECK-NEXT: 0x00000029: "a.cpp" - -CHECK: .debug_rnglists contents: -CHECK-NEXT: 0x00000000: range list header: length = 0x0000000e, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000 -CHECK-NEXT: ranges: -CHECK-NEXT: [[RANGELIST_OFFSET]]: [DW_RLE_base_addressx]: 0x0000000000000000 -CHECK-NEXT: 0x0000000e: [DW_RLE_offset_pair ]: {{.*}}[0x[[RANGELIST_OFFSET_START]], 0x[[RANGELIST_OFFSET_END]]) -CHECK-NEXT: 0x00000011: [DW_RLE_end_of_list ] diff --git a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/fat-dylib-update.test b/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/fat-dylib-update.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/fat-dylib-update.test +++ /dev/null @@ -1,110 +0,0 @@ -# REQUIRES: object-emission,system-darwin -# RUN: dsymutil --linker llvm -oso-prepend-path %p/../.. %p/../../Inputs/fat-test.arm.dylib -o %t.dSYM -# RUN: llvm-dwarfdump -a -v %t.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -# RUN: dsymutil --linker llvm -u %t.dSYM -# RUN: llvm-dwarfdump -a -v %t.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s -# RUN: dsymutil --linker llvm -u %t.dSYM -o %t1.dSYM -# RUN: llvm-dwarfdump -a -v %t1.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s - -CHECK: /Contents/Resources/DWARF/fat-test.arm.dylib(armv7): file format Mach-O arm - -CHECK: .debug_info contents: -CHECK: Compile Unit: length = 0x00000034, format = DWARF32, version = 0x0002, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000038) -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000001] = "clang version 3.8.0 (trunk 243776)") -CHECK: DW_AT_language [DW_FORM_data2] (DW_LANG_C99) -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000024] = "fat-test.c") -CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000002f] = "/Inputs") -CHECK: DW_TAG_variable [2] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = "armv7_var") -CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0030 => {0x00000030} -CHECK: DW_AT_external [DW_FORM_flag] (0x01) -CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs/fat-test.c") -CHECK: DW_AT_decl_line [DW_FORM_data1] (23) -CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x1000) -CHECK: DW_TAG_base_type [3] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000041] = "int") -CHECK: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) -CHECK: DW_AT_byte_size [DW_FORM_data1] (0x04) -CHECK: NULL - - -CHECK: .debug_line contents: -CHECK: Line table prologue: -CHECK: total_length: 0x0000002a -CHECK: version: 2 -CHECK: prologue_length: 0x00000021 -CHECK: min_inst_length: 1 -CHECK: default_is_stmt: 1 -CHECK: line_base: -5 -CHECK: line_range: 14 -CHECK: opcode_base: 13 - -CHECK: /Contents/Resources/DWARF/fat-test.arm.dylib(armv7s): file format Mach-O arm - -CHECK: .debug_info contents: -CHECK: Compile Unit: length = 0x00000034, format = DWARF32, version = 0x0002, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000038) -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000001] = "clang version 3.8.0 (trunk 243776)") -CHECK: DW_AT_language [DW_FORM_data2] (DW_LANG_C99) -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000024] = "fat-test.c") -CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000002f] = "/Inputs") -CHECK: DW_TAG_variable [2] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = "armv7s_var") -CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0030 => {0x00000030} -CHECK: DW_AT_external [DW_FORM_flag] (0x01) -CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs/fat-test.c") -CHECK: DW_AT_decl_line [DW_FORM_data1] (21) -CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x1000) -CHECK: DW_TAG_base_type [3] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000042] = "int") -CHECK: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) -CHECK: DW_AT_byte_size [DW_FORM_data1] (0x04) -CHECK: NULL - -CHECK: .debug_line contents: -CHECK: Line table prologue: -CHECK: total_length: 0x0000002a -CHECK: version: 2 -CHECK: prologue_length: 0x00000021 -CHECK: min_inst_length: 1 -CHECK: default_is_stmt: 1 -CHECK: line_base: -5 -CHECK: line_range: 14 -CHECK: opcode_base: 13 - -CHECK: /Contents/Resources/DWARF/fat-test.arm.dylib(arm64): file format Mach-O arm64 - -CHECK: .debug_info contents: -CHECK: Compile Unit: length = 0x00000038, format = DWARF32, version = 0x0002, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x0000003c) -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000001] = "clang version 3.8.0 (trunk 243776)") -CHECK: DW_AT_language [DW_FORM_data2] (DW_LANG_C99) -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000024] = "fat-test.c") -CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x00000000) -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x0000002f] = "/Inputs") -CHECK: DW_TAG_variable [2] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000037] = "arm64_var") -CHECK: DW_AT_type [DW_FORM_ref4] (cu + 0x0034 => {0x00000034} -CHECK: DW_AT_external [DW_FORM_flag] (0x01) -CHECK: DW_AT_decl_file [DW_FORM_data1] ("/Inputs/fat-test.c") -CHECK: DW_AT_decl_line [DW_FORM_data1] (25) -CHECK: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x4000) -CHECK: DW_TAG_base_type [3] -CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000041] = "int") -CHECK: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) -CHECK: DW_AT_byte_size [DW_FORM_data1] (0x04) -CHECK: NULL - -CHECK: .debug_line contents: -CHECK: Line table prologue: -CHECK: total_length: 0x0000002a -CHECK: version: 2 -CHECK: prologue_length: 0x00000021 -CHECK: min_inst_length: 1 -CHECK: default_is_stmt: 1 -CHECK: line_base: -5 -CHECK: line_range: 14 -CHECK: opcode_base: 13 diff --git a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/obfuscated.test b/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/obfuscated.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/ARM/DWARFLinkerParallel/obfuscated.test +++ /dev/null @@ -1,119 +0,0 @@ -REQUIRES: system-darwin - -RUN: dsymutil --linker llvm --symbol-map %p/../../Inputs/obfuscated.map %p/../../Inputs/obfuscated.arm64 -f -o - \ -RUN: | llvm-dwarfdump -v - \ -RUN: | FileCheck %s - -RUN: dsymutil --linker llvm --symbol-map %p/../../Inputs/obfuscated.map %p/../../Inputs/obfuscated.arm64 -f -o - \ -RUN: | llvm-dwarfdump -v - \ -RUN: | FileCheck --check-prefix=NOHIDDEN %s - -RUN: dsymutil --linker llvm --symbol-map %p/../../Inputs/obfuscated.2.map %p/../../Inputs/obfuscated.2.arm64 -f -o - \ -RUN: | llvm-dwarfdump -v - \ -RUN: | FileCheck --check-prefix=NOHIDDEN %s - -// Run with plist and make sure dsymutil finds it. -RUN: mkdir -p %t.dSYM/Contents/Resources/DWARF/ -RUN: mkdir -p %t.mapdir -RUN: cp %p/../../Inputs/obfuscated.arm64 %t.dSYM/Contents/Resources/DWARF/ -RUN: cp %p/../../Inputs/E828A486-8433-3A5E-B6DB-A6294D28133D.plist %t.dSYM/Contents/Resources/ -RUN: cp %p/../../Inputs/obfuscated.map %t.mapdir/506AA50A-6B26-3B37-86D2-DC6EBD57B720.bcsymbolmap -RUN: dsymutil --linker llvm --symbol-map %t.mapdir %t.dSYM 2>&1 | FileCheck --check-prefix=OBFUSCATING %s - -// Run without plist and make sure dsymutil doesn't crash. -RUN: rm %t.dSYM/Contents/Resources/E828A486-8433-3A5E-B6DB-A6294D28133D.plist -RUN: dsymutil --linker llvm --symbol-map %t.mapdir %t.dSYM 2>&1 | FileCheck --check-prefix=NOTOBFUSCATING %s - -OBFUSCATING-NOT: not unobfuscating - -NOTOBFUSCATING: not unobfuscating - -NOHIDDEN-NOT: __hidden# - -CHECK: .debug_info contents: - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "main.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "main") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "one.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "one") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "two.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "two") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "three.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "three") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "four.c") -CHECK: DW_AT_stmt_list [DW_FORM_data4] (0x0000011e) -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "four") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "five.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "five") - -CHECK: DW_TAG_compile_unit [1] * -CHECK: DW_AT_producer [DW_FORM_strp] ( {{.*}} "Apple LLVM version 7.0.0 (clang-700.2.38.2)") -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "six.c") -CHECK: DW_AT_comp_dir [DW_FORM_strp] ( {{.*}} "/Users/steven/dev/alpena/tests/src") -CHECK: DW_TAG_subprogram [2] -CHECK: DW_AT_name [DW_FORM_strp] ( {{.*}} "six") - -CHECK: .debug_line contents: -CHECK: file_names[ 1]: -CHECK: name: "main.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "one.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "two.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "three.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "four.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "five.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 -CHECK: file_names[ 1]: -CHECK: name: "six.c" -CHECK: dir_index: 0 -CHECK: mod_time: 0x00000000 -CHECK: length: 0x00000000 diff --git a/llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test b/llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test --- a/llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test +++ b/llvm/test/tools/dsymutil/ARM/accel-imported-declarations.test @@ -4,6 +4,15 @@ RUN: llvm-dwarfdump -v %t.dwarf.dSYM | FileCheck %s -check-prefixes=DWARF,COMMON RUN: llvm-dwarfdump -v %t.apple.dSYM | FileCheck %s -check-prefixes=APPLE,COMMON +## Repeat testing steps for --linker llvm +RUN: dsymutil --linker llvm -accelerator=Dwarf -oso-prepend-path=%p/../Inputs \ +RUN: %p/../Inputs/accel-imported-declaration.macho-arm64 -o %t.dwarf.dSYM +RUN: dsymutil --linker llvm -accelerator=Apple -oso-prepend-path=%p/../Inputs \ +RUN: %p/../Inputs/accel-imported-declaration.macho-arm64 -o %t.apple.dSYM + +RUN: llvm-dwarfdump -v %t.dwarf.dSYM | FileCheck %s -check-prefixes=DWARF,COMMON +RUN: llvm-dwarfdump -v %t.apple.dSYM | FileCheck %s -check-prefixes=APPLE,COMMON + COMMON: .debug_info contents COMMON: {{.*}}DW_TAG_namespace COMMON: DW_AT_name{{.*}}"A" diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test b/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test --- a/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test +++ b/llvm/test/tools/dsymutil/ARM/dwarf5-dwarf4-combination-macho.test @@ -34,6 +34,11 @@ RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM -a --verbose | FileCheck %s +RUN: dsymutil --linker llvm -y %p/dummy-debug-map-amr64.map \ +RUN: -oso-prepend-path=%p/../Inputs/DWARF5-DWARF4-combination \ +RUN: -o %t.dir/dwarf5-dwarf4-combination-macho.dSYM +RUN: llvm-dwarfdump %t.dir/dwarf5-dwarf4-combination-macho.dSYM -a --verbose \ +RUN: | FileCheck %s CHECK:.debug_abbrev contents: CHECK-NEXT: Abbrev table for offset: 0x00000000 @@ -50,11 +55,11 @@ CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START:]], 0x[[#%.16x,LOCLIST_PAIR_END:]]): [[LOCLIST_EXPR:.*]] CHECK-NEXT: [0x[[#%.16x,LOCLIST_PAIR_START2:]], 0x[[#%.16x,LOCLIST_PAIR_END2:]]): [[LOCLIST_EXPR2:.*]]) -CHECK: 0x00000065: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 +CHECK: 0x00000065: Compile Unit: length = 0x00000072, format = DWARF32, version = 0x0004, abbr_offset = 0x00{{00|58}}, addr_size = 0x08 CHECK: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,RANGE_LOWPC:]]) CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000 CHECK-NEXT: [0x[[#%.16x,RANGE_START:]], 0x[[#%.16x,RANGE_END:]])) -CHECK: 0x00000097: DW_TAG_subprogram [6] * (0x00000070) +CHECK: 0x00000097: DW_TAG_subprogram {{.*}} * (0x00000070) CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x[[#%.16x,LOC_LOWPC:]]) CHECK: 0x000000b4: DW_TAG_formal_parameter [3] (0x00000097) CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x[[LOC_OFFSET:[0-9a-f]+]]: diff --git a/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test b/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test --- a/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test +++ b/llvm/test/tools/dsymutil/ARM/dwarf5-macho.test @@ -21,6 +21,10 @@ RUN: dsymutil -y %p/dummy-debug-map-amr64.map -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s +RUN: dsymutil --linker llvm -y %p/dummy-debug-map-amr64.map \ +RUN: -oso-prepend-path=%p/../Inputs/DWARF5 -o %t.dir/dwarf5-macho.dSYM +RUN: llvm-dwarfdump %t.dir/dwarf5-macho.dSYM -a --verbose | FileCheck %s + CHECK:.debug_abbrev contents: CHECK-NEXT: Abbrev table for offset: 0x00000000 diff --git a/llvm/test/tools/dsymutil/ARM/fat-dylib-update.test b/llvm/test/tools/dsymutil/ARM/fat-dylib-update.test --- a/llvm/test/tools/dsymutil/ARM/fat-dylib-update.test +++ b/llvm/test/tools/dsymutil/ARM/fat-dylib-update.test @@ -6,6 +6,14 @@ # RUN: dsymutil -u %t.dSYM -o %t1.dSYM # RUN: llvm-dwarfdump -a -v %t1.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s +# RUN: dsymutil --linker llvm -oso-prepend-path %p/.. \ +# RUN: %p/../Inputs/fat-test.arm.dylib -o %t.dSYM +# RUN: llvm-dwarfdump -a -v %t.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s +# RUN: dsymutil --linker llvm -u %t.dSYM +# RUN: llvm-dwarfdump -a -v %t.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s +# RUN: dsymutil --linker llvm -u %t.dSYM -o %t1.dSYM +# RUN: llvm-dwarfdump -a -v %t1.dSYM/Contents/Resources/DWARF/fat-test.arm.dylib | FileCheck %s + CHECK: /Contents/Resources/DWARF/fat-test.arm.dylib(armv7): file format Mach-O arm CHECK: .debug_info contents: diff --git a/llvm/test/tools/dsymutil/ARM/obfuscated.test b/llvm/test/tools/dsymutil/ARM/obfuscated.test --- a/llvm/test/tools/dsymutil/ARM/obfuscated.test +++ b/llvm/test/tools/dsymutil/ARM/obfuscated.test @@ -28,6 +28,42 @@ RUN: rm %t.dSYM/Contents/Resources/E828A486-8433-3A5E-B6DB-A6294D28133D.plist RUN: dsymutil --symbol-map %t.mapdir %t.dSYM 2>&1 | FileCheck --check-prefix=NOTOBFUSCATING %s +## Do the same for --linker llvm +RUN: dsymutil --linker llvm --symbol-map %p/../Inputs/obfuscated.map \ +RUN: %p/../Inputs/obfuscated.arm64 -f -o - \ +RUN: | llvm-dwarfdump -v - \ +RUN: | FileCheck %s + +RUN: dsymutil --linker llvm --accelerator=Pub --symbol-map \ +RUN: %p/../Inputs/obfuscated.map %p/../Inputs/obfuscated.arm64 -f -o - \ +RUN: | llvm-dwarfdump -v - \ +RUN: | FileCheck --check-prefix=PUB %s + +RUN: dsymutil --linker llvm --symbol-map %p/../Inputs/obfuscated.map \ +RUN: %p/../Inputs/obfuscated.arm64 -f -o - \ +RUN: | llvm-dwarfdump -v - \ +RUN: | FileCheck --check-prefix=NOHIDDEN %s + +RUN: dsymutil --linker llvm --symbol-map %p/../Inputs/obfuscated.2.map \ +RUN: %p/../Inputs/obfuscated.2.arm64 -f -o - \ +RUN: | llvm-dwarfdump -v - \ +RUN: | FileCheck --check-prefix=NOHIDDEN %s + +// Run with plist and make sure dsymutil finds it. +RUN: mkdir -p %t.dSYM/Contents/Resources/DWARF/ +RUN: mkdir -p %t.mapdir +RUN: cp %p/../Inputs/obfuscated.arm64 %t.dSYM/Contents/Resources/DWARF/ +RUN: cp %p/../Inputs/E828A486-8433-3A5E-B6DB-A6294D28133D.plist %t.dSYM/Contents/Resources/ +RUN: cp %p/../Inputs/obfuscated.map %t.mapdir/506AA50A-6B26-3B37-86D2-DC6EBD57B720.bcsymbolmap +RUN: dsymutil --linker llvm --symbol-map %t.mapdir %t.dSYM 2>&1 \ +RUN: | FileCheck --check-prefix=OBFUSCATING %s + +// Run without plist and make sure dsymutil doesn't crash. +RUN: rm %t.dSYM/Contents/Resources/E828A486-8433-3A5E-B6DB-A6294D28133D.plist +RUN: dsymutil --linker llvm --symbol-map %t.mapdir %t.dSYM 2>&1 \ +RUN: | FileCheck --check-prefix=NOTOBFUSCATING %s + + OBFUSCATING-NOT: not unobfuscating NOTOBFUSCATING: not unobfuscating diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-bundle.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-bundle.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-bundle.test +++ /dev/null @@ -1,41 +0,0 @@ -RUN: rm -rf %t -RUN: mkdir -p %t/dsymdest -RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t/basic.macho.x86_64 - -RUN: dsymutil --linker llvm -accelerator=Pub -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 - -Check that the object file in the bundle exists and is sane: -RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test - -Check that we don't create an empty Remarks directory if there are no remarks. -RUN: not ls %t/basic.macho.x86_64.dSYM/Contents/Resources/Remarks - -Check that llvm-dwarfdump -a recognizes the bundle as a dSYM: -RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM | FileCheck %S/basic-linking-x86.test - -RUN: FileCheck %s --input-file %t/basic.macho.x86_64.dSYM/Contents/Info.plist - -RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 -o %t/dsymdest/basic.macho.x86_64.dSYM -RUN: llvm-dwarfdump -a %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test -RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist - -CHECK: -CHECK-NEXT: -CHECK-NEXT: -CHECK-NEXT: -CHECK-NEXT: CFBundleDevelopmentRegion -CHECK-NEXT: English -CHECK-NEXT: CFBundleIdentifier -CHECK-NEXT: com.apple.xcode.dsym.basic.macho.x86_64 -CHECK-NEXT: CFBundleInfoDictionaryVersion -CHECK-NEXT: 6.0 -CHECK-NEXT: CFBundlePackageType -CHECK-NEXT: dSYM -CHECK-NEXT: CFBundleSignature -CHECK-NEXT: ???? -CHECK-NEXT: CFBundleShortVersionString -CHECK-NEXT: 1.0 -CHECK-NEXT: CFBundleVersion -CHECK-NEXT: 1 -CHECK-NEXT: -CHECK-NEXT: diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-x86.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-x86.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-linking-x86.test +++ /dev/null @@ -1,190 +0,0 @@ -RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t1 -RUN: dsymutil --linker llvm -accelerator=Pub -f -oso-prepend-path=%p/../.. %t1 -RUN: llvm-dwarfdump -a %t1.dwarf | FileCheck %s -RUN: dsymutil --linker llvm -accelerator=Pub -f -o %t2 -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64 -RUN: llvm-dwarfdump -a %t2 | FileCheck %s -RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC -RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE -RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/../.. %p/../../Inputs/basic.macho.x86_64 | dsymutil -accelerator=Pub -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC -RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/../.. %p/../../Inputs/basic-archive.macho.x86_64 | dsymutil -accelerator=Pub -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE - -CHECK: file format Mach-O 64-bit x86-64 - -CHECK: debug_info contents - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_language (DW_LANG_C99) -CHECK: DW_AT_name ("basic1.c") -CHECK: DW_AT_stmt_list (0x00000000) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000ea0) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("main") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_decl_line (23) -CHECK: DW_AT_prototyped (0x01) -CHECK: DW_AT_type (0x00000063 -CHECK: DW_AT_external (0x01) -CHECK: DW_AT_accessibility (DW_ACCESS_public) -CHECK: DW_AT_low_pc (0x0000000100000ea0) -CHECK: DW_AT_high_pc (0x0000000100000ec4) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("argc") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_decl_line (23) -CHECK: DW_AT_type (0x00000063 -CHECK: DW_AT_location (DW_OP_fbreg -8) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("argv") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_decl_line (23) -CHECK: DW_AT_type (0x0000006a -CHECK: DW_AT_location (DW_OP_fbreg -16) -CHECK: NULL -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("int") -CHECK: DW_AT_encoding (DW_ATE_signed) -CHECK: DW_AT_byte_size (0x04) -CHECK: DW_TAG_pointer_type -CHECK: DW_AT_type (0x0000006f -CHECK: DW_TAG_pointer_type -CHECK: DW_AT_type (0x00000074 -CHECK: DW_TAG_const_type -CHECK: DW_AT_type (0x00000079 -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("char") -CHECK: DW_AT_encoding (DW_ATE_signed_char) -CHECK: DW_AT_byte_size (0x01) -CHECK: NULL - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_name ("basic2.c") -CHECK: DW_AT_stmt_list (0x0000003f) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000ed0) -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("int") -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("private_int") -CHECK: DW_AT_type (0x000000a7 -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -BASIC: DW_AT_location (DW_OP_addr 0x100001008) -ARCHIVE: DW_AT_location (DW_OP_addr 0x100001004) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("baz") -CHECK: DW_AT_type (0x000000a7 -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location (DW_OP_addr 0x100001000) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("foo") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_type (0x000000a7 -CHECK: DW_AT_low_pc (0x0000000100000ed0) -CHECK: DW_AT_high_pc (0x0000000100000f19) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("arg") -CHECK: DW_AT_type (0x000000a7 -CHECK: DW_AT_location (DW_OP_fbreg -4) -CHECK: NULL -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_type (0x000000a7 -CHECK: DW_AT_low_pc (0x0000000100000f20) -CHECK: DW_AT_high_pc (0x0000000100000f37) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: NULL - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_name ("basic3.c") -CHECK: DW_AT_stmt_list (0x00000093) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("val") -CHECK: DW_AT_type (0x00000162 -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c") -BASIC: DW_AT_location (DW_OP_addr 0x100001004) -ARCHIVE: DW_AT_location (DW_OP_addr 0x100001008) -CHECK: DW_TAG_volatile_type -CHECK: DW_AT_type (0x00000167 -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("int") -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("bar") -CHECK: DW_AT_type (0x00000167 -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_AT_high_pc (0x0000000100000f84) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("arg") -CHECK: DW_AT_type (0x00000167 -CHECK: DW_AT_location (DW_OP_fbreg -8) -CHECK: NULL -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_type (0x00000167 -CHECK: DW_AT_low_pc (0x0000000100000f90) -CHECK: DW_AT_high_pc (0x0000000100000fa9) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) - -CHECK: NULL - -CHECK-NOT: .debug_loc contents - -CHECK:.debug_aranges contents: -CHECK-NEXT:Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000ea0, 0x0000000100000ec4) -CHECK-NEXT:Address Range Header: length = 0x0000003c, format = DWARF32, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000ed0, 0x0000000100000f19) -CHECK-NEXT:[0x0000000100000f20, 0x0000000100000f37) -CHECK-NEXT:Address Range Header: length = 0x0000003c, format = DWARF32, version = 0x0002, cu_offset = 0x00000126, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT:[0x0000000100000f40, 0x0000000100000f84) -CHECK-NEXT:[0x0000000100000f90, 0x0000000100000fa9) - -CHECK: .debug_line contents: -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic1.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000ea0 23 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000eb6 24 0 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000ec4 24 0 1 0 0 0 is_stmt end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic2.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000ed0 19 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000ee2 20 0 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f19 20 0 1 0 0 0 is_stmt end_sequence -CHECK-NEXT: 0x0000000100000f20 14 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f24 15 0 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f37 15 0 1 0 0 0 is_stmt end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic3.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000f40 16 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f4b 17 0 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f58 18 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f6c 19 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f7b 20 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f84 20 0 1 0 0 0 is_stmt end_sequence -CHECK-NEXT: 0x0000000100000f90 11 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f9b 12 0 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000fa9 12 0 1 0 0 0 is_stmt end_sequence diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-dw4-linking-x86.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-dw4-linking-x86.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-dw4-linking-x86.test +++ /dev/null @@ -1,183 +0,0 @@ -RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s - -CHECK: file format Mach-O 64-bit x86-64 - -CHECK: debug_info contents - -CHECK: Compile Unit: {{.*}} version = 0x0004 -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("clang version 3.7.0 ") -CHECK: DW_AT_language (DW_LANG_C99) -CHECK: DW_AT_name ("basic1.c") -CHECK: DW_AT_stmt_list (0x00000000) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_AT_high_pc (0x0000000100000f4b) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_AT_high_pc (0x0000000100000f4b) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_AT_name ("main") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_prototyped (true) -CHECK: DW_AT_type (0x00000000000000a1 -CHECK: DW_AT_external (true) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_location (DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK: DW_AT_name ("argc") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_type (0x00000000000000a1 -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_location (DW_OP_reg4 RSI) -CHECK: DW_AT_name ("argv") -CHECK: DW_AT_type (0x00000060 -CHECK: NULL -CHECK: DW_TAG_pointer_type -CHECK: DW_AT_type (0x00000065 -CHECK: DW_TAG_pointer_type -CHECK: DW_TAG_const_type -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("char") -CHECK: DW_AT_encoding (DW_ATE_signed_char) -CHECK: DW_AT_byte_size (0x01) -CHECK: NULL - -CHECK: Compile Unit:{{.*}} version = 0x0004 - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("clang version 3.7.0 ") -CHECK: DW_AT_language (DW_LANG_C99) -CHECK: DW_AT_name ("basic2.c") -CHECK: DW_AT_stmt_list (0x00000044) -CHECK: DW_AT_low_pc (0x0000000100000f50) -CHECK: DW_AT_high_pc (0x0000000100000f87) -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("int") -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("baz") -CHECK: DW_AT_location (DW_OP_addr 0x100001000) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("private_int") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location (DW_OP_addr 0x100001008) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_type (0x000000a1 -CHECK: DW_AT_inline (DW_INL_inlined) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_low_pc (0x0000000100000f50) -CHECK: DW_AT_high_pc (0x0000000100000f87) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_AT_name ("foo") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_prototyped (true) -CHECK: DW_AT_type (0x000000a1 -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_location (0x00000000 -CHECK: [0x0000000100000f50, 0x0000000100000f5c): DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK: DW_AT_name ("arg") -CHECK: DW_AT_type (0x000000a1 -CHECK: DW_TAG_inlined_subroutine -CHECK: DW_AT_abstract_origin (0x000000d2 "inc") -CHECK: DW_AT_low_pc (0x0000000100000f61) -CHECK: DW_AT_high_pc (0x0000000100000f70) -CHECK: NULL -CHECK: NULL - -CHECK: Compile Unit: {{.*}} version = 0x0004 - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("clang version 3.7.0 ") -CHECK: DW_AT_name ("basic3.c") -CHECK: DW_AT_stmt_list (0x0000009a) -CHECK: DW_AT_low_pc (0x0000000100000f90) -CHECK: DW_AT_high_pc (0x0000000100000fb4) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("val") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c") -CHECK: DW_AT_location (DW_OP_addr 0x100001004) -CHECK: DW_TAG_volatile_type -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_inline (DW_INL_inlined) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_low_pc (0x0000000100000f90) -CHECK: DW_AT_high_pc (0x0000000100000fb4) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_AT_name ("bar") -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_location (0x00000025 -CHECK: [0x0000000100000f90, 0x0000000100000f9f): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK: [0x0000000100000fa9, 0x0000000100000fad): DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK: DW_AT_name ("arg") -CHECK: DW_TAG_inlined_subroutine -CHECK: DW_AT_abstract_origin (0x0000015f "inc") -CHECK: DW_AT_ranges (0x00000000 -CHECK: [0x0000000100000f94, 0x0000000100000f9a) -CHECK: [0x0000000100000f9f, 0x0000000100000fa7)) - -CHECK: NULL -CHECK: NULL - - -CHECK: .debug_loc contents: -CHECK-NEXT: 0x00000000: -CHECK-NEXT: (0x0000000000000000, 0x000000000000000c): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK-NOT: : -CHECK: 0x00000025: -CHECK-NEXT: (0x0000000000000000, 0x000000000000000f): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK-NEXT: (0x0000000000000019, 0x000000000000001d): DW_OP_reg5 RDI, DW_OP_piece 0x4 - - -CHECK: .debug_aranges contents: -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b) -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000077, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f87) -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x0000011b, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4) - -CHECK: .debug_line contents: -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic1.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000f40 26 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f44 27 10 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f49 27 3 1 0 0 0 -CHECK-NEXT: 0x0000000100000f4b 27 3 1 0 0 0 end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic2.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000f50 19 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f54 20 18 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f5a 20 17 1 0 0 0 -CHECK-NEXT: 0x0000000100000f5c 20 10 1 0 0 0 -CHECK-NEXT: 0x0000000100000f61 15 10 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f70 20 23 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f74 20 36 1 0 0 0 -CHECK-NEXT: 0x0000000100000f83 20 31 1 0 0 0 -CHECK-NEXT: 0x0000000100000f85 20 3 1 0 0 0 -CHECK-NEXT: 0x0000000100000f87 20 3 1 0 0 0 end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic3.c" -CHECK-NEXT: dir_index: 0 -CHECK: Address Line Column File ISA Discriminator OpIndex Flags -CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- ------- ------------- -CHECK-NEXT: 0x0000000100000f90 16 0 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f94 12 10 1 0 0 0 is_stmt prologue_end -CHECK-NEXT: 0x0000000100000f9a 17 7 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000f9f 12 10 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000fa7 20 1 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000fa9 19 18 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000fab 19 10 1 0 0 0 -CHECK-NEXT: 0x0000000100000fb2 20 1 1 0 0 0 is_stmt -CHECK-NEXT: 0x0000000100000fb4 20 1 1 0 0 0 is_stmt end_sequence - -CHECK-NOT: .debug_pubnames contents: -CHECK-NOT: .debug_pubtypes contents: diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-linking-x86.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-linking-x86.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-lto-linking-x86.test +++ /dev/null @@ -1,182 +0,0 @@ -RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/../.. %p/../../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s -RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. -dump-debug-map %p/../../Inputs/basic-lto.macho.x86_64 | dsymutil -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s - -CHECK: file format Mach-O 64-bit x86-64 - -CHECK: debug_info contents - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_language (DW_LANG_C99) -CHECK: DW_AT_name ("basic1.c") -CHECK: DW_AT_stmt_list (0x00000000) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("main") -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic1.c") -CHECK: DW_AT_decl_line (23) -CHECK: DW_AT_prototyped (0x01) -CHECK: DW_AT_type (0x00000063 -CHECK: DW_AT_external (0x01) -CHECK: DW_AT_accessibility (DW_ACCESS_public) -CHECK: DW_AT_low_pc (0x0000000100000f40) -CHECK: DW_AT_high_pc (0x0000000100000f4b) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("argc") -CHECK: DW_AT_type (0x00000063 -CHECK: DW_AT_location (DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("argv") -CHECK: DW_AT_type (0x0000006a -CHECK: DW_AT_location (DW_OP_reg4 RSI) -CHECK: NULL -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("int") -CHECK: DW_AT_encoding (DW_ATE_signed) -CHECK: DW_AT_byte_size (0x04) -CHECK: DW_TAG_pointer_type -CHECK: DW_AT_type (0x0000006f -CHECK: DW_TAG_pointer_type -CHECK: DW_AT_type (0x00000074 -CHECK: DW_TAG_const_type -CHECK: DW_AT_type (0x00000079 -CHECK: DW_TAG_base_type -CHECK: DW_AT_name ("char") -CHECK: DW_AT_encoding (DW_ATE_signed_char) -CHECK: DW_AT_byte_size (0x01) -CHECK: NULL - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_name ("basic2.c") -CHECK: DW_AT_stmt_list (0x0000003e) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000f50) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("private_int") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic2.c") -CHECK: DW_AT_location (DW_OP_addr 0x100001008) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("baz") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_location (DW_OP_addr 0x100001000) -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("foo") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_low_pc (0x0000000100000f50) -CHECK: DW_AT_high_pc (0x0000000100000f89) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("arg") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_location (0x00000000 -CHECK: [0x0000000100000f50, 0x0000000100000f5e): DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK:[[INC1:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine -CHECK: DW_AT_abstract_origin (0x00000128 "inc") -CHECK: DW_AT_low_pc (0x0000000100000f63) -CHECK: DW_AT_high_pc (0x0000000100000f72) -CHECK: DW_AT_call_line (20) -CHECK: NULL -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_inline (DW_INL_inlined) -CHECK: NULL - -CHECK: Compile Unit: - -CHECK: DW_TAG_compile_unit -CHECK: DW_AT_producer ("Apple LLVM version 6.0 (clang-600.0.39) (based on LLVM 3.5svn)") -CHECK: DW_AT_name ("basic3.c") -CHECK: DW_AT_stmt_list (0x0000007e) -CHECK: DW_AT_comp_dir ("/Inputs") -CHECK: DW_AT_low_pc (0x0000000100000f90) -CHECK: DW_TAG_variable -CHECK: DW_AT_name ("val") -CHECK: DW_AT_type (0x00000176 -CHECK: DW_AT_decl_file ("/Inputs{{[/\\]}}basic3.c") -CHECK: DW_AT_location (DW_OP_addr 0x100001004) -CHECK: DW_TAG_volatile_type -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("bar") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_low_pc (0x0000000100000f90) -CHECK: DW_AT_high_pc (0x0000000100000fb4) -CHECK: DW_AT_frame_base (DW_OP_reg6 RBP) -CHECK: DW_TAG_formal_parameter -CHECK: DW_AT_name ("arg") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: DW_AT_location (0x00000025 -CHECK: [0x0000000100000f90, 0x0000000100000f9f): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK: [0x0000000100000fa9, 0x0000000100000fad): DW_OP_reg5 RDI, DW_OP_piece 0x4) -CHECK: DW_TAG_lexical_block -CHECK: DW_AT_low_pc (0x0000000100000f94) -CHECK: DW_AT_high_pc (0x0000000100000fa7) -CHECK:[[INC2:0x[0-9a-f]*]]{{.*}}DW_TAG_inlined_subroutine -CHECK: DW_AT_abstract_origin (0x000001d4 "inc") -CHECK: DW_AT_ranges (0x00000000 -CHECK: [0x0000000100000f94, 0x0000000100000f9a) -CHECK: [0x0000000100000f9f, 0x0000000100000fa7)) -CHECK: NULL -CHECK: NULL -CHECK: DW_TAG_subprogram -CHECK: DW_AT_name ("inc") -CHECK: DW_AT_type (0x0000000000000063 -CHECK: NULL - -CHECK: .debug_loc contents: -CHECK-NEXT: 0x00000000: -CHECK-NEXT: (0x0000000000000000, 0x000000000000000e): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK-NOT: : -CHECK: 0x00000025: -CHECK-NEXT: (0x0000000000000000, 0x000000000000000f): DW_OP_reg5 RDI, DW_OP_piece 0x4 -CHECK-NEXT: (0x0000000000000019, 0x000000000000001d): DW_OP_reg5 RDI, DW_OP_piece 0x4 - -CHECK: .debug_aranges contents: -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f40, 0x0000000100000f4b) -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000081, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f50, 0x0000000100000f89) -CHECK-NEXT: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x0000013a, addr_size = 0x08, seg_size = 0x00 -CHECK-NEXT: [0x0000000100000f90, 0x0000000100000fb4) - - -CHECK: .debug_line contents -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic1.c" -CHECK-NEXT: dir_index: 0 -CHECK: 0x0000000100000f40 23 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f44 24 0 1 0 0 0 is_stmt prologue_end -CHECK: 0x0000000100000f4b 24 0 1 0 0 0 is_stmt end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic2.c" -CHECK-NEXT: dir_index: 0 -CHECK: 0x0000000100000f50 19 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f54 20 0 1 0 0 0 is_stmt prologue_end -CHECK: 0x0000000100000f63 15 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f72 20 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f89 20 0 1 0 0 0 is_stmt end_sequence - -CHECK: file_names[ 1]: -CHECK-NEXT: name: "basic3.c" -CHECK-NEXT: dir_index: 0 -CHECK: 0x0000000100000f90 16 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f94 12 0 1 0 0 0 is_stmt prologue_end -CHECK: 0x0000000100000f9a 17 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000f9f 12 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000fa7 20 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000fa9 19 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000fb2 20 0 1 0 0 0 is_stmt -CHECK: 0x0000000100000fb4 20 0 1 0 0 0 is_stmt end_sequence - -CHECK-NOT: .debug_pubnames contents: -CHECK-NOT: .debug_pubtypes contents: diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-with-libfat-test.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-with-libfat-test.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/basic-with-libfat-test.test +++ /dev/null @@ -1,12 +0,0 @@ -RUN: cat %p/../../Inputs/basic-with-libfat-test.macho.x86_64 > %t1 -RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t1 -RUN: llvm-dwarfdump %t1.dwarf | FileCheck %s - -The test binary was created by force-linking the libfat-test.a fat archive -with the basic linking test archive, like so: -$ clang -all_load libfat-test.a libbasic.a basic1.macho.x86_64.o -Wl,-dead_strip -u _x86_64_var - -CHECK: DW_AT_name{{.*}}"x86_64_var" -CHECK: DW_AT_name{{.*}}"basic2.c" -CHECK: DW_AT_name{{.*}}"basic3.c" -CHECK: DW_AT_name{{.*}}"basic1.c" diff --git a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/multiple-inputs.test b/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/multiple-inputs.test deleted file mode 100644 --- a/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/multiple-inputs.test +++ /dev/null @@ -1,30 +0,0 @@ -RUN: rm -rf %t -RUN: mkdir -p %t - -RUN: cat %p/../../Inputs/basic.macho.x86_64 > %t/basic.macho.x86_64 -RUN: cat %p/../../Inputs/basic-archive.macho.x86_64 > %t/basic-archive.macho.x86_64 -RUN: cat %p/../../Inputs/basic-lto.macho.x86_64 > %t/basic-lto.macho.x86_64 -RUN: cat %p/../../Inputs/basic-lto-dw4.macho.x86_64 > %t/basic-lto-dw4.macho.x86_64 - -# Multiple inputs in flat mode -RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dwarf \ -RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC -RUN: llvm-dwarfdump -a %t/basic-archive.macho.x86_64.dwarf \ -RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE -RUN: llvm-dwarfdump -a %t/basic-lto.macho.x86_64.dwarf | FileCheck %S/basic-lto-linking-x86.test -RUN: llvm-dwarfdump -a %t/basic-lto-dw4.macho.x86_64.dwarf | FileCheck %S/basic-lto-dw4-linking-x86.test - -# Multiple inputs that end up in the same named bundle -RUN: dsymutil --linker llvm -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM -RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 \ -RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC -RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-archive.macho.x86_64 \ -RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE -RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto.macho.x86_64 | FileCheck %S/basic-lto-linking-x86.test -RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto-dw4.macho.x86_64 | FileCheck %S/basic-lto-dw4-linking-x86.test - -# Multiple inputs in a named bundle in flat mode... impossible. -RUN: not dsymutil --linker llvm -f -oso-prepend-path=%p/../.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s - -CHECK: error: cannot use -o with multiple inputs in flat mode diff --git a/llvm/test/tools/dsymutil/X86/basic-linking-bundle.test b/llvm/test/tools/dsymutil/X86/basic-linking-bundle.test --- a/llvm/test/tools/dsymutil/X86/basic-linking-bundle.test +++ b/llvm/test/tools/dsymutil/X86/basic-linking-bundle.test @@ -19,6 +19,25 @@ RUN: llvm-dwarfdump -a %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist +## Repeat steps for --linker llvm + +RUN: dsymutil --linker llvm -accelerator=Pub -oso-prepend-path=%p/.. %t/basic.macho.x86_64 + +Check that the object file in the bundle exists and is sane: +RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test + +Check that we don't create an empty Remarks directory if there are no remarks. +RUN: not ls %t/basic.macho.x86_64.dSYM/Contents/Resources/Remarks + +Check that llvm-dwarfdump -a recognizes the bundle as a dSYM: +RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dSYM | FileCheck %S/basic-linking-x86.test + +RUN: FileCheck %s --input-file %t/basic.macho.x86_64.dSYM/Contents/Info.plist + +RUN: dsymutil --linker llvm -oso-prepend-path=%p/.. %t/basic.macho.x86_64 -o %t/dsymdest/basic.macho.x86_64.dSYM +RUN: llvm-dwarfdump -a %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 | FileCheck %S/basic-linking-x86.test +RUN: FileCheck %s --input-file %t/dsymdest/basic.macho.x86_64.dSYM/Contents/Info.plist + CHECK: CHECK-NEXT: CHECK-NEXT: diff --git a/llvm/test/tools/dsymutil/X86/basic-linking-x86.test b/llvm/test/tools/dsymutil/X86/basic-linking-x86.test --- a/llvm/test/tools/dsymutil/X86/basic-linking-x86.test +++ b/llvm/test/tools/dsymutil/X86/basic-linking-x86.test @@ -8,6 +8,16 @@ RUN: dsymutil -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | dsymutil -accelerator=Pub -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC,PUB RUN: dsymutil -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | dsymutil -accelerator=Pub -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE,PUB +RUN: dsymutil --linker llvm -accelerator=Pub -f -oso-prepend-path=%p/.. %t1 +RUN: llvm-dwarfdump -a %t1.dwarf | FileCheck %s +RUN: dsymutil --linker llvm -accelerator=Pub -f -o %t2 -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 +RUN: llvm-dwarfdump -a %t2 | FileCheck %s +RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC,PUB +RUN: dsymutil --linker llvm -accelerator=Pub -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE,PUB +RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | dsymutil -accelerator=Pub -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,BASIC,PUB +RUN: dsymutil --linker llvm -accelerator=Pub -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | dsymutil -accelerator=Pub -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefixes=CHECK,ARCHIVE,PUB + + CHECK: file format Mach-O 64-bit x86-64 CHECK: debug_info contents diff --git a/llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test b/llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test --- a/llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test +++ b/llvm/test/tools/dsymutil/X86/basic-lto-dw4-linking-x86.test @@ -1,5 +1,9 @@ RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s +RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/.. \ +RUN: %p/../Inputs/basic-lto-dw4.macho.x86_64 | llvm-dwarfdump -a - | \ +RUN: FileCheck %s + CHECK: file format Mach-O 64-bit x86-64 CHECK: debug_info contents diff --git a/llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test b/llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test --- a/llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test +++ b/llvm/test/tools/dsymutil/X86/basic-lto-linking-x86.test @@ -1,6 +1,12 @@ RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s RUN: dsymutil -oso-prepend-path=%p/.. -dump-debug-map %p/../Inputs/basic-lto.macho.x86_64 | dsymutil -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s +RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/.. \ +RUN: %p/../Inputs/basic-lto.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s +RUN: dsymutil --linker llvm -oso-prepend-path=%p/.. -dump-debug-map \ +RUN: %p/../Inputs/basic-lto.macho.x86_64 | dsymutil -f -o - -y - | \ +RUN: llvm-dwarfdump -a - | FileCheck %s + CHECK: file format Mach-O 64-bit x86-64 CHECK: debug_info contents diff --git a/llvm/test/tools/dsymutil/X86/basic-with-libfat-test.test b/llvm/test/tools/dsymutil/X86/basic-with-libfat-test.test --- a/llvm/test/tools/dsymutil/X86/basic-with-libfat-test.test +++ b/llvm/test/tools/dsymutil/X86/basic-with-libfat-test.test @@ -1,4 +1,8 @@ -RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-with-libfat-test.macho.x86_64 | llvm-dwarfdump - | FileCheck %s +RUN: dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-with-libfat-test.macho.x86_64 | llvm-dwarfdump - | FileCheck %s + +RUN: dsymutil --linker llvm -f -o - -oso-prepend-path=%p/.. \ +RUN: %p/../Inputs/basic-with-libfat-test.macho.x86_64 | \ +RUN: llvm-dwarfdump - | FileCheck %s The test binary was created by force-linking the libfat-test.a fat archive with the basic linking test archive, like so: diff --git a/llvm/test/tools/dsymutil/X86/multiple-inputs.test b/llvm/test/tools/dsymutil/X86/multiple-inputs.test --- a/llvm/test/tools/dsymutil/X86/multiple-inputs.test +++ b/llvm/test/tools/dsymutil/X86/multiple-inputs.test @@ -27,4 +27,34 @@ # Multiple inputs in a named bundle in flat mode... impossible. RUN: not dsymutil -f -oso-prepend-path=%p/.. %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s +## The same steps for --linker llvm: + +# Multiple inputs in flat mode +RUN: dsymutil --linker llvm -f -oso-prepend-path=%p/.. %t/basic.macho.x86_64 \ +RUN: %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 \ +RUN: %t/basic-lto-dw4.macho.x86_64 +RUN: llvm-dwarfdump -a %t/basic.macho.x86_64.dwarf \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC +RUN: llvm-dwarfdump -a %t/basic-archive.macho.x86_64.dwarf \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE +RUN: llvm-dwarfdump -a %t/basic-lto.macho.x86_64.dwarf | FileCheck %S/basic-lto-linking-x86.test +RUN: llvm-dwarfdump -a %t/basic-lto-dw4.macho.x86_64.dwarf | FileCheck %S/basic-lto-dw4-linking-x86.test + +# Multiple inputs that end up in the same named bundle +RUN: dsymutil --linker llvm -oso-prepend-path=%p/.. %t/basic.macho.x86_64 \ +RUN: %t/basic-archive.macho.x86_64 %t/basic-lto.macho.x86_64 \ +RUN: %t/basic-lto-dw4.macho.x86_64 -o %t.dSYM +RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic.macho.x86_64 \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,BASIC +RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-archive.macho.x86_64 \ +RUN: | FileCheck %S/basic-linking-x86.test --check-prefixes=CHECK,ARCHIVE +RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto.macho.x86_64 | FileCheck %S/basic-lto-linking-x86.test +RUN: llvm-dwarfdump -a %t.dSYM/Contents/Resources/DWARF/basic-lto-dw4.macho.x86_64 | FileCheck %S/basic-lto-dw4-linking-x86.test + +# Multiple inputs in a named bundle in flat mode... impossible. +RUN: not dsymutil --linker llvm -f -oso-prepend-path=%p/.. \ +RUN: %t/basic.macho.x86_64 %t/basic-archive.macho.x86_64 \ +RUN: %t/basic-lto.macho.x86_64 %t/basic-lto-dw4.macho.x86_64 \ +RUN: -o %t.dSYM 2>&1 | FileCheck %s + CHECK: error: cannot use -o with multiple inputs in flat mode