This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
gdbserver with -Werror, win64 socket type
- From: Ozkan Sezer <sezeroz at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 27 Aug 2010 16:56:32 +0300
- Subject: gdbserver with -Werror, win64 socket type
Hi:
gdb assumes that the windows socket handles and file descriptors can be
used interchangeably as in unix, but it can not: the SOCKET type in
windows is UINT_PTR (because it is a handle) and INVALID_SOCKET used in
gdbserver/remote-utils.c is (SOCKET)(~0), but it is assigned to signed
int typed data.
Now, for w32 this wraps to -1. For w64, however, it causes the following
warnings:
../../../gdb-cvs/gdb/gdbserver/remote-utils.c:110: error: overflow in
implicit constant conversion
../../../gdb-cvs/gdb/gdbserver/remote-utils.c:111: error: overflow in
implicit constant conversion
../../../gdb-cvs/gdb/gdbserver/remote-utils.c: In function 'remote_close':
../../../gdb-cvs/gdb/gdbserver/remote-utils.c:357: error: overflow in
implicit constant conversion
Normally, we at mingw-w64 define the SOCKET type as INT_PTR, ie. signed
intptr to just _workaround_ such issues. But I got bit by the above
warnings + -Werror when I was testing compilation using the correct
UINT_PTR SOCKET type because of definitions in remote-utils.c line #79.
I know that, with the gdb source as it is now, the file descriptor and
socket interchangability issue is not an easy fix. However, we can just
add an INT_PTR cast to INVALID_DESCRIPTOR definition along with a fixme
note, like:
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.80
diff -u -p -r1.80 remote-utils.c
--- remote-utils.c 26 Aug 2010 16:24:41 -0000 1.80
+++ remote-utils.c 27 Aug 2010 13:50:11 -0000
@@ -77,7 +77,9 @@ typedef int socklen_t;
#ifndef IN_PROCESS_AGENT
#if USE_WIN32API
-# define INVALID_DESCRIPTOR INVALID_SOCKET
+/* FIXME: we are using windows socket handles and
+ file descriptors interchangeably, it is wrong. */
+# define INVALID_DESCRIPTOR (INT_PTR)INVALID_SOCKET
#else
# define INVALID_DESCRIPTOR -1
#endif
Ideas?
--
Ozkan