[COMMITTED] readelf: Use dwarf_form_name for printing (unknown) forms.

Mark Wielaard mark@klomp.org
Mon Jan 1 21:44:00 GMT 2018


A quick first commit of the year to make (error) output more consistent
in readelf:

Use dwarf_form_name consistently to print forms. attr_callback was
using its own string conversion, print_debug_macro_section was using
dwarf_form_string instead of dwarf_form_name.

The difference between dwarf_form_string and dwarf_form_name is that
the first returns NULL if the form is unknown and the second returns
an hexadecimal string representation in that case.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 5 +++++
 src/readelf.c | 6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 9d6ec830..49b0cc03 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-01  Mark Wielaard  <mark@klomp.org>
+
+	* readelf.c (attr_callback): Use dwarf_form_name for unknown forms.
+	(print_debug_macro_section): Print form using dwarf_form_name.
+
 2017-12-28  Mark Wielaard  <mark@klomp.org>
 
 	* readelf.c (print_debug_units): Print DIE offset in error message
diff --git a/src/readelf.c b/src/readelf.c
index ee9c7e1d..4bdaef20 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -6306,9 +6306,9 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
     default:
       if (cbargs->silent)
 	break;
-      printf ("           %*s%-20s (form: %#x) ???\n",
+      printf ("           %*s%-20s (%s) ???\n",
 	      (int) (level * 2), "", dwarf_attr_name (attr),
-	      (int) form);
+	      dwarf_form_name (form));
       break;
     }
 
@@ -7552,7 +7552,7 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 		      if (readp + 1 > readendp)
 			goto invalid_data;
 		      unsigned int form = *readp++;
-		      printf (" %s", dwarf_form_string (form));
+		      printf (" %s", dwarf_form_name (form));
 		      if (form != DW_FORM_data1
 			  && form != DW_FORM_data2
 			  && form != DW_FORM_data4
-- 
2.14.3



More information about the Elfutils-devel mailing list