public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
@ 2014-01-15 16:36 Pedro Alves
  2014-01-15 17:13 ` Eli Zaretskii
  2014-01-16 12:56 ` Pedro Alves
  0 siblings, 2 replies; 7+ messages in thread
From: Pedro Alves @ 2014-01-15 16:36 UTC (permalink / raw)
  To: GDB Patches; +Cc: Eli Zaretskii

I pushed the patch below, approved by Eli offlist.

FYI, djgpp still doesn't build OOTB:

 ../../src/binutils/readelf.c: In function 'print_symbol':
 ../../src/binutils/readelf.c:474:4: error: implicit declaration of function 'mbrtowc' [-Werror=implicit-function-declaration]
 cc1: all warnings being treated as errors
 ...
 ../../src/gdb/dwarf2read.c: In function 'open_and_init_dwp_file':
 ../../src/gdb/dwarf2read.c:10550:7: error: format '%d' expects argument of type 'int', but argument 2 has type 'uint32_t' [-Werror=format]
 ../../src/gdb/dwarf2read.c:10550:7: error: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t' [-Werror=format]

I'm not planing on addressing those myself at the moment though.

---
Fix go32-nat.c build fallout from to_detach constification.

The recent constification of to_detach missed updating the forward
declaration of go32_detach, breaking the build:

 ../../src/gdb/go32-nat.c:387:1: error: conflicting types for 'go32_detach'
 ../../src/gdb/go32-nat.c:240:13: note: previous declaration of 'go32_detach' was here

go32_detach is actually defined before it's ever used, making the
forward declaration is unnecessary.  So we can just remove it instead
of updating it.  While at it, remove all others in the same situation.
Tested by building a djgpp gdb.

gdb/
2014-01-15  Pedro Alves  <palves@redhat.com>

	* go32-nat.c (go32_open, go32_close, go32_attach, go32_detach)
	(go32_resume, go32_fetch_registers, store_register)
	(go32_store_registers, go32_prepare_to_store)
	(go32_xfer_memory, go32_files_info, go32_kill_inferior)
	(go32_create_inferior, go32_can_run, go32_terminal_init)
	(go32_terminal_inferior, go32_terminal_ours): Delete forward
	declarations.
---
 gdb/ChangeLog  | 10 ++++++++++
 gdb/go32-nat.c | 26 +-------------------------
 2 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e3b3eaa..6c51b84 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2014-01-15  Pedro Alves  <palves@redhat.com>
+
+	* go32-nat.c (go32_open, go32_close, go32_attach, go32_detach)
+	(go32_resume, go32_fetch_registers, store_register)
+	(go32_store_registers, go32_prepare_to_store)
+	(go32_xfer_memory, go32_files_info, go32_kill_inferior)
+	(go32_create_inferior, go32_can_run, go32_terminal_init)
+	(go32_terminal_inferior, go32_terminal_ours): Delete forward
+	declarations.
+
 2014-01-15  Tom Tromey  <tromey@redhat.com>
 
 	* target.h (async_callback_ftype): New typedef.
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 8c8e1c7..22b2d21 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -234,34 +234,10 @@ static int dr_ref_count[4];
 #define SOME_PID 42
 
 static int prog_has_started = 0;
-static void go32_open (char *name, int from_tty);
-static void go32_close (void);
-static void go32_attach (struct target_ops *ops, char *args, int from_tty);
-static void go32_detach (struct target_ops *ops, char *args, int from_tty);
-static void go32_resume (struct target_ops *ops,
-			 ptid_t ptid, int step,
-			 enum gdb_signal siggnal);
-static void go32_fetch_registers (struct target_ops *ops,
-				  struct regcache *, int regno);
-static void store_register (const struct regcache *, int regno);
-static void go32_store_registers (struct target_ops *ops,
-				  struct regcache *, int regno);
-static void go32_prepare_to_store (struct regcache *);
-static int go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
-			     int write,
-			     struct mem_attrib *attrib,
-			     struct target_ops *target);
-static void go32_files_info (struct target_ops *target);
-static void go32_kill_inferior (struct target_ops *ops);
-static void go32_create_inferior (struct target_ops *ops, char *exec_file,
-				  char *args, char **env, int from_tty);
+
 static void go32_mourn_inferior (struct target_ops *ops);
