public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Subject: Re: [PATCH] readelf: Report error when decl_file or call_file attribute is invalid.
Date: Tue, 27 Mar 2018 13:42:00 -0000	[thread overview]
Message-ID: <1522158126.15770.59.camel@klomp.org> (raw)
In-Reply-To: <1521549237-15410-1-git-send-email-mark@klomp.org>

On Tue, 2018-03-20 at 13:33 +0100, Mark Wielaard wrote:
> Report an error for why the DW_AT_decl_file or DW_AT_call_file cannot
> be resolved to a file name. This is likely invalid DWARF, a missing
> DW_AT_stmt_list attribute on the CU or a missing .debug_line section.

I pushed this to master with one tiny change, at the end of the error
checking this is added:

diff --git a/src/readelf.c b/src/readelf.c
index 72b5469..fc5aab7 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6780,6 +6780,8 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
            else
             error (0, 0, gettext ("couldn't get DWARF CU: %s"),
                    dwarf_errmsg (-1));
+           if (valuestr == NULL)
+             valuestr = "???";
          }
          break;

That way you don't just get a stderr message, but can also see in the
DIE tree output that the actual file name is missing. So with that the
output for a bogus DW_AT_decl_file would look like:

 [    1b]    typedef              abbrev: 2
             name                 (GNU_str_index) "size_t"
src/readelf: no srcfiles for CU [b]
             decl_file            (data1) ??? (5)
             decl_line            (data1) 216
             type                 (ref4) [    24]

Cheers,

Mark

  reply	other threads:[~2018-03-27 13:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-20 12:34 Mark Wielaard
2018-03-27 13:42 ` Mark Wielaard [this message]
2018-03-27 14:26   ` 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=1522158126.15770.59.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@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).