Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ozkan Sezer <sezeroz@gmail.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] fix build failure for win64, revise some format strings
Date: Fri, 16 Jul 2010 17:18:00 -0000	[thread overview]
Message-ID: <AANLkTilXvUJo6hqsP7jfMhSVA6Pdv8pv1cZnheoHSDj8@mail.gmail.com> (raw)
In-Reply-To: <m3d3unjv6t.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2301 bytes --]

On Fri, Jul 16, 2010 at 6:35 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Ozkan" == Ozkan Sezer <sezeroz@gmail.com> writes:
>
> Ozkan> PING
> Ozkan> Can someone please review this patch? (Win64 fails to build for a week.)
>
> Sorry about that.  I was hoping someone else would do this ;-)
>
> Thanks for pinging.
>

Thanks for the suggestion, seems like an easier way, indeed.

> I think it would be better to change those places to use
> host_address_to_string.  E.g., change from:
>
>  fprintf_unfiltered (gdb_stdlog,
>                      "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
>                      (unsigned long) bp_tgt->placed_address,
>                      (unsigned long) retval);
>
> to
>
>  fprintf_unfiltered (gdb_stdlog,
>                      "target_insert_breakpoint (%s, xxx) = %ld\n",
>                      host_address_to_string (bp_tgt->placed_address),
>                      (unsigned long) retval);
>
>
> This lets us avoid dealing with the gnulib changes, etc.
>
> Tom
>

I cooked the attached patch. Tested by compiling for win64
(--host=x86_64-w64-mingw32 --disable-nls --disable-multilib),
for i686-linux (--disable-nls --disable-multilib) and for win32
(--host=i686-w64-mingw32 --disable-nls --disable-multilib).

OK for apply?

gdb/

	* target.c (debug_to_insert_breakpoint): For printing pointer-wide
	(address) variables, use host_address_to_string() and %s instead of
	casting to unsigned long and %ld.
	(debug_to_remove_breakpoint): Likewise.
	(debug_to_region_ok_for_hw_watchpoint): Likewise.
	(debug_to_can_accel_watchpoint_condition): Likewise.
	(debug_to_stopped_data_address): Likewise.
	(debug_to_watchpoint_addr_within_range): Likewise.
	(debug_to_insert_hw_breakpoint): Likewise.
	(debug_to_remove_hw_breakpoint): Likewise.
	(debug_to_insert_watchpoint): Likewise.
	(debug_to_remove_watchpoint): Likewise.

gdb/gdbserver/

	* server.c (handle_query): For windows, Use %I64d instead of
	%lld in the sprintf format string.