-static int go32_can_run (void);
 
 static struct target_ops go32_ops;
-static void go32_terminal_init (void);
-static void go32_terminal_inferior (void);
-static void go32_terminal_ours (void);
 
 #define r_ofs(x) (offsetof(TSS,x))
 
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-15 16:36 [PUSHED] Fix go32-nat.c build fallout from to_detach constification Pedro Alves
@ 2014-01-15 17:13 ` Eli Zaretskii
  2014-01-15 17:45   ` Pedro Alves
  2014-01-16 12:56 ` Pedro Alves
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2014-01-15 17:13 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> Date: Wed, 15 Jan 2014 16:36:44 +0000
> From: Pedro Alves <palves@redhat.com>
> CC: Eli Zaretskii <eliz@gnu.org>
> 
> I pushed the patch below, approved by Eli offlist.

Thanks.

> FYI, djgpp still doesn't build OOTB:
> 
>  ../../src/binutils/readelf.c: In function 'print_symbol':
>  ../../src/binutils/readelf.c:474:4: error: implicit declaration of function 'mbrtowc' [-Werror=implicit-function-declaration]

This is here:

  #ifdef HAVE_MBSTATE_T
	    /* Try to find out how many bytes made up the character that was
	       just printed.  Advance the symbol pointer past the bytes that
	       were displayed.  */
	    n = mbrtowc (& w, symbol - 1, MB_CUR_MAX, & state);  <<<<<<<<<
  #else
	    n = 1;
  #endif

The code (incorrectly) assumes that if the mbstate_t type is
supported, so is mbrtowc.  DJGPP has the former, but not the latter.
I guess the solution is either to modify the HAVE_MBSTATE_T test or
add a HAVE_MBRTOWC test.

>  cc1: all warnings being treated as errors
>  ...
>  ../../src/gdb/dwarf2read.c: In function 'open_and_init_dwp_file':
>  ../../src/gdb/dwarf2read.c:10550:7: error: format '%d' expects argument of type 'int', but argument 2 has type 'uint32_t' [-Werror=format]
>  ../../src/gdb/dwarf2read.c:10550:7: error: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t' [-Werror=format]

How does this compile on other platforms?  I see this in dwarf2read.c:

  struct dwp_hash_table
  {
    uint32_t version, nr_columns;
    [...]

  struct dwp_file
  {
    /* Name of the file.  */
    const char *name;
    [...]
    /* Table of CUs in the file.  */
    const struct dwp_hash_table *cus;

    /* Table of TUs in the file.  */
    const struct dwp_hash_table *tus;

And the line which is flagged by the compiler is this:

  /* The DWP file version is stored in the hash table.  Oh well.  */
  if (dwp_file->cus->version != dwp_file->tus->version)
    {
      /* Technically speaking, we should try to limp along, but this is
         pretty bizarre.  */
      error (_("Dwarf Error: DWP file CU version %d doesn't match" <<<<<<
               " TU version %d [in DWP file %s]"), <<<<<<<<<<<<<<<<<<<<<<
             dwp_file->cus->version, dwp_file->tus->version, dwp_name);

So it really tries to format uint32_t values with %d.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-15 17:13 ` Eli Zaretskii
@ 2014-01-15 17:45   ` Pedro Alves
  2014-01-15 21:25     ` Doug Evans
  0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2014-01-15 17:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On 01/15/2014 05:13 PM, Eli Zaretskii wrote:

