mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
llvm-dwp: Add error handling for invalid (non-CU) top level tag in debug_info.dwo
The diagnostic could be improved a bit to include information about which input file had the mistake (& which unit (counted, since the name of the unit won't be accessible) within the input). llvm-svn: 269723
This commit is contained in:
parent
a338cd2790
commit
db05b7f61e
BIN
test/tools/llvm-dwp/Inputs/non_cu_top_level.dwo
Normal file
BIN
test/tools/llvm-dwp/Inputs/non_cu_top_level.dwo
Normal file
Binary file not shown.
3
test/tools/llvm-dwp/X86/non_cu_top_level.test
Normal file
3
test/tools/llvm-dwp/X86/non_cu_top_level.test
Normal file
@ -0,0 +1,3 @@
|
||||
RUN: not llvm-dwp %p/../Inputs/non_cu_top_level.dwo -o %t 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: error: top level DIE is not a compile unit
|
@ -141,9 +141,10 @@ static const char *getIndexedString(uint32_t Form, DataExtractor InfoData,
|
||||
return StrData.getCStr(&StrOffset);
|
||||
}
|
||||
|
||||
static CompileUnitIdentifiers getCUIdentifiers(StringRef Abbrev, StringRef Info,
|
||||
StringRef StrOffsets,
|
||||
StringRef Str) {
|
||||
static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
|
||||
StringRef Info,
|
||||
StringRef StrOffsets,
|
||||
StringRef Str) {
|
||||
uint32_t Offset = 0;
|
||||
DataExtractor InfoData(Info, true, 0);
|
||||
InfoData.getU32(&Offset); // Length
|
||||
@ -156,9 +157,8 @@ static CompileUnitIdentifiers getCUIdentifiers(StringRef Abbrev, StringRef Info,
|
||||
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);
|
||||
if (Tag != dwarf::DW_TAG_compile_unit)
|
||||
return make_error<DWPError>("top level DIE is not a compile unit");
|
||||
// DW_CHILDREN
|
||||
AbbrevData.getU8(&AbbrevOffset);
|
||||
uint32_t Name;
|
||||
@ -506,11 +506,14 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
||||
continue;
|
||||
auto P =
|
||||
IndexEntries.insert(std::make_pair(E.getSignature(), CurEntry));
|
||||
CompileUnitIdentifiers ID = getCUIdentifiers(
|
||||
Expected<CompileUnitIdentifiers> EID = getCUIdentifiers(
|
||||
getSubsection(AbbrevSection, E, DW_SECT_ABBREV),
|
||||
getSubsection(InfoSection, E, DW_SECT_INFO),
|
||||
getSubsection(CurStrOffsetSection, E, DW_SECT_STR_OFFSETS),
|
||||
CurStrSection);
|
||||
if (!EID)
|
||||
return EID.takeError();
|
||||
const auto &ID = *EID;
|
||||
if (!P.second)
|
||||
return make_error<DWPError>(buildDuplicateError(*P.first, ID, Input));
|
||||
auto &NewEntry = P.first->second;
|
||||
@ -537,8 +540,11 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
|
||||
ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO]);
|
||||
}
|
||||
} else {
|
||||
CompileUnitIdentifiers ID = getCUIdentifiers(
|
||||
Expected<CompileUnitIdentifiers> EID = getCUIdentifiers(
|
||||
AbbrevSection, InfoSection, CurStrOffsetSection, CurStrSection);
|
||||
if (!EID)
|
||||
return EID.takeError();
|
||||
const auto &ID = *EID;
|
||||
auto P = IndexEntries.insert(std::make_pair(ID.Signature, CurEntry));
|
||||
if (!P.second)
|
||||
return make_error<DWPError>(buildDuplicateError(*P.first, ID, ""));
|
||||
|
Loading…
Reference in New Issue
Block a user