diff options
| author | David Blaikie <dblaikie@gmail.com> | 2016-02-06 01:15:26 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2016-02-06 01:15:26 +0000 |
| commit | 23919372d1db1dba80e8c4697e0a0922e830fc3a (patch) | |
| tree | 0ba19e3bbb389f96193bfd799d8e22fa548abae0 | |
| parent | 81f240a3ffd357db652bab50a4bee4b3a13e582f (diff) | |
| download | bcm5719-llvm-23919372d1db1dba80e8c4697e0a0922e830fc3a.tar.gz bcm5719-llvm-23919372d1db1dba80e8c4697e0a0922e830fc3a.zip | |
[llvm-dwp] Merge cu_index from DWPs
This is almost feature complete - just missing tu_index merging now.
llvm-svn: 259971
| -rw-r--r-- | llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h | 11 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp | bin | 0 -> 1384 bytes | |||
| -rw-r--r-- | llvm/test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo | bin | 0 -> 1257 bytes | |||
| -rw-r--r-- | llvm/test/tools/llvm-dwp/X86/merge.test | 48 | ||||
| -rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 43 |
5 files changed, 96 insertions, 6 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h index a85c2f9f0a2..9f051cd7081 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h @@ -10,6 +10,7 @@ #ifndef LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H #define LLVM_LIB_DEBUGINFO_DWARFUNITINDEX_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/Support/DataExtractor.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -56,6 +57,10 @@ public: public: const SectionContribution *getOffset(DWARFSectionKind Sec) const; const SectionContribution *getOffset() const; + const SectionContribution *getOffsets() const { + return Contributions.get(); + } + uint64_t getSignature() const { return Signature; } }; private: @@ -75,6 +80,12 @@ public: : InfoColumnKind(InfoColumnKind) {} void dump(raw_ostream &OS) const; const Entry *getFromOffset(uint32_t Offset) const; + ArrayRef<DWARFSectionKind> getColumnKinds() const { + return makeArrayRef(ColumnKinds.get(), Header.NumColumns); + } + ArrayRef<Entry> getRows() const { + return makeArrayRef(Rows.get(), Header.NumBuckets); + } }; } diff --git a/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp b/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp Binary files differnew file mode 100644 index 00000000000..a3274f1e23e --- /dev/null +++ b/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp diff --git a/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo b/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo Binary files differnew file mode 100644 index 00000000000..e02969d365b --- /dev/null +++ b/llvm/test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo diff --git a/llvm/test/tools/llvm-dwp/X86/merge.test b/llvm/test/tools/llvm-dwp/X86/merge.test new file mode 100644 index 00000000000..8feb5a0237e --- /dev/null +++ b/llvm/test/tools/llvm-dwp/X86/merge.test @@ -0,0 +1,48 @@ +RUN: llvm-dwp %p/../Inputs/merge/notypes/c.dwo %p/../Inputs/merge/notypes/ab.dwp -o %t +RUN: llvm-dwarfdump %t | FileCheck --check-prefix=CHECK --check-prefix=NOTYP %s + +FIXME: For some reason, piping straight from llvm-dwp to llvm-dwarfdump doesn't behave well - looks like dwarfdump is reading/closes before dwp has finished. + +DWP from a DWO (c.dwo) and a DWP (ab.dwp, created from a.dwo and b.dwo) +Make sure the entries for A and B are updated correctly when read/processed from ab.dwp +a.cpp: + struct foo { }; + foo a; + +b.cpp: + struct bar { }; + void b(bar) { + } + +c.cpp: + typedef int baz; + baz c() { + } + +CHECK-LABEL: .debug_abbrev.dwo contents: +CHECK-LABEL: Abbrev table for offset: +CHECK: 0x0000[[CAOFF:.*]] +CHECK-LABEL: Abbrev table for offset: +CHECK: 0x0000[[AAOFF:.*]] +CHECK-LABEL: Abbrev table for offset: +CHECK: 0x0000[[BAOFF:.*]] + +CHECK: .debug_info.dwo contents: +CHECK: [[COFF:0x[0-9a-f]*]]: +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = +CHECK: 0x[[CAOFF]] addr_size = 0x08 (next unit at [[AOFF:.*]]) +CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOC:.*]]) +CHECK: [[AOFF]]: +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = +CHECK: 0x[[AAOFF]] addr_size = 0x08 (next unit at [[BOFF:.*]]) +CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOA:.*]]) +CHECK: [[BOFF]]: +CHECK-LABEL: Compile Unit: length = {{.*}} version = 0x0004 abbr_offset = +CHECK: 0x[[BAOFF]] addr_size = 0x08 (next unit at [[XOFF:.*]]) +CHECK: DW_AT_GNU_dwo_id {{.*}} ([[DWOB:.*]]) + +CHECK-LABEL: .debug_cu_index +CHECK: Index Signature INFO ABBREV LINE STR_OFFSETS +CHECK-DAG: [[DWOC]] {{\[}}[[COFF]], [[AOFF]]) [0x0000[[CAOFF]], 0x0000[[AAOFF]]) [0x00000000, 0x00000011) [0x00000000, 0x00000018) +CHECK-DAG: [[DWOA]] {{\[}}[[AOFF]], [[BOFF]]) [0x0000[[AAOFF]], 0x0000[[BAOFF]]) [0x00000011, 0x00000022) [0x00000018, 0x00000028) +CHECK-DAG: [[DWOB]] {{\[}}[[BOFF]], [[XOFF]]) [0x0000[[BAOFF]], 0x000000c3) [0x00000022, 0x00000033) [0x00000028, 0x0000003c) diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index 570854b849c..bf0d29f4c2d 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -24,6 +24,7 @@ #include <list> #include <memory> #include <unordered_set> +#include <system_error> using namespace llvm; using namespace llvm::object; @@ -239,6 +240,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { MCSection *const StrSection = MCOFI.getDwarfStrDWOSection(); MCSection *const StrOffsetSection = MCOFI.getDwarfStrOffDWOSection(); MCSection *const TypesSection = MCOFI.getDwarfTypesDWOSection(); + MCSection *const CUIndexSection = MCOFI.getDwarfCUIndexSection(); const StringMap<std::pair<MCSection *, DWARFSectionKind>> KnownSections = { {"debug_info.dwo", {MCOFI.getDwarfInfoDWOSection(), DW_SECT_INFO}}, {"debug_types.dwo", {MCOFI.getDwarfTypesDWOSection(), DW_SECT_TYPES}}, @@ -246,7 +248,9 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { {"debug_str.dwo", {StrSection, static_cast<DWARFSectionKind>(0)}}, {"debug_loc.dwo", {MCOFI.getDwarfLocDWOSection(), DW_SECT_LOC}}, {"debug_line.dwo", {MCOFI.getDwarfLineDWOSection(), DW_SECT_LINE}}, - {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}}}; + {"debug_abbrev.dwo", {MCOFI.getDwarfAbbrevDWOSection(), DW_SECT_ABBREV}}, + {"debug_cu_index", + {MCOFI.getDwarfCUIndexSection(), static_cast<DWARFSectionKind>(0)}}}; std::vector<UnitIndexEntry> IndexEntries; std::vector<UnitIndexEntry> TypeIndexEntries; @@ -261,14 +265,14 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { if (!ErrOrObj) return ErrOrObj.getError(); - IndexEntries.emplace_back(); - UnitIndexEntry &CurEntry = IndexEntries.back(); + UnitIndexEntry CurEntry = {}; StringRef CurStrSection; StringRef CurStrOffsetSection; StringRef CurTypesSection; StringRef InfoSection; StringRef AbbrevSection; + StringRef CurCUIndexSection; for (const auto &Section : ErrOrObj->getBinary()->sections()) { StringRef Name; @@ -311,6 +315,8 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { CurStrSection = Contents; else if (OutSection == TypesSection) CurTypesSection = Contents; + else if (OutSection == CUIndexSection) + CurCUIndexSection = Contents; else { Out.SwitchSection(OutSection); Out.EmitBytes(Contents); @@ -319,9 +325,34 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) { assert(!AbbrevSection.empty()); assert(!InfoSection.empty()); - CurEntry.Signature = getCUSignature(AbbrevSection, InfoSection); - addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection, CurEntry, - ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]); + if (!CurCUIndexSection.empty()) { + DWARFUnitIndex CUIndex(DW_SECT_INFO); + DataExtractor CUIndexData(CurCUIndexSection, + ErrOrObj->getBinary()->isLittleEndian(), 0); + if (!CUIndex.parse(CUIndexData)) + return make_error_code(std::errc::invalid_argument); + + for (const DWARFUnitIndex::Entry &E : CUIndex.getRows()) { + auto NewEntry = CurEntry; + auto *I = E.getOffsets(); + if (!I) + continue; + NewEntry.Signature = E.getSignature(); + for (auto Kind : CUIndex.getColumnKinds()) { + auto &C = NewEntry.Contributions[Kind - DW_SECT_INFO]; + C.Offset += I->Offset; + C.Length = I->Length; + ++I; + } + IndexEntries.push_back(NewEntry); + } + } else { + CurEntry.Signature = getCUSignature(AbbrevSection, InfoSection); + addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection, + CurEntry, ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]); + + IndexEntries.push_back(CurEntry); + } if (auto Err = writeStringsAndOffsets(Out, Strings, StringOffset, StrSection, StrOffsetSection, |

