From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH 3/3] debugedit: Simplify and extend .debug_line tests
Date: Sat, 25 Mar 2023 00:58:07 +0100 [thread overview]
Message-ID: <20230324235807.2335399-3-mark@klomp.org> (raw)
In-Reply-To: <20230324235807.2335399-1-mark@klomp.org>
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
next prev parent reply other threads:[~2023-03-24 23:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230324235807.2335399-3-mark@klomp.org \
--to=mark@klomp.org \
--cc=debugedit@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).