This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] readelf: Report error when decl_file or call_file attribute is invalid.


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]