This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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: gdb_pformat.diff
Description: Binary data


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