diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-02-12 15:01:07 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-02-12 15:01:07 +0000 |
commit | 4b78d4f3470dcbe4978457e4b1347bc0be150ca7 (patch) | |
tree | d8c6609bfe00d817503cc8c450a74e884a296fef | |
parent | 00ccd13c73a34cb5da8b2ba7a5a66123ab22b445 (diff) | |
download | bcm5719-llvm-4b78d4f3470dcbe4978457e4b1347bc0be150ca7.tar.gz bcm5719-llvm-4b78d4f3470dcbe4978457e4b1347bc0be150ca7.zip |
[llvm-dwp] Abort when dwo_id is unset
Summary:
An empty dwo_id indicates a degenerate .dwo file that should not have been generated in the first place. Instead of discovering this error later when merging with another degenerate .dwo file, print an error immediately when noticing an unset dwo_id, including the filename of the offending file.
Test case created by compiling a trivial file w/ `-fno-split-dwarf-inlining -gmlt -gsplit-dwarf -c` prior to r353771
Reviewers: dblaikie
Reviewed By: dblaikie
Subscribers: jdoerfert, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58085
llvm-svn: 353846
-rw-r--r-- | llvm/test/tools/llvm-dwp/Inputs/missing_dwo_id.dwo | bin | 0 -> 464 bytes | |||
-rw-r--r-- | llvm/test/tools/llvm-dwp/X86/invalid_string_form.test | 2 | ||||
-rw-r--r-- | llvm/test/tools/llvm-dwp/X86/missing_dwo_id.test | 3 | ||||
-rw-r--r-- | llvm/test/tools/llvm-dwp/X86/non_cu_top_level.test | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 11 |
5 files changed, 13 insertions, 5 deletions
diff --git a/llvm/test/tools/llvm-dwp/Inputs/missing_dwo_id.dwo b/llvm/test/tools/llvm-dwp/Inputs/missing_dwo_id.dwo Binary files differnew file mode 100644 index 00000000000..f92b4583c50 --- /dev/null +++ b/llvm/test/tools/llvm-dwp/Inputs/missing_dwo_id.dwo diff --git a/llvm/test/tools/llvm-dwp/X86/invalid_string_form.test b/llvm/test/tools/llvm-dwp/X86/invalid_string_form.test index e78a145dcb5..2d3cf6fe28c 100644 --- a/llvm/test/tools/llvm-dwp/X86/invalid_string_form.test +++ b/llvm/test/tools/llvm-dwp/X86/invalid_string_form.test @@ -1,3 +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 +CHECK: error: {{.*}}invalid_string_form.dwo': string field encoded without DW_FORM_string or DW_FORM_GNU_str_index diff --git a/llvm/test/tools/llvm-dwp/X86/missing_dwo_id.test b/llvm/test/tools/llvm-dwp/X86/missing_dwo_id.test new file mode 100644 index 00000000000..a07bcb8fb9b --- /dev/null +++ b/llvm/test/tools/llvm-dwp/X86/missing_dwo_id.test @@ -0,0 +1,3 @@ +RUN: not llvm-dwp %p/../Inputs/missing_dwo_id.dwo -o %t 2>&1 | FileCheck %s + +CHECK: error: {{.*}}missing_dwo_id.dwo': compile unit missing dwo_id diff --git a/llvm/test/tools/llvm-dwp/X86/non_cu_top_level.test b/llvm/test/tools/llvm-dwp/X86/non_cu_top_level.test index 60b8742cdc2..92f53a703a0 100644 --- a/llvm/test/tools/llvm-dwp/X86/non_cu_top_level.test +++ b/llvm/test/tools/llvm-dwp/X86/non_cu_top_level.test @@ -1,3 +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 +CHECK: error: {{.*}}non_cu_top_level.dwo': top level DIE is not a compile unit diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index cb4df9fd49f..87831a8f81f 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -13,6 +13,7 @@ #include "DWPError.h" #include "DWPStringPool.h" #include "llvm/ADT/MapVector.h" +#include "llvm/ADT/Optional.h" #include "llvm/ADT/STLExtras.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" @@ -159,6 +160,7 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev, uint32_t Name; dwarf::Form Form; CompileUnitIdentifiers ID; + Optional<uint64_t> Signature = None; while ((Name = AbbrevData.getULEB128(&AbbrevOffset)) | (Form = static_cast<dwarf::Form>(AbbrevData.getULEB128(&AbbrevOffset))) && (Name != 0 || Form != 0)) { @@ -180,13 +182,16 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev, break; } case dwarf::DW_AT_GNU_dwo_id: - ID.Signature = InfoData.getU64(&Offset); + Signature = InfoData.getU64(&Offset); break; default: DWARFFormValue::skipValue(Form, InfoData, &Offset, dwarf::FormParams({Version, AddrSize, Format})); } } + if (!Signature) + return make_error<DWPError>("compile unit missing dwo_id"); + ID.Signature = *Signature; return ID; } @@ -560,7 +565,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) { Expected<CompileUnitIdentifiers> EID = getCUIdentifiers( AbbrevSection, InfoSection, CurStrOffsetSection, CurStrSection); if (!EID) - return EID.takeError(); + return createFileError(Input, EID.takeError()); const auto &ID = *EID; auto P = IndexEntries.insert(std::make_pair(ID.Signature, CurEntry)); if (!P.second) @@ -588,7 +593,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) { getSubsection(CurStrOffsetSection, E, DW_SECT_STR_OFFSETS), CurStrSection); if (!EID) - return EID.takeError(); + return createFileError(Input, EID.takeError()); const auto &ID = *EID; if (!P.second) return buildDuplicateError(*P.first, ID, Input); |