* [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section
@ 2023-03-24 23:58 Mark Wielaard
2023-03-24 23:58 ` [PATCH 2/3] debuginfo: check whether compiler needs -fdebug-macro Mark Wielaard
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mark Wielaard @ 2023-03-24 23:58 UTC (permalink / raw)
To: debugedit; +Cc: Mark Wielaard
Some compilers don't generate a .debug_types section even when compiling
with -fdebug-types-section. Skip testing the .debug_types tests in that
case.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tests/debugedit.at | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 725e68e..0601127 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -364,6 +364,7 @@ AT_CLEANUP
AT_SETUP([debugedit .debug_types objects])
AT_KEYWORDS([debugtypes] [debugedit])
DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
+AT_SKIP_IF([! $READELF -S ./foo.o ./subdir_bar/bar.o ./baz.o | grep -q '.debug_types'])
AT_DATA([expout],
[st1
@@ -401,6 +402,7 @@ AT_CLEANUP
AT_SETUP([debugedit .debug_types partial])
AT_KEYWORDS([debugtypes] [debugedit])
DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
+AT_SKIP_IF([! $READELF -S ./foobarbaz.part.o | grep -q '.debug_types'])
AT_DATA([expout],
[st1
@@ -430,6 +432,7 @@ AT_CLEANUP
AT_SETUP([debugedit .debug_types exe])
AT_KEYWORDS([debugtypes] [debugedit])
DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
+AT_SKIP_IF([! $READELF -S ./foobarbaz.exe | grep -q '.debug_types'])
AT_DATA([expout],
[st1
--
2.31.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [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
* Re: [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section
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 ` [PATCH 3/3] debugedit: Simplify and extend .debug_line tests Mark Wielaard
@ 2023-03-25 11:30 ` Dmitry V. Levin
2023-03-28 11:24 ` Mark Wielaard
2 siblings, 1 reply; 6+ messages in thread
From: Dmitry V. Levin @ 2023-03-25 11:30 UTC (permalink / raw)
To: debugedit
On Sat, Mar 25, 2023 at 12:58:05AM +0100, Mark Wielaard wrote:
> Some compilers don't generate a .debug_types section even when compiling
> with -fdebug-types-section. Skip testing the .debug_types tests in that
> case.
>
> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
> tests/debugedit.at | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tests/debugedit.at b/tests/debugedit.at
> index 725e68e..0601127 100644
> --- a/tests/debugedit.at
> +++ b/tests/debugedit.at
> @@ -364,6 +364,7 @@ AT_CLEANUP
> AT_SETUP([debugedit .debug_types objects])
> AT_KEYWORDS([debugtypes] [debugedit])
> DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
> +AT_SKIP_IF([! $READELF -S ./foo.o ./subdir_bar/bar.o ./baz.o | grep -q '.debug_types'])
Should it rather be grep -F -q?
--
ldv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section
2023-03-25 11:30 ` [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section Dmitry V. Levin
@ 2023-03-28 11:24 ` Mark Wielaard
2023-04-21 12:46 ` Mark Wielaard
0 siblings, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2023-03-28 11:24 UTC (permalink / raw)
To: Dmitry V. Levin, debugedit
Hi Dmitry,
On Sat, 2023-03-25 at 14:30 +0300, Dmitry V. Levin wrote:
> On Sat, Mar 25, 2023 at 12:58:05AM +0100, Mark Wielaard wrote:
> > Some compilers don't generate a .debug_types section even when compiling
> > with -fdebug-types-section. Skip testing the .debug_types tests in that
> > case.
> >
> > DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
> > +AT_SKIP_IF([! $READELF -S ./foo.o ./subdir_bar/bar.o ./baz.o | grep -q '.debug_types'])
>
> Should it rather be grep -F -q?
Yes, that (--fixed-strings) would indeed be better.
Fixed in 3 places.
Thanks,
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] debugedit: skip .debug_types tests if compiler doesn't generate section
2023-03-28 11:24 ` Mark Wielaard
@ 2023-04-21 12:46 ` Mark Wielaard
0 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2023-04-21 12:46 UTC (permalink / raw)
To: Dmitry V. Levin, debugedit
Hi,
On Tue, 2023-03-28 at 13:24 +0200, Mark Wielaard wrote:
> On Sat, 2023-03-25 at 14:30 +0300, Dmitry V. Levin wrote:
> > On Sat, Mar 25, 2023 at 12:58:05AM +0100, Mark Wielaard wrote:
> > > Some compilers don't generate a .debug_types section even when compiling
> > > with -fdebug-types-section. Skip testing the .debug_types tests in that
> > > case.
> > >
> > > DEBUGEDIT_SETUP([-fdebug-types-section -gdwarf-4])
> > > +AT_SKIP_IF([! $READELF -S ./foo.o ./subdir_bar/bar.o ./baz.o | grep -q '.debug_types'])
> >
> > Should it rather be grep -F -q?
>
> Yes, that (--fixed-strings) would indeed be better.
> Fixed in 3 places.
Pushed all 3 patches, with the above fix to patch 1.
Cheers,
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-21 12:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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
2023-03-28 11:24 ` Mark Wielaard
2023-04-21 12:46 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).