Blame SOURCES/0001-tests-Handle-zero-directory-entry-in-.debug_line-DWA.patch

55887d
From ae27211cbbfb63a0ad3c141cd1310d7f583ec40e Mon Sep 17 00:00:00 2001
55887d
From: Mark Wielaard <mark@klomp.org>
55887d
Date: Fri, 30 Jul 2021 18:09:46 +0200
55887d
Subject: [PATCH] tests: Handle zero directory entry in .debug_line DWARF5
55887d
 debugedit.at
55887d
55887d
We were skipping the zero directory entry, because it was always
55887d
the same as the directory entry at position one. But that isn't
55887d
true anymore with gcc 11.2.1. There the zero dir entry is unique.
55887d
Fix the debugedit.at .debug_line testcases using DWARF5 to also
55887d
include dir entry zero.
55887d
55887d
Signed-off-by: Mark Wielaard <mark@klomp.org>
55887d
---
55887d
 configure.ac       | 14 ++++++++++++++
55887d
 tests/atlocal.in   |  1 +
55887d
 tests/debugedit.at | 18 ++++++++++++------
55887d
 3 files changed, 27 insertions(+), 6 deletions(-)
55887d
55887d
diff --git a/configure.ac b/configure.ac
55887d
index e5c9230..6a53365 100644
55887d
--- a/configure.ac
55887d
+++ b/configure.ac
55887d
@@ -87,6 +87,20 @@ CFLAGS="$save_CFLAGS"
55887d
 GDWARF_5_FLAG=$ac_cv_gdwarf_5
55887d
 AC_SUBST([GDWARF_5_FLAG])
55887d
 
55887d
+AC_CACHE_CHECK([whether -gdwarf-5 produced DWARF5 .debug_line], ac_cv_dwarf_5_debugline, [dnl
55887d
+save_CFLAGS="$CFLAGS"
55887d
+CFLAGS="-gdwarf-5"
55887d
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i=0;]],[[/* empty main */]])],
55887d
+  [if readelf --debug-dump=line conftest.o 2>&1 | \
55887d
+   grep "DWARF Version:" 2>&1 | grep "5" > /dev/null 2>&1; \
55887d
+     then ac_cv_dwarf_5_debugline=yes; \
55887d
+     else ac_cv_dwarf_5_debugline=no; fi],
55887d
+  ac_cv_dwarf_5_debugline=no)
55887d
+CFLAGS="$save_CFLAGS"
55887d
+])
55887d
+DWARF_5_DEBUGLINE=$ac_cv_dwarf_5_debugline
55887d
+AC_SUBST([DWARF_5_DEBUGLINE])
55887d
+
55887d
 AC_CACHE_CHECK([whether gcc supports -gz=none], ac_cv_gz_none, [dnl
55887d
 save_CFLAGS="$CFLAGS"
55887d
 CFLAGS="-gz=none"
55887d
diff --git a/tests/atlocal.in b/tests/atlocal.in
55887d
index 8399f8d..d916301 100644
55887d
--- a/tests/atlocal.in
55887d
+++ b/tests/atlocal.in
55887d
@@ -13,3 +13,4 @@ READELF="@READELF@"
55887d
 
55887d
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
55887d
 GZ_NONE_FLAG=@GZ_NONE_FLAG@
55887d
+DWARF_5_DEBUGLINE=@DWARF_5_DEBUGLINE@
55887d
diff --git a/tests/debugedit.at b/tests/debugedit.at
55887d
index 0311d26..725e68e 100644
55887d
--- a/tests/debugedit.at
55887d
+++ b/tests/debugedit.at
55887d
@@ -488,10 +488,12 @@ AT_CLEANUP
55887d
 AT_SETUP([debugedit .debug_line objects DWARF5])
55887d
 AT_KEYWORDS([debuginfo] [debugedit])
55887d
 AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
55887d
+AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
55887d
 DEBUGEDIT_SETUP([-gdwarf-5])
55887d
 
55887d
 AT_DATA([expout],
55887d
 [foo/bar/baz
55887d
+foo/bar/baz/subdir_bar
55887d
 foo/bar/baz/subdir_headers
55887d
 ])
55887d
 
55887d
@@ -500,8 +502,8 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
55887d
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
55887d
 AT_CHECK([[
55887d
 readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
55887d
-        | grep -A5 "The Directory Table" | grep "^  [123]" \
55887d
-	| cut -f2- -d/ | grep ^foo/ | sort
55887d
+	| grep -A5 "The Directory Table" | grep "^  [0123]" \
55887d
+	| cut -f2- -d/ | grep ^foo/ | sort -u
55887d
 ]],[0],[expout])
55887d
 
55887d
 AT_CLEANUP
55887d
@@ -535,18 +537,20 @@ AT_CLEANUP
55887d
 AT_SETUP([debugedit .debug_line partial DWARF5])
55887d
 AT_KEYWORDS([debuginfo] [debugedit])
55887d
 AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
55887d
+AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
55887d
 DEBUGEDIT_SETUP([-gdwarf-5])
55887d
 
55887d
 AT_DATA([expout],
55887d
 [foo/bar/baz
55887d
+foo/bar/baz/subdir_bar
55887d
 foo/bar/baz/subdir_headers
55887d
 ])
55887d
 
55887d
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
55887d
 AT_CHECK([[
55887d
 readelf --debug-dump=line ./foobarbaz.part.o \
55887d
-        | grep -A5 "The Directory Table" | grep "^  [123]" \
55887d
-	| cut -f2- -d/ | grep ^foo/ | sort
55887d
+	| grep -A5 "The Directory Table" | grep "^  [0123]" \
55887d
+	| cut -f2- -d/ | grep ^foo/ | sort -u
55887d
 ]],[0],[expout])
55887d
 
55887d
 AT_CLEANUP
55887d
@@ -580,18 +584,20 @@ AT_CLEANUP
55887d
 AT_SETUP([debugedit .debug_line exe DWARF5])
55887d
 AT_KEYWORDS([debuginfo] [debugedit])
55887d
 AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
55887d
+AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
55887d
 DEBUGEDIT_SETUP([-gdwarf-5])
55887d
 
55887d
 AT_DATA([expout],
55887d
 [foo/bar/baz
55887d
+foo/bar/baz/subdir_bar
55887d
 foo/bar/baz/subdir_headers
55887d
 ])
55887d
 
55887d
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
55887d
 AT_CHECK([[
55887d
 readelf --debug-dump=line ./foobarbaz.exe \
55887d
-        | grep -A5 "The Directory Table" | grep "^  [123]" \
55887d
-	| cut -f2- -d/ | grep ^foo/ | sort
55887d
+	| grep -A5 "The Directory Table" | grep "^  [0123]" \
55887d
+	| cut -f2- -d/ | grep ^foo/ | sort -u
55887d
 ]],[0],[expout])
55887d
 
55887d
 AT_CLEANUP
55887d
-- 
55887d
2.27.0
55887d