PATCH: printing scalars with objdump --debugging

Greg McGary gkm@work.mcgary.org
Mon Jan 7 16:22:00 GMT 2008


"objdump --debugging" represents scalars with the type VMA.  If VMA fits
within a host's long, scalars are printf'ed with "%lx", "%lu" or "%ld"
according to type.   If VMA doesn't fit in the host's long, scalars are
all printed as full-width hex.  This causes trouble for scripts that
digest the output, since output format depends on the cross-host where
objdump runs, e.g. ix86 vs. x86_64.  This patch takes advantage of "%ll"
formats, if available.

OK to commmit?
(I have CVS permissions and copyright assignments on file with FSF)

Greg


2008-01-04  Greg McGary  <greg@mcgary.org>

	* prdbg.c (print_vma): Print as long long, if host supports it.

 
Index: binutils/prdbg.c
===================================================================
RCS file: /cvs/src/src/binutils/prdbg.c,v
retrieving revision 1.19
diff -u -p -r1.19 prdbg.c
--- binutils/prdbg.c	5 Jul 2007 16:54:45 -0000	1.19
+++ binutils/prdbg.c	4 Jan 2008 18:14:03 -0000
@@ -1,5 +1,5 @@
 /* prdbg.c -- Print out generic debugging information.
-   Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2006, 2007
+   Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
    Tags style generation written by Salvador E. Tropea <set@computer.org>.
@@ -499,6 +499,17 @@ print_vma (bfd_vma vma, char *buf, bfd_b
       else
 	sprintf (buf, "%ld", (long) vma);
     }
+#if BFD_HOST_64BIT_LONG_LONG
+  else if (sizeof (vma) <= sizeof (unsigned long long))
+    {
+      if (hexp)
+	sprintf (buf, "0x%llx", (unsigned long long) vma);
+      else if (unsignedp)
+	sprintf (buf, "%llu", (unsigned long long) vma);
+      else
+	sprintf (buf, "%lld", (long long) vma);
+    }
+#endif
   else
     {
       buf[0] = '0';



More information about the Binutils mailing list