Skip to content

Commit 79fffed

Browse files
authored
[llvm-dwp] Give more information when incompatible version found (#168511)
Provide more information when detecting a DWARF version mismatch in .dwo files to help locate the issue and align with other similar errors.
1 parent beac880 commit 79fffed

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/DWP/DWP.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
706706
uint32_t ContributionOffsets[8] = {};
707707
uint16_t Version = 0;
708708
uint32_t IndexVersion = 0;
709+
StringRef FirstInput;
709710
bool AnySectionOverflow = false;
710711

711712
DWPStringPool Strings(Out, StrSection);
@@ -764,8 +765,12 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
764765
if (Version == 0) {
765766
Version = Header.Version;
766767
IndexVersion = Version < 5 ? 2 : 5;
768+
FirstInput = Input;
767769
} else if (Version != Header.Version) {
768-
return make_error<DWPError>("incompatible DWARF compile unit versions.");
770+
return make_error<DWPError>(
771+
"incompatible DWARF compile unit version: " + Input + " (version " +
772+
utostr(Header.Version) + ") and " + FirstInput.str() + " (version " +
773+
utostr(Version) + ")");
769774
}
770775

771776
writeStringsAndOffsets(Out, Strings, StrOffsetSection, CurStrSection,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RUN: rm -rf %t && mkdir -p %t && cd %t
2+
RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/main_v5.dwo -dwarf-version=5 %p/../Inputs/overflow/main_v5.s -o %t/main_v5.o
3+
RUN: llvm-mc --triple=x86_64-unknown-linux --filetype=obj --split-dwarf-file=%t/debug_info_v4.dwo -dwarf-version=4 %p/../Inputs/overflow/debug_info_v4.s -o %t/debug_info_v4.o
4+
RUN: not llvm-dwp %t/main_v5.dwo %t/debug_info_v4.dwo -o main.dwp 2>&1 | FileCheck %s
5+
6+
CHECK: error: incompatible DWARF compile unit version: {{.*}}debug_info_v4.dwo (version 4) and {{.*}}main_v5.dwo (version 5)

0 commit comments

Comments
 (0)