Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ozkan Sezer <sezeroz@gmail.com>
To: gdb-patches@sourceware.org
Subject: gdbserver with -Werror, win64 socket type
Date: Fri, 27 Aug 2010 13:56:00 -0000	[thread overview]
Message-ID: <AANLkTi=BqExXKgwgVS5cXgrjK-g-0P=GYEOhK9P6ciM_@mail.gmail.com> (raw)

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


             reply	other threads:[~2010-08-27 13:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 13:56 Ozkan Sezer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTi=BqExXKgwgVS5cXgrjK-g-0P=GYEOhK9P6ciM_@mail.gmail.com' \
    --to=sezeroz@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox