This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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] dwarf2read.c: Don't assume uint32_t is unsigned int on all hosts.


On 05/22/2013 12:35 AM, Doug Evans wrote:
> On Tue, May 21, 2013 at 1:34 PM, Pedro Alves <palves@redhat.com> wrote:
>> Use pulongest rather than PRIu32, so that the translatable format
>> string does not depend on host.

...

> Lovely.
> Although having to remember to use pulongest to print uint32_t sounds
> like a never ending series of headaches.

Hmm.  Grepping for PRIu in src/intl/ finds lots of hits.  Looks like
gettext is doing some magic to deal with these.  There's still the
issue with the fact that we use gnulib's inttypes.h replacement for
systems that don't have it, and it's possible gettext's replacements
don't match gnulib's...  But I'm willing to ignore that.

WDYT?

------
Subject: [PATCH] dwarf2read.c: Don't assume uint32_t is unsigned int on all hosts.

Building gdb on GNU/Linux, for --host=i586-pc-msdosdjgpp, I get:

 ../../src/gdb/dwarf2read.c: In function 'create_dwp_hash_table':
 ../../src/gdb/dwarf2read.c:8626:7: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Werror=format]
 ../../src/gdb/dwarf2read.c:8632:7: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Werror=format]
 ../../src/gdb/dwarf2read.c: In function 'create_dwo_in_dwp':
 ../../src/gdb/dwarf2read.c:8754:6: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' [-Werror=format]
 ../../src/gdb/dwarf2read.c: In function 'open_and_init_dwp_file':
 ../../src/gdb/dwarf2read.c:9248:6: error: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format]
 ../../src/gdb/dwarf2read.c:9248:6: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Werror=format]

And:

 $ grep uint32_t /usr/i586-pc-msdosdjgpp/sys-include/*
 /usr/i586-pc-msdosdjgpp/sys-include/stdint.h:typedef unsigned long uint32_t;

Tested on F17.  Also confirmed GDB still builds OK with --host=i686-w64-mingw32.

gdb/
2013-05-22  Pedro Alves  <palves@redhat.com>

	* dwarf2read.c (create_dwp_hash_table, create_dwo_in_dwp)
	(open_and_init_dwp_file): Use PRIu32 instead of %u for printing
	uint32_t variables.
---
 gdb/dwarf2read.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b819d3c..72f0e8b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8960,13 +8960,13 @@ create_dwp_hash_table (struct dwp_file *dwp_file, int is_debug_types)

   if (version != 1)
     {
-      error (_("Dwarf Error: unsupported DWP file version (%u)"
+      error (_("Dwarf Error: unsupported DWP file version (%" PRIu32 ")"
 	       " [in module %s]"),
 	     version, dwp_file->name);
     }
   if (nr_slots != (nr_slots & -nr_slots))
     {
-      error (_("Dwarf Error: number of slots in DWP hash table (%u)"
+      error (_("Dwarf Error: number of slots in DWP hash table (%" PRIu32 ")"
 	       " is not power of 2 [in module %s]"),
 	     nr_slots, dwp_file->name);
     }
@@ -9087,7 +9087,7 @@ create_dwo_in_dwp (struct dwp_file *dwp_file,

   if (dwarf2_read_debug)
     {
-      fprintf_unfiltered (gdb_stdlog, "Reading %s %u/%s in DWP file: %s\n",
+      fprintf_unfiltered (gdb_stdlog, "Reading %s %" PRIu32 "/%s in DWP file: %s\n",
 			  kind,
 			  section_index, hex_string (signature),
 			  dwp_file->name);
@@ -9582,7 +9582,7 @@ open_and_init_dwp_file (void)
     {
       fprintf_unfiltered (gdb_stdlog, "DWP file found: %s\n", dwp_file->name);
       fprintf_unfiltered (gdb_stdlog,
-			  "    %u CUs, %u TUs\n",
+			  "    %" PRIu32 " CUs, %" PRIu32 " TUs\n",
 			  dwp_file->cus ? dwp_file->cus->nr_units : 0,
 			  dwp_file->tus ? dwp_file->tus->nr_units : 0);
     }
-- 
1.7.11.7


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