From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17114 invoked by alias); 27 Aug 2010 13:56:41 -0000 Received: (qmail 17100 invoked by uid 22791); 27 Aug 2010 13:56:39 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iw0-f169.google.com (HELO mail-iw0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Aug 2010 13:56:34 +0000 Received: by iwn33 with SMTP id 33so3892975iwn.0 for ; Fri, 27 Aug 2010 06:56:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.15.9 with SMTP id i9mr1196905iba.58.1282917392047; Fri, 27 Aug 2010 06:56:32 -0700 (PDT) Received: by 10.231.141.155 with HTTP; Fri, 27 Aug 2010 06:56:32 -0700 (PDT) Date: Fri, 27 Aug 2010 13:56:00 -0000 Message-ID: Subject: gdbserver with -Werror, win64 socket type From: Ozkan Sezer To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-08/txt/msg00459.txt.bz2 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