* [PATCH 2/3] debuginfo: check whether compiler needs -fdebug-macro
2023-03-24 23:58 [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section Mark Wielaard
@ 2023-03-24 23:58 ` Mark Wielaard
2023-03-24 23:58 ` [PATCH 3/3] debugedit: Simplify and extend .debug_line tests Mark Wielaard
2023-03-25 11:30 ` [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section Dmitry V. Levin
2 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2023-03-24 23:58 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
Some compilers only generate a .debug_macro section when given the
-fdebug_macro flag.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
configure.ac | 13 +++++++++++++
tests/atlocal.in | 1 +
tests/debugedit.at | 6 +++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index c887aed..79803dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,6 +135,19 @@ else
fi
AC_SUBST([GZ_NONE_FLAG])
+AC_CACHE_CHECK([whether compiler needs -fdebug-macro], ac_cv_debug_macro, [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="-fdebug-macro"
+AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_debug_macro=yes, ac_cv_debug_macro=no)
+CFLAGS="$save_CFLAGS"
+])
+if test "$ac_cv_debug_macro" = "yes"; then
+ DEBUG_MACRO_FLAG="-fdebug-macro"
+else
+ DEBUG_MACRO_FLAG=""
+fi
+AC_SUBST([DEBUG_MACRO_FLAG])
+
# And generate the output files.
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/tests/atlocal.in b/tests/atlocal.in
index d916301..01b998c 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -14,3 +14,4 @@ READELF="@READELF@"
GDWARF_5_FLAG=@GDWARF_5_FLAG@
GZ_NONE_FLAG=@GZ_NONE_FLAG@
DWARF_5_DEBUGLINE=@DWARF_5_DEBUGLINE@
+DEBUG_MACRO_FLAG=@DEBUG_MACRO_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 0601127..19ab7dc 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -611,7 +611,7 @@ AT_CLEANUP
# ===
AT_SETUP([debugedit .debug_macro objects])
AT_KEYWORDS([debuginfo] [debugedit])
-DEBUGEDIT_SETUP
+DEBUGEDIT_SETUP([$DEBUG_MACRO_FLAG])
# We expect 3 for each compile unit.
AT_DATA([expout],
@@ -636,7 +636,7 @@ AT_CLEANUP
# ===
AT_SETUP([debugedit .debug_macro partial])
AT_KEYWORDS([debuginfo] [debugedit])
-DEBUGEDIT_SETUP
+DEBUGEDIT_SETUP([$DEBUG_MACRO_FLAG])
# We expect 3 for each compile unit.
AT_DATA([expout],
@@ -659,7 +659,7 @@ AT_CLEANUP
# ===
AT_SETUP([debugedit .debug_macro exe])
AT_KEYWORDS([debuginfo] [debugedit])
-DEBUGEDIT_SETUP
+DEBUGEDIT_SETUP([$DEBUG_MACRO_FLAG])
# We expect 3 for each compile unit.
AT_DATA([expout],
--
2.31.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] debugedit: Simplify and extend .debug_line tests
2023-03-24 23:58 [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section Mark Wielaard
2023-03-24 23:58 ` [PATCH 2/3] debuginfo: check whether compiler needs -fdebug-macro Mark Wielaard
@ 2023-03-24 23:58 ` Mark Wielaard
2023-03-25 11:30 ` [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section Dmitry V. Levin
2 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2023-03-24 23:58 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
The debugedit .debug_line tests were only checking the directory
table, skipping the file name table assuming those would not be
include a directory element. But some compilers output the file
names as absolute paths (so ignoring the directory table entries,
which is slightly inefficient). Check both tables now using sed
to replace the directory strings.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tests/debugedit.at | 74 ++++++++++++++++++++++------------------------
1 file changed, 35 insertions(+), 39 deletions(-)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 19ab7dc..b3387b8 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -468,18 +468,17 @@ AT_SETUP([debugedit .debug_line objects DWARF4])
AT_KEYWORDS([debuginfo] [debugedit])
DEBUGEDIT_SETUP([-gdwarf-4])
-AT_DATA([expout],
-[/foo/bar/baz
-/foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[1234]]" \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
AT_CHECK([[
$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
- | grep -A3 "The Directory Table" | grep "^ [123]" \
- | grep /foo/ | cut -c5- | sort
+ | grep -E -A5 "The (Directory|File Name) Table" | grep "^ [1234]"
]],[0],[expout])
AT_CLEANUP
@@ -494,19 +493,18 @@ AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
DEBUGEDIT_SETUP([-gdwarf-5])
-AT_DATA([expout],
-[foo/bar/baz
-foo/bar/baz/subdir_bar
-foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[01234]]" | cut -f3 -d: \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
AT_CHECK([[
$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
- | grep -A5 "The Directory Table" | grep "^ [0123]" \
- | cut -f2- -d/ | grep ^foo/ | sort -u
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [01234]" | cut -f3 -d:
]],[0],[expout])
AT_CLEANUP
@@ -519,16 +517,16 @@ AT_SETUP([debugedit .debug_line partial DWARF4])
AT_KEYWORDS([debuginfo] [debugedit])
DEBUGEDIT_SETUP([-gdwarf-4])
-AT_DATA([expout],
-[/foo/bar/baz
-/foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line ./foobarbaz.part.o \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[1234]]" \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
AT_CHECK([[
$READELF --debug-dump=line ./foobarbaz.part.o \
- | grep -A3 "The Directory Table" | grep "^ [123]" \
- | grep /foo/ | cut -c5- | sort
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [1234]"
]],[0],[expout])
AT_CLEANUP
@@ -543,17 +541,16 @@ AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
DEBUGEDIT_SETUP([-gdwarf-5])
-AT_DATA([expout],
-[foo/bar/baz
-foo/bar/baz/subdir_bar
-foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line ./foobarbaz.part.o \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[01234]]" | cut -f3 -d: \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
AT_CHECK([[
$READELF --debug-dump=line ./foobarbaz.part.o \
- | grep -A5 "The Directory Table" | grep "^ [0123]" \
- | cut -f2- -d/ | grep ^foo/ | sort -u
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [01234]" | cut -f3 -d:
]],[0],[expout])
AT_CLEANUP
@@ -566,16 +563,16 @@ AT_SETUP([debugedit .debug_line exe DWARF4])
AT_KEYWORDS([debuginfo] [debugedit])
DEBUGEDIT_SETUP([-gdwarf-4])
-AT_DATA([expout],
-[/foo/bar/baz
-/foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line ./foobarbaz.exe \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[1234]]" \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
AT_CHECK([[
$READELF --debug-dump=line ./foobarbaz.exe \
- | grep -A3 "The Directory Table" | grep "^ [123]" \
- | grep /foo/ | cut -c5- | sort
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [1234]"
]],[0],[expout])
AT_CLEANUP
@@ -590,17 +587,16 @@ AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
AT_SKIP_IF([test "$DWARF_5_DEBUGLINE" = "no"])
DEBUGEDIT_SETUP([-gdwarf-5])
-AT_DATA([expout],
-[foo/bar/baz
-foo/bar/baz/subdir_bar
-foo/bar/baz/subdir_headers
-])
+$READELF --debug-dump=line ./foobarbaz.exe \
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [[01234]]" | cut -f3 -d: \
+ | sed -e "s@$(pwd)@/foo/bar/baz@" | tee expout
AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
AT_CHECK([[
$READELF --debug-dump=line ./foobarbaz.exe \
- | grep -A5 "The Directory Table" | grep "^ [0123]" \
- | cut -f2- -d/ | grep ^foo/ | sort -u
+ | grep -E -A5 "The (Directory|File Name) Table" \
+ | grep "^ [01234]" | cut -f3 -d:
]],[0],[expout])
AT_CLEANUP
--
2.31.1
^ permalink raw reply [flat|nested] 6+ messages in thread