From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH] Record and write files in read_dwarf5_line_entries.
Date: Mon, 5 Jul 2021 18:35:04 +0200 [thread overview]
Message-ID: <20210705163504.27225-1-mark@klomp.org> (raw)
Without giving -d /foo/build/bar debugedit wouldn't actually output
any file from the line number table for DWARF5.
* tools/debugedit.c (read_dwarf5_line_entries): Don't make
collecting_dirs and writing_files depend on dest_dir. Always
read idx for strp or line_strp on phase 0. comp_dir_len is
zero when comp_dir is NULL.
* tests/debugedit.at: Add source list mode tests for DWARF4
and DWARF5.
https://bugzilla.redhat.com/show_bug.cgi?id=1966987
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tests/debugedit.at | 24 ++++++++++++++++++++++++
tools/debugedit.c | 22 +++++++++++++---------
2 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 01b1f2f..608b1d0 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -666,3 +666,27 @@ readelf --debug-dump=macro ./foobarbaz.exe \
]],[0],[expout])
AT_CLEANUP
+
+# ===
+# source list mode dwarf-4
+# ===
+AT_SETUP([debugedit --list-file DWARF4])
+AT_KEYWORDS([debuginfo] [debugedit])
+echo "int main () { }" > main.c
+$CC $CFLAGS -gdwarf-4 -o main main.c
+AT_CHECK([[debugedit -l sources.list main]])
+AT_CHECK([[grep -q main.c sources.list]])
+cat sources.list
+AT_CLEANUP
+
+# ===
+# source list mode dwarf-5
+# ===
+AT_SETUP([debugedit --list-file DWARF5])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
+echo "int main () { }" > main.c
+$CC $CFLAGS -gdwarf-5 -o main main.c
+AT_CHECK([[debugedit -l sources.list main]])
+AT_CHECK([[grep -q main.c sources.list]])
+AT_CLEANUP
diff --git a/tools/debugedit.c b/tools/debugedit.c
index c4e6c4c..668777a 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1831,8 +1831,8 @@ read_dwarf5_line_entries (DSO *dso, unsigned char **ptrp,
/* file_names_count */
unsigned entry_count = read_uleb128 (*ptrp);
- bool collecting_dirs = dest_dir && phase == 0 && *dirs == NULL;
- bool writing_files = dest_dir && phase == 0 && *dirs != NULL;
+ bool collecting_dirs = phase == 0 && *dirs == NULL;
+ bool writing_files = phase == 0 && *dirs != NULL;
if (collecting_dirs)
{
*ndir = entry_count;
@@ -1862,15 +1862,19 @@ read_dwarf5_line_entries (DSO *dso, unsigned char **ptrp,
{
case DW_FORM_strp:
case DW_FORM_line_strp:
- if (dest_dir && phase == 0)
+ if (phase == 0)
{
size_t idx = do_read_32_relocated (*ptrp);
- if (record_file_string_entry_idx (line_strp, dso, idx))
+ if (dest_dir)
{
- if (line_strp)
- need_line_strp_update = true;
- else
- need_strp_update = true;
+ if (record_file_string_entry_idx (line_strp, dso,
+ idx))
+ {
+ if (line_strp)
+ need_line_strp_update = true;
+ else
+ need_strp_update = true;
+ }
}
handled_strp = true;
if (collecting_dirs || writing_files)
@@ -1956,7 +1960,7 @@ read_dwarf5_line_entries (DSO *dso, unsigned char **ptrp,
if (writing_files)
{
char *comp_dir = (*dirs)[0];
- size_t comp_dir_len = strlen(comp_dir);
+ size_t comp_dir_len = !comp_dir ? 0 : strlen(comp_dir);
size_t file_len = strlen (file);
size_t dir_len = strlen (dir);
--
2.18.4
next reply other threads:[~2021-07-05 16:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 16:35 Mark Wielaard [this message]
2021-07-12 20:31 ` 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=20210705163504.27225-1-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).