mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[llvm-dwp] Merge cu_index from DWPs
This is almost feature complete - just missing tu_index merging now. llvm-svn: 259971
This commit is contained in:
parent
94e9a3a474
commit
25a5770c88
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
BIN
test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp
Normal file
BIN
test/tools/llvm-dwp/Inputs/merge/notypes/ab.dwp
Normal file
Binary file not shown.
BIN
test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo
Normal file
BIN
test/tools/llvm-dwp/Inputs/merge/notypes/c.dwo
Normal file
Binary file not shown.
48
test/tools/llvm-dwp/X86/merge.test
Normal file
48
test/tools/llvm-dwp/X86/merge.test
Normal file
@ -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)
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user