* [PATCH] fix build failure for win64, revise some format strings
@ 2010-07-12 10:14 Ozkan Sezer
2010-07-12 11:51 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-12 10:14 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2782 bytes --]
Hi:
The current gdb cvs fails building for win64:
cc1: warnings being treated as errors
../../gdb-cvs/gdb/target.c: In function
'debug_to_can_accel_watchpoint_condition':
../../gdb-cvs/gdb/target.c:3335: error: cast from pointer to integer
of different size
../../gdb-cvs/gdb/target.c: In function 'debug_to_insert_watchpoint':
../../gdb-cvs/gdb/target.c:3424: error: cast from pointer to integer
of different size
../../gdb-cvs/gdb/target.c: In function 'debug_to_remove_watchpoint':
../../gdb-cvs/gdb/target.c:3439: error: cast from pointer to integer
of different size
The warnings are due to the unsigned long casts in gdb/target.c
with assumption of LP64 behavior which isn't true for wih64 (LLP64).
There are even more unsigned long casts there which aren't
causing warnings but still truncating the value.
I thought that it would be best to solve this using inttypes.h macros.
An initial patch is attached. Since gdb already uses gnulib for stdint,
it can also use inttypes.
In the patch, I also touched gdbserver/server.c in order to fix
another format string issue with windows:
../../../gdb-cvs/gdb/gdbserver/server.c: In function 'handle_query':
../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: unknown
conversion type character 'l' in format
../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: too many
arguments for format
../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: unknown
conversion type character 'l' in format
../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: too many
arguments for format
These warnings are due to the fact that M$ doesn't support %ll.
Fixed by using %I64d with _WIN32 ifdefs.
Patch was test by compiling gdb for x86_64-linux and for x86_64-w64-mingw32
where both targets already provide inttypes.h.
* target.c: Include inttypes.h.
(debug_to_insert_breakpoint): Remove unnecessary unsigned long casts
from int type variables. For pointers, cast to uintptr_t instead of
unsigned long and use the PRIuPTR macro from inttypes.h instead of %ld.
(debug_to_remove_breakpoint): Likewise.
(debug_to_can_use_hw_breakpoint): Likewise.
(debug_to_region_ok_for_hw_watchpoint): Likewise.
(debug_to_can_accel_watchpoint_condition): Likewise.
(debug_to_stopped_by_watchpoint): 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.
gdbserver/server.c (handle_query): For windows, Use %I64d instead of
%lld in the sprintf format string.
Note: if this patch is OK'ed, someone with an experience with gnulib should
import inttypes into gdb (I don't feel at home with gnulib.)
Regards.
--
Ozkan
[-- Attachment #2: gdb_pformat.diff --]
[-- Type: application/octet-stream, Size: 6930 bytes --]
Index: gdb/target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.259
diff -u -p -r1.259 target.c
--- gdb/target.c 7 Jul 2010 16:15:17 -0000 1.259
+++ gdb/target.c 12 Jul 2010 07:20:37 -0000
@@ -22,6 +22,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include <inttypes.h>
#include <errno.h>
#include "gdb_string.h"
#include "target.h"
@@ -3270,9 +3271,8 @@ debug_to_insert_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_insert_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3285,9 +3285,8 @@ debug_to_remove_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_remove_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (intptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3299,11 +3298,8 @@ debug_to_can_use_hw_breakpoint (int type
retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
fprintf_unfiltered (gdb_stdlog,
- "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
- (unsigned long) type,
- (unsigned long) cnt,
- (unsigned long) from_tty,
- (unsigned long) retval);
+ "target_can_use_hw_breakpoint (%d, %d, %d) = %d\n",
+ type, cnt, from_tty, retval);
return retval;
}
@@ -3315,10 +3311,9 @@ debug_to_region_ok_for_hw_watchpoint (CO
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,
- (unsigned long) len,
- (unsigned long) retval);
+ "target_region_ok_for_hw_watchpoint (%" PRIuPTR \
+ ", %d) = 0x%" PRIuPTR "\n",
+ (uintptr_t) addr, len, (uintptr_t) retval);
return retval;
}
@@ -3331,9 +3326,9 @@ debug_to_can_accel_watchpoint_condition
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ addr, len, rw, (intptr_t) cond, retval);
return retval;
}
@@ -3345,8 +3340,7 @@ debug_to_stopped_by_watchpoint (void)
retval = debug_target.to_stopped_by_watchpoint ();
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_by_watchpoint () = %ld\n",
- (unsigned long) retval);
+ "target_stopped_by_watchpoint () = %d\n", retval);
return retval;
}
@@ -3358,9 +3352,8 @@ debug_to_stopped_data_address (struct ta
retval = debug_target.to_stopped_data_address (target, addr);
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_data_address ([0x%lx]) = %ld\n",
- (unsigned long)*addr,
- (unsigned long)retval);
+ "target_stopped_data_address ([0x%" PRIuPTR "]) = %d\n",
+ (uintptr_t)*addr, retval);
return retval;
}
@@ -3375,9 +3368,9 @@ debug_to_watchpoint_addr_within_range (s
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 (0x%" PRIuPTR \
+ ", 0x%" PRIuPTR ", %d) = %d\n",
+ (uintptr_t) addr, (uintptr_t) start, length, retval);
return retval;
}
@@ -3390,9 +3383,9 @@ debug_to_insert_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_insert_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (intptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3405,9 +3398,9 @@ debug_to_remove_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_remove_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (intptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3420,9 +3413,10 @@ debug_to_insert_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond,
+ retval);
return retval;
}
@@ -3435,9 +3429,9 @@ debug_to_remove_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR ", %d, %d, 0x%" PRIuPTR \
+ ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond, retval);
return retval;
}
Index: gdb/gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.125
diff -u -p -r1.125 server.c
--- gdb/gdbserver/server.c 7 Jul 2010 16:14:04 -0000 1.125
+++ gdb/gdbserver/server.c 12 Jul 2010 09:50:13 -0000
@@ -1539,7 +1539,11 @@ handle_query (char *own_buf, int packet_
if (err == 0)
{
+#ifdef _WIN32
+ sprintf (own_buf, "%I64d", address);
+#else
sprintf (own_buf, "%llx", address);
+#endif
return;
}
else if (err > 0)
@@ -1563,7 +1567,11 @@ handle_query (char *own_buf, int packet_
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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-12 10:14 [PATCH] fix build failure for win64, revise some format strings Ozkan Sezer
@ 2010-07-12 11:51 ` Ozkan Sezer
2010-07-15 18:55 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-12 11:51 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 3286 bytes --]
On Mon, Jul 12, 2010 at 1:14 PM, Ozkan Sezer <sezeroz@gmail.com> wrote:
> Hi:
>
> The current gdb cvs fails building for win64:
>
> cc1: warnings being treated as errors
> ../../gdb-cvs/gdb/target.c: In function
> 'debug_to_can_accel_watchpoint_condition':
> ../../gdb-cvs/gdb/target.c:3335: error: cast from pointer to integer
> of different size
> ../../gdb-cvs/gdb/target.c: In function 'debug_to_insert_watchpoint':
> ../../gdb-cvs/gdb/target.c:3424: error: cast from pointer to integer
> of different size
> ../../gdb-cvs/gdb/target.c: In function 'debug_to_remove_watchpoint':
> ../../gdb-cvs/gdb/target.c:3439: error: cast from pointer to integer
> of different size
>
> The warnings are due to the unsigned long casts in gdb/target.c
> with assumption of LP64 behavior which isn't true for wih64 (LLP64).
> There are even more unsigned long casts there which aren't
> causing warnings but still truncating the value.
>
> I thought that it would be best to solve this using inttypes.h macros.
> An initial patch is attached. Since gdb already uses gnulib for stdint,
> it can also use inttypes.
>
> In the patch, I also touched gdbserver/server.c in order to fix
> another format string issue with windows:
>
> ../../../gdb-cvs/gdb/gdbserver/server.c: In function 'handle_query':
> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: unknown
> conversion type character 'l' in format
> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: too many
> arguments for format
> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: unknown
> conversion type character 'l' in format
> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: too many
> arguments for format
>
> These warnings are due to the fact that M$ doesn't support %ll.
> Fixed by using %I64d with _WIN32 ifdefs.
>
> Patch was test by compiling gdb for x86_64-linux and for x86_64-w64-mingw32
> where both targets already provide inttypes.h.
>
> * target.c: Include inttypes.h.
> (debug_to_insert_breakpoint): Remove unnecessary unsigned long casts
> from int type variables. For pointers, cast to uintptr_t instead of
> unsigned long and use the PRIuPTR macro from inttypes.h instead of %ld.
> (debug_to_remove_breakpoint): Likewise.
> (debug_to_can_use_hw_breakpoint): Likewise.
> (debug_to_region_ok_for_hw_watchpoint): Likewise.
> (debug_to_can_accel_watchpoint_condition): Likewise.
> (debug_to_stopped_by_watchpoint): 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.
>
> gdbserver/server.c (handle_query): For windows, Use %I64d instead of
> %lld in the sprintf format string.
>
> Note: if this patch is OK'ed, someone with an experience with gnulib should
> import inttypes into gdb (I don't feel at home with gnulib.)
>
> Regards.
>
> --
> Ozkan
>
Just noticed that the patch had intptr_t (as a typo) instead of uintptr_t
in a few places. Fixed one attached.
--
Ozkan
[-- Attachment #2: gdb_pformat.diff --]
[-- Type: application/octet-stream, Size: 7791 bytes --]
* target.c: Include inttypes.h.
(debug_to_insert_breakpoint): Remove unnecessary unsigned long casts
from int type variables. For pointers, cast to uintptr_t instead of
unsigned long and use the PRIuPTR macro from inttypes.h instead of %ld.
(debug_to_remove_breakpoint): Likewise.
(debug_to_can_use_hw_breakpoint): Likewise.
(debug_to_region_ok_for_hw_watchpoint): Likewise.
(debug_to_can_accel_watchpoint_condition): Likewise.
(debug_to_stopped_by_watchpoint): 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.
* 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 -u -p -r1.259 target.c
--- gdb/target.c 7 Jul 2010 16:15:17 -0000 1.259
+++ gdb/target.c 12 Jul 2010 07:20:37 -0000
@@ -22,6 +22,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include <inttypes.h>
#include <errno.h>
#include "gdb_string.h"
#include "target.h"
@@ -3270,9 +3271,8 @@ debug_to_insert_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_insert_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3285,9 +3285,8 @@ debug_to_remove_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_remove_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3299,11 +3298,8 @@ debug_to_can_use_hw_breakpoint (int type
retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
fprintf_unfiltered (gdb_stdlog,
- "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
- (unsigned long) type,
- (unsigned long) cnt,
- (unsigned long) from_tty,
- (unsigned long) retval);
+ "target_can_use_hw_breakpoint (%d, %d, %d) = %d\n",
+ type, cnt, from_tty, retval);
return retval;
}
@@ -3315,10 +3311,9 @@ debug_to_region_ok_for_hw_watchpoint (CO
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,
- (unsigned long) len,
- (unsigned long) retval);
+ "target_region_ok_for_hw_watchpoint (%" PRIuPTR \
+ ", %d) = 0x%" PRIuPTR "\n",
+ (uintptr_t) addr, len, (uintptr_t) retval);
return retval;
}
@@ -3331,9 +3326,9 @@ debug_to_can_accel_watchpoint_condition
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ addr, len, rw, (uintptr_t) cond, retval);
return retval;
}
@@ -3345,8 +3340,7 @@ debug_to_stopped_by_watchpoint (void)
retval = debug_target.to_stopped_by_watchpoint ();
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_by_watchpoint () = %ld\n",
- (unsigned long) retval);
+ "target_stopped_by_watchpoint () = %d\n", retval);
return retval;
}
@@ -3358,9 +3352,8 @@ debug_to_stopped_data_address (struct ta
retval = debug_target.to_stopped_data_address (target, addr);
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_data_address ([0x%lx]) = %ld\n",
- (unsigned long)*addr,
- (unsigned long)retval);
+ "target_stopped_data_address ([0x%" PRIuPTR "]) = %d\n",
+ (uintptr_t)*addr, retval);
return retval;
}
@@ -3375,9 +3368,9 @@ debug_to_watchpoint_addr_within_range (s
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 (0x%" PRIuPTR \
+ ", 0x%" PRIuPTR ", %d) = %d\n",
+ (uintptr_t) addr, (uintptr_t) start, length, retval);
return retval;
}
@@ -3390,9 +3383,9 @@ debug_to_insert_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_insert_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3405,9 +3398,9 @@ debug_to_remove_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_remove_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3420,9 +3413,10 @@ debug_to_insert_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond,
+ retval);
return retval;
}
@@ -3435,9 +3429,9 @@ debug_to_remove_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR ", %d, %d, 0x%" PRIuPTR \
+ ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond, retval);
return retval;
}
Index: gdb/gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.125
diff -u -p -r1.125 server.c
--- gdb/gdbserver/server.c 7 Jul 2010 16:14:04 -0000 1.125
+++ gdb/gdbserver/server.c 12 Jul 2010 09:50:13 -0000
@@ -1539,7 +1539,11 @@ handle_query (char *own_buf, int packet_
if (err == 0)
{
+#ifdef _WIN32
+ sprintf (own_buf, "%I64d", address);
+#else
sprintf (own_buf, "%llx", address);
+#endif
return;
}
else if (err > 0)
@@ -1563,7 +1567,11 @@ handle_query (char *own_buf, int packet_
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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-12 11:51 ` Ozkan Sezer
@ 2010-07-15 18:55 ` Ozkan Sezer
2010-07-16 15:36 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-15 18:55 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 3527 bytes --]
PING
Can someone please review this patch? (Win64 fails to build for a week.)
On Mon, Jul 12, 2010 at 2:51 PM, Ozkan Sezer <sezeroz@gmail.com> wrote:
> On Mon, Jul 12, 2010 at 1:14 PM, Ozkan Sezer <sezeroz@gmail.com> wrote:
>> Hi:
>>
>> The current gdb cvs fails building for win64:
>>
>> cc1: warnings being treated as errors
>> ../../gdb-cvs/gdb/target.c: In function
>> 'debug_to_can_accel_watchpoint_condition':
>> ../../gdb-cvs/gdb/target.c:3335: error: cast from pointer to integer
>> of different size
>> ../../gdb-cvs/gdb/target.c: In function 'debug_to_insert_watchpoint':
>> ../../gdb-cvs/gdb/target.c:3424: error: cast from pointer to integer
>> of different size
>> ../../gdb-cvs/gdb/target.c: In function 'debug_to_remove_watchpoint':
>> ../../gdb-cvs/gdb/target.c:3439: error: cast from pointer to integer
>> of different size
>>
>> The warnings are due to the unsigned long casts in gdb/target.c
>> with assumption of LP64 behavior which isn't true for wih64 (LLP64).
>> There are even more unsigned long casts there which aren't
>> causing warnings but still truncating the value.
>>
>> I thought that it would be best to solve this using inttypes.h macros.
>> An initial patch is attached. Since gdb already uses gnulib for stdint,
>> it can also use inttypes.
>>
>> In the patch, I also touched gdbserver/server.c in order to fix
>> another format string issue with windows:
>>
>> ../../../gdb-cvs/gdb/gdbserver/server.c: In function 'handle_query':
>> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: unknown
>> conversion type character 'l' in format
>> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: too many
>> arguments for format
>> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: unknown
>> conversion type character 'l' in format
>> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: too many
>> arguments for format
>>
>> These warnings are due to the fact that M$ doesn't support %ll.
>> Fixed by using %I64d with _WIN32 ifdefs.
>>
>> Patch was test by compiling gdb for x86_64-linux and for x86_64-w64-mingw32
>> where both targets already provide inttypes.h.
>>
>> * target.c: Include inttypes.h.
>> (debug_to_insert_breakpoint): Remove unnecessary unsigned long casts
>> from int type variables. For pointers, cast to uintptr_t instead of
>> unsigned long and use the PRIuPTR macro from inttypes.h instead of %ld.
>> (debug_to_remove_breakpoint): Likewise.
>> (debug_to_can_use_hw_breakpoint): Likewise.
>> (debug_to_region_ok_for_hw_watchpoint): Likewise.
>> (debug_to_can_accel_watchpoint_condition): Likewise.
>> (debug_to_stopped_by_watchpoint): 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.
>>
>> gdbserver/server.c (handle_query): For windows, Use %I64d instead of
>> %lld in the sprintf format string.
>>
>> Note: if this patch is OK'ed, someone with an experience with gnulib should
>> import inttypes into gdb (I don't feel at home with gnulib.)
>>
>> Regards.
>>
>> --
>> Ozkan
>>
>
> Just noticed that the patch had intptr_t (as a typo) instead of uintptr_t
> in a few places. Fixed one attached.
>
> --
> Ozkan
>
[-- Attachment #2: gdb_pformat.diff --]
[-- Type: application/octet-stream, Size: 7791 bytes --]
* target.c: Include inttypes.h.
(debug_to_insert_breakpoint): Remove unnecessary unsigned long casts
from int type variables. For pointers, cast to uintptr_t instead of
unsigned long and use the PRIuPTR macro from inttypes.h instead of %ld.
(debug_to_remove_breakpoint): Likewise.
(debug_to_can_use_hw_breakpoint): Likewise.
(debug_to_region_ok_for_hw_watchpoint): Likewise.
(debug_to_can_accel_watchpoint_condition): Likewise.
(debug_to_stopped_by_watchpoint): 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.
* 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 -u -p -r1.259 target.c
--- gdb/target.c 7 Jul 2010 16:15:17 -0000 1.259
+++ gdb/target.c 12 Jul 2010 07:20:37 -0000
@@ -22,6 +22,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include <inttypes.h>
#include <errno.h>
#include "gdb_string.h"
#include "target.h"
@@ -3270,9 +3271,8 @@ debug_to_insert_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_insert_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3285,9 +3285,8 @@ debug_to_remove_breakpoint (struct gdbar
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,
- (unsigned long) retval);
+ "target_remove_breakpoint (0x%" PRIuPTR ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3299,11 +3298,8 @@ debug_to_can_use_hw_breakpoint (int type
retval = debug_target.to_can_use_hw_breakpoint (type, cnt, from_tty);
fprintf_unfiltered (gdb_stdlog,
- "target_can_use_hw_breakpoint (%ld, %ld, %ld) = %ld\n",
- (unsigned long) type,
- (unsigned long) cnt,
- (unsigned long) from_tty,
- (unsigned long) retval);
+ "target_can_use_hw_breakpoint (%d, %d, %d) = %d\n",
+ type, cnt, from_tty, retval);
return retval;
}
@@ -3315,10 +3311,9 @@ debug_to_region_ok_for_hw_watchpoint (CO
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,
- (unsigned long) len,
- (unsigned long) retval);
+ "target_region_ok_for_hw_watchpoint (%" PRIuPTR \
+ ", %d) = 0x%" PRIuPTR "\n",
+ (uintptr_t) addr, len, (uintptr_t) retval);
return retval;
}
@@ -3331,9 +3326,9 @@ debug_to_can_accel_watchpoint_condition
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ addr, len, rw, (uintptr_t) cond, retval);
return retval;
}
@@ -3345,8 +3340,7 @@ debug_to_stopped_by_watchpoint (void)
retval = debug_target.to_stopped_by_watchpoint ();
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_by_watchpoint () = %ld\n",
- (unsigned long) retval);
+ "target_stopped_by_watchpoint () = %d\n", retval);
return retval;
}
@@ -3358,9 +3352,8 @@ debug_to_stopped_data_address (struct ta
retval = debug_target.to_stopped_data_address (target, addr);
fprintf_unfiltered (gdb_stdlog,
- "target_stopped_data_address ([0x%lx]) = %ld\n",
- (unsigned long)*addr,
- (unsigned long)retval);
+ "target_stopped_data_address ([0x%" PRIuPTR "]) = %d\n",
+ (uintptr_t)*addr, retval);
return retval;
}
@@ -3375,9 +3368,9 @@ debug_to_watchpoint_addr_within_range (s
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 (0x%" PRIuPTR \
+ ", 0x%" PRIuPTR ", %d) = %d\n",
+ (uintptr_t) addr, (uintptr_t) start, length, retval);
return retval;
}
@@ -3390,9 +3383,9 @@ debug_to_insert_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_insert_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3405,9 +3398,9 @@ debug_to_remove_hw_breakpoint (struct gd
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,
- (unsigned long) retval);
+ "target_remove_hw_breakpoint (0x%" PRIuPTR \
+ ", xxx) = %d\n",
+ (uintptr_t) bp_tgt->placed_address, retval);
return retval;
}
@@ -3420,9 +3413,10 @@ debug_to_insert_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR \
+ ", %d, %d, 0x%" PRIuPTR ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond,
+ retval);
return retval;
}
@@ -3435,9 +3429,9 @@ debug_to_remove_watchpoint (CORE_ADDR ad
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 (0x%" PRIuPTR ", %d, %d, 0x%" PRIuPTR \
+ ") = %d\n",
+ (uintptr_t) addr, len, type, (uintptr_t) cond, retval);
return retval;
}
Index: gdb/gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.125
diff -u -p -r1.125 server.c
--- gdb/gdbserver/server.c 7 Jul 2010 16:14:04 -0000 1.125
+++ gdb/gdbserver/server.c 12 Jul 2010 09:50:13 -0000
@@ -1539,7 +1539,11 @@ handle_query (char *own_buf, int packet_
if (err == 0)
{
+#ifdef _WIN32
+ sprintf (own_buf, "%I64d", address);
+#else
sprintf (own_buf, "%llx", address);
+#endif
return;
}
else if (err > 0)
@@ -1563,7 +1567,11 @@ handle_query (char *own_buf, int packet_
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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-15 18:55 ` Ozkan Sezer
@ 2010-07-16 15:36 ` Tom Tromey
2010-07-16 17:18 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-07-16 15:36 UTC (permalink / raw)
To: Ozkan Sezer; +Cc: gdb-patches
>>>>> "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.
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 15:36 ` Tom Tromey
@ 2010-07-16 17:18 ` Ozkan Sezer
2010-07-16 18:47 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-16 17:18 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[-- 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;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 17:18 ` Ozkan Sezer
@ 2010-07-16 18:47 ` Tom Tromey
2010-07-16 18:50 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-07-16 18:47 UTC (permalink / raw)
To: Ozkan Sezer; +Cc: gdb-patches
>>>>> "Ozkan" == Ozkan Sezer <sezeroz@gmail.com> writes:
Ozkan> gdb/gdbserver/
Ozkan> * server.c (handle_query): For windows, Use %I64d instead of
Ozkan> %lld in the sprintf format string.
I don't know much about gdbserver. So I am going to ask that someone
else look at this part.
Ozkan> (Note: debug_to_region_ok_for_hw_watchpoint() specifically
Ozkan> did not use 0x%lx but only %ld for the addr value. Should I
Ozkan> not care, or should I change my patch to use
Ozkan> host_address_to_string ((void *) addr) + 2
Ozkan> ... to skip the "0x" instead?
Don't worry about it, using host_address_to_string is fine.
Ozkan> + host_address_to_string ((void *) bp_tgt->placed_address),
I think you should not need these casts to void*.
The gdb parts of this patch are ok with that change. Thanks.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 18:47 ` Tom Tromey
@ 2010-07-16 18:50 ` Ozkan Sezer
2010-07-16 19:07 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-16 18:50 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Fri, Jul 16, 2010 at 9:47 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Ozkan" == Ozkan Sezer <sezeroz@gmail.com> writes:
>
> Ozkan> gdb/gdbserver/
> Ozkan> * server.c (handle_query): For windows, Use %I64d instead of
> Ozkan> %lld in the sprintf format string.
>
> I don't know much about gdbserver. So I am going to ask that someone
> else look at this part.
>
> Ozkan> (Note: debug_to_region_ok_for_hw_watchpoint() specifically
> Ozkan> did not use 0x%lx but only %ld for the addr value. Should I
> Ozkan> not care, or should I change my patch to use
> Ozkan> host_address_to_string ((void *) addr) + 2
> Ozkan> ... to skip the "0x" instead?
>
> Don't worry about it, using host_address_to_string is fine.
>
> Ozkan> + host_address_to_string ((void *) bp_tgt->placed_address),
>
> I think you should not need these casts to void*.
Actually I do: placed_address is CORE_ADDR which is
bfd_vma, ie. uintptr_t and not a pointer.
>
> The gdb parts of this patch are ok with that change. Thanks.
>
Still OK without removing the casts?
> Tom
>
--
Ozkan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 18:50 ` Ozkan Sezer
@ 2010-07-16 19:07 ` Tom Tromey
2010-07-16 19:30 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-07-16 19:07 UTC (permalink / raw)
To: Ozkan Sezer; +Cc: Tom Tromey, gdb-patches
Ozkan> Actually I do: placed_address is CORE_ADDR which is
Ozkan> bfd_vma, ie. uintptr_t and not a pointer.
Aha. I didn't look that deeply.
There are different functions in utils.c for printing a CORE_ADDR.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 19:07 ` Tom Tromey
@ 2010-07-16 19:30 ` Ozkan Sezer
2010-07-16 19:53 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-16 19:30 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]
On Fri, Jul 16, 2010 at 10:10 PM, Tom Tromey <tromey@redhat.com> wrote:
> Ozkan> Actually I do: placed_address is CORE_ADDR which is
> Ozkan> bfd_vma, ie. uintptr_t and not a pointer.
>
> Aha. I didn't look that deeply.
> There are different functions in utils.c for printing a CORE_ADDR.
>
> Tom
>
That would be core_addr_to_string() I guess (I'm learning), modified
patch attached. OK to apply? (Should I use core_addr_to_string_nz
to trim the leading zeroes instead?)
* target.c (debug_to_insert_breakpoint): Instead of casting to unsigned
long and %ld, use core_addr_to_string and %s to print CORE_ADDR vars and
host_address_to_string() and %s for pointers.
(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.
--
Ozkan
[-- Attachment #2: g1a.diff --]
[-- Type: application/octet-stream, Size: 6839 bytes --]
2010-07-16 Ozkan Sezer <sezeroz@gmail.com>
* target.c (debug_to_insert_breakpoint): Instead of casting to unsigned
long and %ld, use core_addr_to_string and %s to print CORE_ADDR vars and
host_address_to_string() and %s for pointers.
(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.
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 19:16:57 -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",
+ core_addr_to_string (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",
+ core_addr_to_string (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,34 @@ 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,
- (unsigned long) len,
- (unsigned long) retval);
+ "target_region_ok_for_hw_watchpoint (%s, %ld) = %s\n",
+ core_addr_to_string (addr), (unsigned long) len,
+ core_addr_to_string (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",
+ core_addr_to_string (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 +3352,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",
+ core_addr_to_string (*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",
+ core_addr_to_string (addr), core_addr_to_string (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",
+ core_addr_to_string (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",
+ core_addr_to_string (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",
+ core_addr_to_string (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",
+ core_addr_to_string (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 ();
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 19:30 ` Ozkan Sezer
@ 2010-07-16 19:53 ` Tom Tromey
2010-07-16 20:10 ` Ozkan Sezer
0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-07-16 19:53 UTC (permalink / raw)
To: Ozkan Sezer; +Cc: Tom Tromey, gdb-patches
>>>>> "Ozkan" == Ozkan Sezer <sezeroz@gmail.com> writes:
Ozkan> That would be core_addr_to_string() I guess (I'm learning), modified
Ozkan> patch attached. OK to apply? (Should I use core_addr_to_string_nz
Ozkan> to trim the leading zeroes instead?)
I think it is fine as-is.
Please check this in, thanks.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] fix build failure for win64, revise some format strings
2010-07-16 19:53 ` Tom Tromey
@ 2010-07-16 20:10 ` Ozkan Sezer
0 siblings, 0 replies; 11+ messages in thread
From: Ozkan Sezer @ 2010-07-16 20:10 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Fri, Jul 16, 2010 at 10:56 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Ozkan" == Ozkan Sezer <sezeroz@gmail.com> writes:
>
> Ozkan> That would be core_addr_to_string() I guess (I'm learning), modified
> Ozkan> patch attached. OK to apply? (Should I use core_addr_to_string_nz
> Ozkan> to trim the leading zeroes instead?)
>
> I think it is fine as-is.
> Please check this in, thanks.
>
> Tom
>
Applied, thanks.
For the gdbserver change, I am sending another mail (you CC'ed)
so that it doesn't get forgotten here.
--
Ozkan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-07-16 20:10 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-12 10:14 [PATCH] fix build failure for win64, revise some format strings 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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox