public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* gdbserver with -Werror, win64 socket type
@ 2010-08-27 13:56 Ozkan Sezer
  2010-08-27 14:45 ` Pedro Alves
  0 siblings, 1 reply; 7+ messages in thread
From: Ozkan Sezer @ 2010-08-27 13:56 UTC (permalink / raw)
  To: gdb-patches

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-27 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-27 13:56 gdbserver with -Werror, win64 socket type Ozkan Sezer
2010-08-27 14:45 ` Pedro Alves
2010-08-27 15:09   ` Ozkan Sezer
2010-08-27 15:34     ` Pedro Alves
2010-08-27 15:46       ` Ozkan Sezer
2010-08-27 16:06         ` Pedro Alves
2010-08-27 16:12           ` Ozkan Sezer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).