Re: [PATCH] fix build failure for win64, revise some format strings

Ozkan Sezer
2010-07-16T19:30:52Z

[-- 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 ();