1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

llvm-dwp: Provide error handling for invalid string field forms

This diagnostic could be improved by adding the name of the input file
containing the invalid data and/or some information about how to
identify the specific offending attribute/tag in the input. But that's
not an immediate priority as these corner cases of invalid input
shouldn't come up too often.

llvm-svn: 269727
This commit is contained in:
David Blaikie 2016-05-17 00:07:10 +00:00
parent 08f026523a
commit b2196ac249
3 changed files with 19 additions and 8 deletions

Binary file not shown.

View File

@ -0,0 +1,3 @@
RUN: not llvm-dwp %p/../Inputs/invalid_string_form.dwo -o %t 2>&1 | FileCheck %s
CHECK: error: string field encoded without DW_FORM_string or DW_FORM_GNU_str_index

View File

@ -125,14 +125,14 @@ struct CompileUnitIdentifiers {
const char *DWOName = "";
};
static const char *getIndexedString(uint32_t Form, DataExtractor InfoData,
uint32_t &InfoOffset, StringRef StrOffsets,
StringRef Str) {
static Expected<const char *>
getIndexedString(uint32_t Form, DataExtractor InfoData, uint32_t &InfoOffset,
StringRef StrOffsets, StringRef Str) {
if (Form == dwarf::DW_FORM_string)
return InfoData.getCStr(&InfoOffset);
assert(Form == dwarf::DW_FORM_GNU_str_index && "Only string and str_index "
"forms are supported for DWP "
"string attributes");
if (Form != dwarf::DW_FORM_GNU_str_index)
return make_error<DWPError>(
"string field encoded without DW_FORM_string or DW_FORM_GNU_str_index");
auto StrIndex = InfoData.getULEB128(&InfoOffset);
DataExtractor StrOffsetsData(StrOffsets, true, 0);
uint32_t StrOffsetsOffset = 4 * StrIndex;
@ -169,11 +169,19 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
(Name != 0 || Form != 0)) {
switch (Name) {
case dwarf::DW_AT_name: {
ID.Name = getIndexedString(Form, InfoData, Offset, StrOffsets, Str);
Expected<const char *> EName =
getIndexedString(Form, InfoData, Offset, StrOffsets, Str);
if (!EName)
return EName.takeError();
ID.Name = *EName;
break;
}
case dwarf::DW_AT_GNU_dwo_name: {
ID.DWOName = getIndexedString(Form, InfoData, Offset, StrOffsets, Str);
Expected<const char *> EName =
getIndexedString(Form, InfoData, Offset, StrOffsets, Str);
if (!EName)
return EName.takeError();
ID.DWOName = *EName;
break;
}
case dwarf::DW_AT_GNU_dwo_id: