public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] readelf: Use dwarf_form_name for printing (unknown) forms.
@ 2018-01-01 21:44 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2018-01-01 21:44 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-01 21:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-01 21:44 [COMMITTED] readelf: Use dwarf_form_name for printing (unknown) forms Mark Wielaard

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).