summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2017-10-03 16:55:25 +0200
committerMark Wielaard <[email protected]>2017-11-16 15:27:47 +0100
commit4d36d125fac8999506b8b2137d6b04c0354954ac (patch)
tree52a2c0ffe48645211de46465973e9fe1a06ef21e
parent1af6c2b9e49f59ea2f01035738525e798bb4f645 (diff)
readelf: Print DIE offset in attribute reading error messages.
When processing large files it is useful to know the DIE offset if printing of attributes fails (especially when redirecting the output). With this change the error message looks like: eu-readelf: DIE [2aeb8ef1] cannot get attribute value: invalid DWARF Signed-off-by: Mark Wielaard <[email protected]>
-rw-r--r--src/ChangeLog4
-rw-r--r--src/readelf.c16
2 files changed, 14 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 3b886a7b..d112cd2e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-03 Mark Wielaard <[email protected]>
+
+ * readelf.c (attr_callback): Print DIE offset in error messages.
+
2017-11-03 Mark Wielaard <[email protected]>
* readelf.c (print_ops): Handle DW_OP_GNU_variable_value. Print
diff --git a/src/readelf.c b/src/readelf.c
index 833884b5..e364583c 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -5935,13 +5935,15 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
{
struct attrcb_args *cbargs = (struct attrcb_args *) arg;
const int level = cbargs->level;
+ Dwarf_Die *die = cbargs->die;
unsigned int attr = dwarf_whatattr (attrp);
if (unlikely (attr == 0))
{
if (!cbargs->silent)
- error (0, 0, gettext ("cannot get attribute code: %s"),
- dwarf_errmsg (-1));
+ error (0, 0, gettext ("DIE [%" PRIx64 "] "
+ "cannot get attribute code: %s"),
+ dwarf_dieoffset (die), dwarf_errmsg (-1));
return DWARF_CB_ABORT;
}
@@ -5949,8 +5951,9 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
if (unlikely (form == 0))
{
if (!cbargs->silent)
- error (0, 0, gettext ("cannot get attribute form: %s"),
- dwarf_errmsg (-1));
+ error (0, 0, gettext ("DIE [%" PRIx64 "] "
+ "cannot get attribute form: %s"),
+ dwarf_dieoffset (die), dwarf_errmsg (-1));
return DWARF_CB_ABORT;
}
@@ -5964,8 +5967,9 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
{
attrval_out:
if (!cbargs->silent)
- error (0, 0, gettext ("cannot get attribute value: %s"),
- dwarf_errmsg (-1));
+ error (0, 0, gettext ("DIE [%" PRIx64 "] "
+ "cannot get attribute value: %s"),
+ dwarf_dieoffset (die), dwarf_errmsg (-1));
return DWARF_CB_ABORT;
}
char *a = format_dwarf_addr (cbargs->dwflmod, cbargs->addrsize,