[llvm] [llvm-dwp] Give more information when incompatible version found (PR #168511)
Jinjie Huang via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 03:56:27 PST 2025
https://github.com/Jinjie-Huang updated https://github.com/llvm/llvm-project/pull/168511
>From 0fd50382b0bf62ee8c78d21555885b6ada576075 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 18 Nov 2025 18:40:12 +0800
Subject: [PATCH 1/2] add more detail when incompatible version found
---
llvm/lib/DWP/DWP.cpp | 4 +++-
.../llvm-dwp/X86/incompatible_dwarf_version.test | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
diff --git a/llvm/lib/DWP/DWP.cpp b/llvm/lib/DWP/DWP.cpp
index b565edbfe96db..a6624339f704f 100644
--- a/llvm/lib/DWP/DWP.cpp
+++ b/llvm/lib/DWP/DWP.cpp
@@ -709,7 +709,9 @@ Error write(MCStreamer &Out, ArrayRef<std::string> Inputs,
Version = Header.Version;
IndexVersion = Version < 5 ? 2 : 5;
} else if (Version != Header.Version) {
- return make_error<DWPError>("incompatible DWARF compile unit versions.");
+ return make_error<DWPError>(
+ Input + ": incompatible DWARF compile unit version, found " +
+ utostr(Header.Version) + " and expecting " + utostr(Version));
}
writeStringsAndOffsets(Out, Strings, StrOffsetSection, CurStrSection,
diff --git a/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
new file mode 100644
index 0000000000000..886fe834a3263
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
@@ -0,0 +1,15 @@
+RUN: rm -rf %t && split-file %s %t && cd %t
+RUN: clang++ -g -gsplit-dwarf -gdwarf-5 -c %t/a.cpp -o %t/a.o
+RUN: clang++ -g -gsplit-dwarf -gdwarf-4 -c %t/b.cpp -o %t/b.o
+RUN: clang++ %t/a.o %t/b.o -o %t/main.exe
+RUN: not llvm-dwp -e %t/main.exe -o %t/main.exe.dwp 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}b.dwo: incompatible DWARF compile unit version, found 4 and expecting 5
+
+;--- a.cpp
+int main() {
+ return 0;
+}
+
+;--- b.cpp
+void b() {}
>From 0bd6baa004a0572be6c5e426119263024fcbd48d Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Tue, 18 Nov 2025 19:56:09 +0800
Subject: [PATCH 2/2] use the existing input as the test case
---
.../X86/incompatible_dwarf_version.test | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
index 886fe834a3263..2258bf1ecbc1f 100644
--- a/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
+++ b/llvm/test/tools/llvm-dwp/X86/incompatible_dwarf_version.test
@@ -1,15 +1,6 @@
-RUN: rm -rf %t && split-file %s %t && cd %t
-RUN: clang++ -g -gsplit-dwarf -gdwarf-5 -c %t/a.cpp -o %t/a.o
-RUN: clang++ -g -gsplit-dwarf -gdwarf-4 -c %t/b.cpp -o %t/b.o
-RUN: clang++ %t/a.o %t/b.o -o %t/main.exe
-RUN: not llvm-dwp -e %t/main.exe -o %t/main.exe.dwp 2>&1 | FileCheck %s
+RUN: rm -rf %t && mkdir -p %t && cd %t
+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
+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
+RUN: not llvm-dwp %t/main_v5.dwo %t/debug_info_v4.dwo -o main.dwp 2>&1 | FileCheck %s
-# CHECK: error: {{.*}}b.dwo: incompatible DWARF compile unit version, found 4 and expecting 5
-
-;--- a.cpp
-int main() {
- return 0;
-}
-
-;--- b.cpp
-void b() {}
+# CHECK: error: {{.*}}debug_info_v4.dwo: incompatible DWARF compile unit version, found 4 and expecting 5
More information about the llvm-commits
mailing list