mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
llvm-dwp: provide diagnostics for duplicate DWO IDs
These diagnostics aren't perfect - in the case of merging several dwos into dwps and those dwps into more dwps - just getting the message about the original source file name might not be much help (since it's the same in both dwos, by definition - but doesn't tell you which chain of dwps to backtrack) It might be worth adding the DW_AT_dwo_id to the split debug info to improve the diagnostic experience - might help track down the duplicates better. llvm-svn: 261988
This commit is contained in:
parent
97ae473a6b
commit
f8f826e596
BIN
test/tools/llvm-dwp/Inputs/duplicate/ac.dwp
Normal file
BIN
test/tools/llvm-dwp/Inputs/duplicate/ac.dwp
Normal file
Binary file not shown.
BIN
test/tools/llvm-dwp/Inputs/duplicate/bc.dwp
Normal file
BIN
test/tools/llvm-dwp/Inputs/duplicate/bc.dwp
Normal file
Binary file not shown.
BIN
test/tools/llvm-dwp/Inputs/duplicate/c.dwo
Normal file
BIN
test/tools/llvm-dwp/Inputs/duplicate/c.dwo
Normal file
Binary file not shown.
18
test/tools/llvm-dwp/X86/duplicate.test
Normal file
18
test/tools/llvm-dwp/X86/duplicate.test
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
RUN: not llvm-dwp %p/../Inputs/duplicate/c.dwo %p/../Inputs/duplicate/c.dwo -o %t 2>&1 \
|
||||||
|
RUN: | FileCheck --check-prefix=CHECK %s
|
||||||
|
|
||||||
|
RUN: not llvm-dwp %p/../Inputs/duplicate/c.dwo %p/../Inputs/duplicate/bc.dwp -o %t 2>&1 \
|
||||||
|
RUN: | FileCheck --check-prefix=CHECK --check-prefix=DWP2 %s
|
||||||
|
|
||||||
|
RUN: not llvm-dwp %p/../Inputs/duplicate/ac.dwp %p/../Inputs/duplicate/c.dwo -o %t 2>&1 \
|
||||||
|
RUN: | FileCheck --check-prefix=CHECK --check-prefix=DWP1 %s
|
||||||
|
|
||||||
|
RUN: not llvm-dwp %p/../Inputs/duplicate/ac.dwp %p/../Inputs/duplicate/bc.dwp -o %t 2>&1 \
|
||||||
|
RUN: | FileCheck --check-prefix=CHECK --check-prefix=DWP1 --check-prefix=DWP2 %s
|
||||||
|
|
||||||
|
Build from a, b, and c.c all containing a single void() func by the name of the file.
|
||||||
|
|
||||||
|
CHECK: Duplicate DWO ID ({{.*}}) in 'c.c'
|
||||||
|
DWP1-SAME: (from '{{.*}}ac.dwp')
|
||||||
|
CHECK-SAME: and 'c.c'
|
||||||
|
DWP2-SAME: (from '{{.*}}bc.dwp')
|
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
@ -106,6 +107,43 @@ static uint32_t getCUAbbrev(StringRef Abbrev, uint64_t AbbrCode) {
|
|||||||
return Offset;
|
return Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *getCUName(StringRef Abbrev, StringRef Info,
|
||||||
|
StringRef StrOffsets, StringRef Str) {
|
||||||
|
uint32_t Offset = 0;
|
||||||
|
DataExtractor InfoData(Info, true, 0);
|
||||||
|
InfoData.getU32(&Offset); // Length
|
||||||
|
uint16_t Version = InfoData.getU16(&Offset);
|
||||||
|
InfoData.getU32(&Offset); // Abbrev offset (should be zero)
|
||||||
|
uint8_t AddrSize = InfoData.getU8(&Offset);
|
||||||
|
|
||||||
|
uint32_t AbbrCode = InfoData.getULEB128(&Offset);
|
||||||
|
|
||||||
|
DataExtractor AbbrevData(Abbrev, true, 0);
|
||||||
|
uint32_t AbbrevOffset = getCUAbbrev(Abbrev, AbbrCode);
|
||||||
|
uint64_t Tag = AbbrevData.getULEB128(&AbbrevOffset);
|
||||||
|
(void)Tag;
|
||||||
|
// FIXME: Real error handling
|
||||||
|
assert(Tag == dwarf::DW_TAG_compile_unit);
|
||||||
|
// DW_CHILDREN
|
||||||
|
AbbrevData.getU8(&AbbrevOffset);
|
||||||
|
uint32_t Name;
|
||||||
|
uint32_t Form;
|
||||||
|
while ((Name = AbbrevData.getULEB128(&AbbrevOffset)) |
|
||||||
|
(Form = AbbrevData.getULEB128(&AbbrevOffset)) &&
|
||||||
|
Name != dwarf::DW_AT_name) {
|
||||||
|
DWARFFormValue::skipValue(Form, InfoData, &Offset, Version, AddrSize);
|
||||||
|
}
|
||||||
|
// FIXME: Real error handling
|
||||||
|
assert(Name == dwarf::DW_AT_name);
|
||||||
|
auto StrIndex = InfoData.getULEB128(&Offset);
|
||||||
|
|
||||||
|
DataExtractor StrOffsetsData(StrOffsets, true, 0);
|
||||||
|
uint32_t StrOffsetsOffset = 4 * StrIndex;
|
||||||
|
uint32_t StrOffset = StrOffsetsData.getU32(&StrOffsetsOffset);
|
||||||
|
DataExtractor StrData(Str, true, 0);
|
||||||
|
return StrData.getCStr(&StrOffset);
|
||||||
|
}
|
||||||
|
|
||||||
static uint64_t getCUSignature(StringRef Abbrev, StringRef Info) {
|
static uint64_t getCUSignature(StringRef Abbrev, StringRef Info) {
|
||||||
uint32_t Offset = 0;
|
uint32_t Offset = 0;
|
||||||
DataExtractor InfoData(Info, true, 0);
|
DataExtractor InfoData(Info, true, 0);
|
||||||
@ -138,8 +176,17 @@ static uint64_t getCUSignature(StringRef Abbrev, StringRef Info) {
|
|||||||
|
|
||||||
struct UnitIndexEntry {
|
struct UnitIndexEntry {
|
||||||
DWARFUnitIndex::Entry::SectionContribution Contributions[8];
|
DWARFUnitIndex::Entry::SectionContribution Contributions[8];
|
||||||
|
std::string Name;
|
||||||
|
StringRef DWPName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StringRef getSubsection(StringRef Section, const DWARFUnitIndex::Entry &Entry, DWARFSectionKind Kind) {
|
||||||
|
const auto *Off = Entry.getOffset(Kind);
|
||||||
|
if (!Off)
|
||||||
|
return StringRef();
|
||||||
|
return Section.substr(Off->Offset, Off->Length);
|
||||||
|
}
|
||||||
|
|
||||||
static void addAllTypesFromDWP(
|
static void addAllTypesFromDWP(
|
||||||
MCStreamer &Out, MapVector<uint64_t, UnitIndexEntry> &TypeIndexEntries,
|
MCStreamer &Out, MapVector<uint64_t, UnitIndexEntry> &TypeIndexEntries,
|
||||||
const DWARFUnitIndex &TUIndex, MCSection *OutputTypes, StringRef Types,
|
const DWARFUnitIndex &TUIndex, MCSection *OutputTypes, StringRef Types,
|
||||||
@ -416,8 +463,22 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
|||||||
continue;
|
continue;
|
||||||
auto P =
|
auto P =
|
||||||
IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));
|
IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));
|
||||||
// FIXME: Check P.second and error for duplicate CU signatures
|
const char* Name = getCUName(
|
||||||
|
getSubsection(AbbrevSection, E, DW_SECT_ABBREV),
|
||||||
|
getSubsection(InfoSection, E, DW_SECT_INFO),
|
||||||
|
getSubsection(CurStrOffsetSection, E, DW_SECT_STR_OFFSETS),
|
||||||
|
CurStrSection);
|
||||||
|
if (!P.second) {
|
||||||
|
auto &PrevE = *P.first;
|
||||||
|
std::cerr << "Duplicate DWO ID (" << PrevE.first << ") in '" << PrevE.second.Name << "' ";
|
||||||
|
if (!PrevE.second.DWPName.empty())
|
||||||
|
std::cerr << "(from '" << PrevE.second.DWPName.str() << "') ";
|
||||||
|
std::cerr << "and '" << Name << "' (from '" << Input << "')\n";
|
||||||
|
return make_error_code(std::errc::invalid_argument);
|
||||||
|
}
|
||||||
auto &NewEntry = P.first->second;
|
auto &NewEntry = P.first->second;
|
||||||
|
NewEntry.Name = Name;
|
||||||
|
NewEntry.DWPName = Input;
|
||||||
for (auto Kind : CUIndex.getColumnKinds()) {
|
for (auto Kind : CUIndex.getColumnKinds()) {
|
||||||
auto &C = NewEntry.Contributions[Kind - DW_SECT_INFO];
|
auto &C = NewEntry.Contributions[Kind - DW_SECT_INFO];
|
||||||
C.Offset += I->Offset;
|
C.Offset += I->Offset;
|
||||||
@ -439,9 +500,20 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
|||||||
ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
|
ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IndexEntries.insert(
|
auto P = IndexEntries.insert(
|
||||||
std::make_pair(getCUSignature(AbbrevSection, InfoSection), CurEntry));
|
std::make_pair(getCUSignature(AbbrevSection, InfoSection), CurEntry));
|
||||||
// FIXME: Check P.second and error for duplicate CU signatures
|
const char *Name = getCUName(AbbrevSection, InfoSection,
|
||||||
|
CurStrOffsetSection, CurStrSection);
|
||||||
|
if (!P.second) {
|
||||||
|
auto &E = *P.first;
|
||||||
|
std::cerr << "Duplicate DWO ID (" << E.first << ") in '" << Name
|
||||||
|
<< "' ";
|
||||||
|
if (!E.second.DWPName.empty())
|
||||||
|
std::cerr << "(from '" << E.second.DWPName.str() << "') ";
|
||||||
|
std::cerr << "and '" << E.second.Name << "'\n";
|
||||||
|
return make_error_code(std::errc::invalid_argument);
|
||||||
|
}
|
||||||
|
P.first->second.Name = Name;
|
||||||
addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
|
addAllTypes(Out, TypeIndexEntries, TypesSection, CurTypesSection,
|
||||||
CurEntry, ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
|
CurEntry, ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user