>   /* The DWP file version is stored in the hash table.  Oh well.  */
>   if (dwp_file->cus->version != dwp_file->tus->version)
>     {
>       /* Technically speaking, we should try to limp along, but this is
>          pretty bizarre.  */
>       error (_("Dwarf Error: DWP file CU version %d doesn't match" <<<<<<
>                " TU version %d [in DWP file %s]"), <<<<<<<<<<<<<<<<<<<<<<
>              dwp_file->cus->version, dwp_file->tus->version, dwp_name);
> 
> So it really tries to format uint32_t values with %d.

Wait, we've been through this before.
See 21aa081e21da472e1e470d57770953c5e5c01477 (below).
So, that should be adjusted to do pulongest instead.

--------------
From 21aa081e21da472e1e470d57770953c5e5c01477 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Thu, 23 May 2013 18:31:29 +0000
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;

As decided on the discussion at
<http://sourceware.org/ml/gdb-patches/2013-05/msg00788.html>, use
pulongest rather than PRIu32.

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

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

	* dwarf2read.c (create_dwp_hash_table, create_dwo_in_dwp)
	(open_and_init_dwp_file): Use %s/pulongest instead of %u for
	printing uint32_t variables.
---
 gdb/ChangeLog    |  6 ++++++
 gdb/dwarf2read.c | 18 +++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5baaf27..194fb85 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2013-05-23  Pedro Alves  <palves@redhat.com>

+	* dwarf2read.c (create_dwp_hash_table, create_dwo_in_dwp)
+	(open_and_init_dwp_file): Use %s/pulongest instead of %u for
+	printing uint32_t variables.
+
+2013-05-23  Pedro Alves  <palves@redhat.com>
+
 	* NEWS: Mention GDBserver range stepping support.

 2013-05-23  Yao Qi  <yao@codesourcery.com>
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b819d3c..092a801 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8960,15 +8960,15 @@ 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 (%s)"
 	       " [in module %s]"),
-	     version, dwp_file->name);
+	     pulongest (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 (%s)"
 	       " is not power of 2 [in module %s]"),
-	     nr_slots, dwp_file->name);
+	     pulongest (nr_slots), dwp_file->name);
     }

   htab = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwp_hash_table);
@@ -9087,9 +9087,9 @@ 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 %s/%s in DWP file: %s\n",
 			  kind,
-			  section_index, hex_string (signature),
+			  pulongest (section_index), hex_string (signature),
 			  dwp_file->name);
     }

@@ -9582,9 +9582,9 @@ 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",
-			  dwp_file->cus ? dwp_file->cus->nr_units : 0,
-			  dwp_file->tus ? dwp_file->tus->nr_units : 0);
+			  "    %s CUs, %s TUs\n",
+			  pulongest (dwp_file->cus ? dwp_file->cus->nr_units : 0),
+			  pulongest (dwp_file->tus ? dwp_file->tus->nr_units : 0));
     }

   return dwp_file;
-- 
1.7.11.7


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-15 17:45   ` Pedro Alves
@ 2014-01-15 21:25     ` Doug Evans
  2014-01-16  2:52       ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Doug Evans @ 2014-01-15 21:25 UTC (permalink / raw)
  To: Pedro Alves, Eli Zaretskii; +Cc: gdb-patches

Pedro Alves writes:
 > On 01/15/2014 05:13 PM, Eli Zaretskii wrote:
 > 
 > >   /* The DWP file version is stored in the hash table.  Oh well.  */
 > >   if (dwp_file->cus->version != dwp_file->tus->version)
 > >     {
 > >       /* Technically speaking, we should try to limp along, but this is
 > >          pretty bizarre.  */
 > >       error (_("Dwarf Error: DWP file CU version %d doesn't match" <<<<<<
 > >                " TU version %d [in DWP file %s]"), <<<<<<<<<<<<<<<<<<<<<<
 > >              dwp_file->cus->version, dwp_file->tus->version, dwp_name);
 > > 
 > > So it really tries to format uint32_t values with %d.
 > 
 > Wait, we've been through this before.
 > See 21aa081e21da472e1e470d57770953c5e5c01477 (below).
 > So, that should be adjusted to do pulongest instead.

Headaches indeed.  Oh well.

I've pushed this to trunk and the 7.7 branch.

2014-01-15  Doug Evans  <dje@google.com>

	* dwarf2read.c (open_and_init_dwp_file): Use pulongest to print
	uint32_t.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 90c60cd..71bbe96 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10544,10 +10544,12 @@ open_and_init_dwp_file (void)
   if (dwp_file->cus->version != dwp_file->tus->version)
     {
       /* Technically speaking, we should try to limp along, but this is
-	 pretty bizarre.  */
-      error (_("Dwarf Error: DWP file CU version %d doesn't match"
-	       " TU version %d [in DWP file %s]"),
-	     dwp_file->cus->version, dwp_file->tus->version, dwp_name);
+	 pretty bizarre.  We use pulongest here because that's the established
+	 portability solution (e.g, we can use %u for uint32_t).  */
+      error (_("Dwarf Error: DWP file CU version %s doesn't match"
+	       " TU version %s [in DWP file %s]"),
+	     pulongest (dwp_file->cus->version),
+	     pulongest (dwp_file->tus->version), dwp_name);
     }
   dwp_file->version = dwp_file->cus->version;
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-15 21:25     ` Doug Evans
@ 2014-01-16  2:52       ` Joel Brobecker
  2014-01-16 17:35         ` Doug Evans
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2014-01-16  2:52 UTC (permalink / raw)
  To: Doug Evans; +Cc: Pedro Alves, Eli Zaretskii, gdb-patches

> +	 pretty bizarre.  We use pulongest here because that's the established
> +	 portability solution (e.g, we can use %u for uint32_t).  */
                                       ^^^

Thinko? I'd expect "cannot"...


> +      error (_("Dwarf Error: DWP file CU version %s doesn't match"
> +	       " TU version %s [in DWP file %s]"),
> +	     pulongest (dwp_file->cus->version),
> +	     pulongest (dwp_file->tus->version), dwp_name);
>      }
>    dwp_file->version = dwp_file->cus->version;
>  

-- 
Joel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-15 16:36 [PUSHED] Fix go32-nat.c build fallout from to_detach constification Pedro Alves
  2014-01-15 17:13 ` Eli Zaretskii
@ 2014-01-16 12:56 ` Pedro Alves
  1 sibling, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2014-01-16 12:56 UTC (permalink / raw)
  Cc: GDB Patches, Eli Zaretskii

On 01/15/2014 04:36 PM, Pedro Alves wrote:
> I pushed the patch below, approved by Eli offlist.

Pushed to the 7.7 branch as well now.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PUSHED] Fix go32-nat.c build fallout from to_detach constification.
  2014-01-16  2:52       ` Joel Brobecker
@ 2014-01-16 17:35         ` Doug Evans
  0 siblings, 0 replies; 7+ messages in thread
From: Doug Evans @ 2014-01-16 17:35 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Pedro Alves, Eli Zaretskii, gdb-patches

On Wed, Jan 15, 2014 at 6:52 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> +      pretty bizarre.  We use pulongest here because that's the established
>> +      portability solution (e.g, we can use %u for uint32_t).  */
>                                        ^^^
>
> Thinko? I'd expect "cannot"...
>
>
>> +      error (_("Dwarf Error: DWP file CU version %s doesn't match"
>> +            " TU version %s [in DWP file %s]"),
>> +          pulongest (dwp_file->cus->version),
>> +          pulongest (dwp_file->tus->version), dwp_name);
>>      }
>>    dwp_file->version = dwp_file->cus->version;

Yikes.  Fixed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-16 17:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-15 16:36 [PUSHED] Fix go32-nat.c build fallout from to_detach constification Pedro Alves
2014-01-15 17:13 ` Eli Zaretskii
2014-01-15 17:45   ` Pedro Alves
2014-01-15 21:25     ` Doug Evans
2014-01-16  2:52       ` Joel Brobecker
2014-01-16 17:35         ` Doug Evans
2014-01-16 12:56 ` Pedro Alves

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