(Note: debug_to_region_ok_for_hw_watchpoint() specifically
did not use 0x%lx but only %ld for the addr value.  Should I
not care, or should I change my patch to use
host_address_to_string ((void *) addr) + 2
... to skip the "0x" instead?

--
Ozkan

[-- Attachment #2: g1.diff --]
[-- Type: application/octet-stream, Size: 8201 bytes --]

gdb/

	* target.c (debug_to_insert_breakpoint): For printing pointer-wide
	(address) variables, use host_address_to_string() and %s instead of
	casting to unsigned long and %ld.
	(debug_to_remove_breakpoint): Likewise.
	(debug_to_region_ok_for_hw_watchpoint): Likewise.
	(debug_to_can_accel_watchpoint_condition): Likewise.
	(debug_to_stopped_data_address): Likewise.
	(debug_to_watchpoint_addr_within_range): Likewise.
	(debug_to_insert_hw_breakpoint): Likewise.
	(debug_to_remove_hw_breakpoint): Likewise.
	(debug_to_insert_watchpoint): Likewise.
	(debug_to_remove_watchpoint): Likewise.

gdb/gdbserver/

	* server.c (handle_query): For windows, Use %I64d instead of
	%lld in the sprintf format string.

Index: gdb/target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.259
diff -U8 -p -r1.259 target.c
--- gdb/target.c	7 Jul 2010 16:15:17 -0000	1.259
+++ gdb/target.c	16 Jul 2010 17:02:40 -0000
@@ -3265,33 +3265,33 @@ static int
 debug_to_insert_breakpoint (struct gdbarch *gdbarch,
 			    struct bp_target_info *bp_tgt)
 {
   int retval;
 
   retval = debug_target.to_insert_breakpoint (gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
-		      (unsigned long) bp_tgt->placed_address,
+		      "target_insert_breakpoint (%s, xxx) = %ld\n",
+		      host_address_to_string ((void *) bp_tgt->placed_address),
 		      (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_remove_breakpoint (struct gdbarch *gdbarch,
 			    struct bp_target_info *bp_tgt)
 {
   int retval;
 
   retval = debug_target.to_remove_breakpoint (gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
-		      (unsigned long) bp_tgt->placed_address,
+		      "target_remove_breakpoint (%s, xxx) = %ld\n",
+		      host_address_to_string ((void *) bp_tgt->placed_address),
 		      (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_can_use_hw_breakpoint (int type, int cnt, int from_tty)
 {
   int retval;
@@ -3310,35 +3310,35 @@ debug_to_can_use_hw_breakpoint (int type
 static int
 debug_to_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
 {
   CORE_ADDR retval;
 
   retval = debug_target.to_region_ok_for_hw_watchpoint (addr, len);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_region_ok_for_hw_watchpoint (%ld, %ld) = 0x%lx\n",
-		      (unsigned long) addr,
+		      "target_region_ok_for_hw_watchpoint (%s, %ld) = %s\n",
+		      host_address_to_string ((void *) addr),
 		      (unsigned long) len,
-		      (unsigned long) retval);
+		      host_address_to_string ((void *) retval));
   return retval;
 }
 
 static int
 debug_to_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw,
 					 struct expression *cond)
 {
   int retval;
 
   retval = debug_target.to_can_accel_watchpoint_condition (addr, len, rw, cond);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_can_accel_watchpoint_condition (0x%lx, %d, %d, 0x%lx) = %ld\n",
-		      (unsigned long) addr, len, rw, (unsigned long) cond,
-		      (unsigned long) retval);
+		      "target_can_accel_watchpoint_condition (%s, %d, %d, %s) = %ld\n",
+		      host_address_to_string ((void *) addr), len, rw,
+		      host_address_to_string (cond), (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_stopped_by_watchpoint (void)
 {
   int retval;
 
@@ -3353,96 +3353,96 @@ debug_to_stopped_by_watchpoint (void)
 static int
 debug_to_stopped_data_address (struct target_ops *target, CORE_ADDR *addr)
 {
   int retval;
 
   retval = debug_target.to_stopped_data_address (target, addr);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_stopped_data_address ([0x%lx]) = %ld\n",
-		      (unsigned long)*addr,
+		      "target_stopped_data_address ([%s]) = %ld\n",
+		      host_address_to_string ((void *) *addr),
 		      (unsigned long)retval);
   return retval;
 }
 
 static int
 debug_to_watchpoint_addr_within_range (struct target_ops *target,
 				       CORE_ADDR addr,
 				       CORE_ADDR start, int length)
 {
   int retval;
 
   retval = debug_target.to_watchpoint_addr_within_range (target, addr,
 							 start, length);
 
   fprintf_filtered (gdb_stdlog,
-		    "target_watchpoint_addr_within_range (0x%lx, 0x%lx, %d) = %d\n",
-		    (unsigned long) addr, (unsigned long) start, length,
-		    retval);
+		    "target_watchpoint_addr_within_range (%s, %s, %d) = %d\n",
+		    host_address_to_string ((void *) addr),
+		    host_address_to_string ((void *) start), length, retval);
   return retval;
 }
 
 static int
 debug_to_insert_hw_breakpoint (struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   int retval;
 
   retval = debug_target.to_insert_hw_breakpoint (gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_insert_hw_breakpoint (0x%lx, xxx) = %ld\n",
-		      (unsigned long) bp_tgt->placed_address,
+		      "target_insert_hw_breakpoint (%s, xxx) = %ld\n",
+		      host_address_to_string ((void *) bp_tgt->placed_address),
 		      (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_remove_hw_breakpoint (struct gdbarch *gdbarch,
 			       struct bp_target_info *bp_tgt)
 {
   int retval;
 
   retval = debug_target.to_remove_hw_breakpoint (gdbarch, bp_tgt);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
-		      (unsigned long) bp_tgt->placed_address,
+		      "target_remove_hw_breakpoint (%s, xxx) = %ld\n",
+		      host_address_to_string ((void *) bp_tgt->placed_address),
 		      (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_insert_watchpoint (CORE_ADDR addr, int len, int type,
 			    struct expression *cond)
 {
   int retval;
 
   retval = debug_target.to_insert_watchpoint (addr, len, type, cond);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_insert_watchpoint (0x%lx, %d, %d, 0x%ld) = %ld\n",
-		      (unsigned long) addr, len, type, (unsigned long) cond,
-		      (unsigned long) retval);
+		      "target_insert_watchpoint (%s, %d, %d, %s) = %ld\n",
+		      host_address_to_string ((void *) addr), len, type,
+		      host_address_to_string (cond), (unsigned long) retval);
   return retval;
 }
 
 static int
 debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type,
 			    struct expression *cond)
 {
   int retval;
 
   retval = debug_target.to_remove_watchpoint (addr, len, type, cond);
 
   fprintf_unfiltered (gdb_stdlog,
-		      "target_remove_watchpoint (0x%lx, %d, %d, 0x%ld) = %ld\n",
-		      (unsigned long) addr, len, type, (unsigned long) cond,
-		      (unsigned long) retval);
+		      "target_remove_watchpoint (%s, %d, %d, %s) = %ld\n",
+		      host_address_to_string ((void *) addr), len, type,
+		      host_address_to_string (cond), (unsigned long) retval);
   return retval;
 }
 
 static void
 debug_to_terminal_init (void)
 {
   debug_target.to_terminal_init ();
 
Index: gdb/gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.125
diff -U8 -p -r1.125 server.c
--- gdb/gdbserver/server.c	7 Jul 2010 16:14:04 -0000	1.125
+++ gdb/gdbserver/server.c	16 Jul 2010 17:02:42 -0000
@@ -1534,17 +1534,21 @@ handle_query (char *own_buf, int packet_
 	    err = 2;
 	  else
 	    err = the_target->get_tls_address (thread, parts[0], parts[1],
 					       &address);
 	}
 
       if (err == 0)
 	{
+#ifdef _WIN32
+	  sprintf (own_buf, "%I64d", address);
+#else
 	  sprintf (own_buf, "%llx", address);
+#endif
 	  return;
 	}
       else if (err > 0)
 	{
 	  write_enn (own_buf);
 	  return;
 	}
 
@@ -1558,17 +1562,21 @@ handle_query (char *own_buf, int packet_
       char *annex;
       int n;
       CORE_ADDR tlb;
       ptid_t ptid = read_ptid (own_buf + 12, &annex);
 
       n = (*the_target->get_tib_address) (ptid, &tlb);
       if (n == 1)
 	{
+#ifdef _WIN32
+	  sprintf (own_buf, "%I64d", tlb);
+#else
 	  sprintf (own_buf, "%llx", tlb);
+#endif
 	  return;
 	}
       else if (n == 0)
 	{
 	  write_enn (own_buf);
 	  return;
 	}
       return;

  reply	other threads:[~2010-07-16 17:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-12 10:14 Ozkan Sezer
2010-07-12 11:51 ` Ozkan Sezer
2010-07-15 18:55   ` Ozkan Sezer
2010-07-16 15:36     ` Tom Tromey
2010-07-16 17:18       ` Ozkan Sezer [this message]
2010-07-16 18:47         ` Tom Tromey
2010-07-16 18:50           ` Ozkan Sezer
2010-07-16 19:07             ` Tom Tromey
2010-07-16 19:30               ` Ozkan Sezer
2010-07-16 19:53                 ` Tom Tromey
2010-07-16 20:10                   ` Ozkan Sezer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTilXvUJo6hqsP7jfMhSVA6Pdv8pv1cZnheoHSDj8@mail.gmail.com \
    --to=sezeroz@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox