* 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
* Re: gdbserver with -Werror, win64 socket type 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 0 siblings, 1 reply; 7+ messages in thread From: Pedro Alves @ 2010-08-27 14:45 UTC (permalink / raw) To: gdb-patches; +Cc: Ozkan Sezer On Friday 27 August 2010 14:56:32, Ozkan Sezer wrote: > Hi: > > gdb assumes that the windows socket handles and file descriptors can be > used interchangeably as in unix, but it can not: s/gdb/gdbserver, and there is actually no such assumption. The mingw ports of gdbserver only support socket communications, and nothing else. see: void remote_open (char *name) { char *port_str; port_str = strchr (name, ':'); if (port_str == NULL) { #ifdef USE_WIN32API error ("Only <host>:<port> is supported on this platform."); #else > Ideas? Given the above, could you give this patch a try? -- Pedro Alves --- gdb/gdbserver/event-loop.c | 17 +++++++++-------- gdb/gdbserver/remote-utils.c | 4 ++-- gdb/gdbserver/server.h | 12 +++++++++--- 3 files changed, 20 insertions(+), 13 deletions(-) Index: src/gdb/gdbserver/event-loop.c =================================================================== --- src.orig/gdb/gdbserver/event-loop.c 2010-06-16 10:58:29.000000000 +0100 +++ src/gdb/gdbserver/event-loop.c 2010-08-27 15:39:25.000000000 +0100 @@ -64,7 +64,7 @@ struct gdb_event event_handler_func *proc; /* File descriptor that is ready. */ - int fd; + gdb_fildes_t fd; /* Next in list of events or NULL. */ struct gdb_event *next_event; @@ -76,7 +76,7 @@ struct gdb_event typedef struct file_handler { /* File descriptor. */ - int fd; + gdb_fildes_t fd; /* Events we want to monitor. */ int mask; @@ -202,7 +202,7 @@ process_event (void) { gdb_event *event_ptr, *prev_ptr; event_handler_func *proc; - int fd; + gdb_fildes_t fd; /* Look in the event queue to find an event that is ready to be processed. */ @@ -332,7 +332,7 @@ process_callback (void) occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ static void -create_file_handler (int fd, int mask, handler_func *proc, +create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc, gdb_client_data client_data) { file_handler *file_ptr; @@ -382,7 +382,8 @@ create_file_handler (int fd, int mask, h /* Wrapper function for create_file_handler. */ void -add_file_handler (int fd, handler_func *proc, gdb_client_data client_data) +add_file_handler (gdb_fildes_t fd, + handler_func *proc, gdb_client_data client_data) { create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data); } @@ -391,7 +392,7 @@ add_file_handler (int fd, handler_func * i.e. we don't care anymore about events on the FD. */ void -delete_file_handler (int fd) +delete_file_handler (gdb_fildes_t fd) { file_handler *file_ptr, *prev_ptr = NULL; int i; @@ -454,7 +455,7 @@ delete_file_handler (int fd) event in the front of the event queue. */ static int -handle_file_event (int event_file_desc) +handle_file_event (gdb_fildes_t event_file_desc) { file_handler *file_ptr; int mask; @@ -502,7 +503,7 @@ handle_file_event (int event_file_desc) associated to FD when it was registered with the event loop. */ static gdb_event * -create_file_event (int fd) +create_file_event (gdb_fildes_t fd) { gdb_event *file_event_ptr; Index: src/gdb/gdbserver/remote-utils.c =================================================================== --- src.orig/gdb/gdbserver/remote-utils.c 2010-08-26 19:32:03.000000000 +0100 +++ src/gdb/gdbserver/remote-utils.c 2010-08-27 15:37:02.000000000 +0100 @@ -107,8 +107,8 @@ struct sym_cache int remote_debug = 0; struct ui_file *gdb_stdlog; -static int remote_desc = INVALID_DESCRIPTOR; -static int listen_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; /* FIXME headerize? */ extern int using_threads; Index: src/gdb/gdbserver/server.h =================================================================== --- src.orig/gdb/gdbserver/server.h 2010-07-19 15:47:22.000000000 +0100 +++ src/gdb/gdbserver/server.h 2010-08-27 15:40:30.000000000 +0100 @@ -334,13 +334,19 @@ extern int disable_packet_qfThreadInfo; extern int multi_process; extern int non_stop; +#if USE_WIN32API +typedef SOCKET gdb_fildes_t; +#else +typedef int gdb_fildes_t; +#endif + /* Functions from event-loop.c. */ typedef void *gdb_client_data; -typedef int (handler_func) (int, gdb_client_data); +typedef int (handler_func) (gdb_fildes_t, gdb_client_data); typedef int (callback_handler_func) (gdb_client_data); -extern void delete_file_handler (int fd); -extern void add_file_handler (int fd, handler_func *proc, +extern void delete_file_handler (gdb_fildes_t fd); +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, gdb_client_data client_data); extern int append_callback_event (callback_handler_func *proc, gdb_client_data client_data); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdbserver with -Werror, win64 socket type 2010-08-27 14:45 ` Pedro Alves @ 2010-08-27 15:09 ` Ozkan Sezer 2010-08-27 15:34 ` Pedro Alves 0 siblings, 1 reply; 7+ messages in thread From: Ozkan Sezer @ 2010-08-27 15:09 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches Hi Pedro, thanks for looking into this, On Fri, Aug 27, 2010 at 5:45 PM, Pedro Alves <pedro@codesourcery.com> wrote: > On Friday 27 August 2010 14:56:32, Ozkan Sezer wrote: >> Hi: >> >> gdb assumes that the windows socket handles and file descriptors can be >> used interchangeably as in unix, but it can not: > > s/gdb/gdbserver, and there is actually no such assumption. The mingw Not exactly correct, see gdb/serial.h, struct serial where fd is int type and is used socket() for assigning its data. > ports of gdbserver only support socket communications, and nothing else. > > see: > > void > remote_open (char *name) > { > char *port_str; > > port_str = strchr (name, ':'); > if (port_str == NULL) > { > #ifdef USE_WIN32API > error ("Only <host>:<port> is supported on this platform."); > #else > >> Ideas? > > Given the above, could you give this patch a try? > > -- > Pedro Alves > > --- > gdb/gdbserver/event-loop.c | 17 +++++++++-------- > gdb/gdbserver/remote-utils.c | 4 ++-- > gdb/gdbserver/server.h | 12 +++++++++--- > 3 files changed, 20 insertions(+), 13 deletions(-) > > Index: src/gdb/gdbserver/event-loop.c > =================================================================== > --- src.orig/gdb/gdbserver/event-loop.c 2010-06-16 10:58:29.000000000 +0100 > +++ src/gdb/gdbserver/event-loop.c 2010-08-27 15:39:25.000000000 +0100 > @@ -64,7 +64,7 @@ struct gdb_event > event_handler_func *proc; > > /* File descriptor that is ready. */ > - int fd; > + gdb_fildes_t fd; > > /* Next in list of events or NULL. */ > struct gdb_event *next_event; > @@ -76,7 +76,7 @@ struct gdb_event > typedef struct file_handler > { > /* File descriptor. */ > - int fd; > + gdb_fildes_t fd; > > /* Events we want to monitor. */ > int mask; > @@ -202,7 +202,7 @@ process_event (void) > { > gdb_event *event_ptr, *prev_ptr; > event_handler_func *proc; > - int fd; > + gdb_fildes_t fd; > > /* Look in the event queue to find an event that is ready > to be processed. */ > @@ -332,7 +332,7 @@ process_callback (void) > occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ > > static void > -create_file_handler (int fd, int mask, handler_func *proc, > +create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc, > gdb_client_data client_data) > { > file_handler *file_ptr; > @@ -382,7 +382,8 @@ create_file_handler (int fd, int mask, h > /* Wrapper function for create_file_handler. */ > > void > -add_file_handler (int fd, handler_func *proc, gdb_client_data client_data) > +add_file_handler (gdb_fildes_t fd, > + handler_func *proc, gdb_client_data client_data) > { > create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data); > } > @@ -391,7 +392,7 @@ add_file_handler (int fd, handler_func * > i.e. we don't care anymore about events on the FD. */ > > void > -delete_file_handler (int fd) > +delete_file_handler (gdb_fildes_t fd) > { > file_handler *file_ptr, *prev_ptr = NULL; > int i; > @@ -454,7 +455,7 @@ delete_file_handler (int fd) > event in the front of the event queue. */ > > static int > -handle_file_event (int event_file_desc) > +handle_file_event (gdb_fildes_t event_file_desc) > { > file_handler *file_ptr; > int mask; > @@ -502,7 +503,7 @@ handle_file_event (int event_file_desc) > associated to FD when it was registered with the event loop. */ > > static gdb_event * > -create_file_event (int fd) > +create_file_event (gdb_fildes_t fd) > { > gdb_event *file_event_ptr; > > Index: src/gdb/gdbserver/remote-utils.c > =================================================================== > --- src.orig/gdb/gdbserver/remote-utils.c 2010-08-26 19:32:03.000000000 +0100 > +++ src/gdb/gdbserver/remote-utils.c 2010-08-27 15:37:02.000000000 +0100 > @@ -107,8 +107,8 @@ struct sym_cache > int remote_debug = 0; > struct ui_file *gdb_stdlog; > > -static int remote_desc = INVALID_DESCRIPTOR; > -static int listen_desc = INVALID_DESCRIPTOR; > +static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; > +static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; > > /* FIXME headerize? */ > extern int using_threads; > Index: src/gdb/gdbserver/server.h > =================================================================== > --- src.orig/gdb/gdbserver/server.h 2010-07-19 15:47:22.000000000 +0100 > +++ src/gdb/gdbserver/server.h 2010-08-27 15:40:30.000000000 +0100 > @@ -334,13 +334,19 @@ extern int disable_packet_qfThreadInfo; > extern int multi_process; > extern int non_stop; > > +#if USE_WIN32API I had to insert a #include <winsock2.h> here but, then ... > +typedef SOCKET gdb_fildes_t; > +#else > +typedef int gdb_fildes_t; > +#endif > + > /* Functions from event-loop.c. */ > typedef void *gdb_client_data; > -typedef int (handler_func) (int, gdb_client_data); > +typedef int (handler_func) (gdb_fildes_t, gdb_client_data); > typedef int (callback_handler_func) (gdb_client_data); > > -extern void delete_file_handler (int fd); > -extern void add_file_handler (int fd, handler_func *proc, > +extern void delete_file_handler (gdb_fildes_t fd); > +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, > gdb_client_data client_data); > extern int append_callback_event (callback_handler_func *proc, > gdb_client_data client_data); > ... I get these: ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'handle_file_event': ../../../gdb-cvs/gdb/gdbserver/event-loop.c:476: error: format '%d' expects type 'int', but argument 3 has type 'gdb_fildes_t' ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'create_file_event': ../../../gdb-cvs/gdb/gdbserver/event-loop.c:511: error: assignment from incompatible pointer type -- Ozkan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdbserver with -Werror, win64 socket type 2010-08-27 15:09 ` Ozkan Sezer @ 2010-08-27 15:34 ` Pedro Alves 2010-08-27 15:46 ` Ozkan Sezer 0 siblings, 1 reply; 7+ messages in thread From: Pedro Alves @ 2010-08-27 15:34 UTC (permalink / raw) To: gdb-patches; +Cc: Ozkan Sezer On Friday 27 August 2010 16:09:37, Ozkan Sezer wrote: > Hi Pedro, thanks for looking into this, > > s/gdb/gdbserver, and there is actually no such assumption. The mingw > > Not exactly correct, see gdb/serial.h, struct serial where fd is int type > and is used socket() for assigning its data. Note the "s/gdb/gdbserver". > ... I get these: > > ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'handle_file_event': > ../../../gdb-cvs/gdb/gdbserver/event-loop.c:476: error: format '%d' > expects type 'int', but argument 3 has type 'gdb_fildes_t' > ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'create_file_event': > ../../../gdb-cvs/gdb/gdbserver/event-loop.c:511: error: assignment > from incompatible pointer type Try this version. If this still fails, please use "make -k" so that we see the most errors as possible in one run. -- Pedro Alves --- gdb/gdbserver/event-loop.c | 23 ++++++++++++----------- gdb/gdbserver/remote-utils.c | 4 ++-- gdb/gdbserver/server.h | 11 +++++++++-- gdb/gdbserver/utils.c | 12 ++++++++++++ 4 files changed, 35 insertions(+), 15 deletions(-) Index: src/gdb/gdbserver/event-loop.c =================================================================== --- src.orig/gdb/gdbserver/event-loop.c 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/event-loop.c 2010-08-27 16:28:18.000000000 +0100 @@ -39,7 +39,7 @@ #endif typedef struct gdb_event gdb_event; -typedef int (event_handler_func) (int); +typedef int (event_handler_func) (gdb_fildes_t); /* Tell create_file_handler what events we are interested in. */ @@ -64,7 +64,7 @@ struct gdb_event event_handler_func *proc; /* File descriptor that is ready. */ - int fd; + gdb_fildes_t fd; /* Next in list of events or NULL. */ struct gdb_event *next_event; @@ -76,7 +76,7 @@ struct gdb_event typedef struct file_handler { /* File descriptor. */ - int fd; + gdb_fildes_t fd; /* Events we want to monitor. */ int mask; @@ -202,7 +202,7 @@ process_event (void) { gdb_event *event_ptr, *prev_ptr; event_handler_func *proc; - int fd; + gdb_fildes_t fd; /* Look in the event queue to find an event that is ready to be processed. */ @@ -332,7 +332,7 @@ process_callback (void) occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ static void -create_file_handler (int fd, int mask, handler_func *proc, +create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc, gdb_client_data client_data) { file_handler *file_ptr; @@ -382,7 +382,8 @@ create_file_handler (int fd, int mask, h /* Wrapper function for create_file_handler. */ void -add_file_handler (int fd, handler_func *proc, gdb_client_data client_data) +add_file_handler (gdb_fildes_t fd, + handler_func *proc, gdb_client_data client_data) { create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data); } @@ -391,7 +392,7 @@ add_file_handler (int fd, handler_func * i.e. we don't care anymore about events on the FD. */ void -delete_file_handler (int fd) +delete_file_handler (gdb_fildes_t fd) { file_handler *file_ptr, *prev_ptr = NULL; int i; @@ -454,7 +455,7 @@ delete_file_handler (int fd) event in the front of the event queue. */ static int -handle_file_event (int event_file_desc) +handle_file_event (gdb_fildes_t event_file_desc) { file_handler *file_ptr; int mask; @@ -471,8 +472,8 @@ handle_file_event (int event_file_desc) if (file_ptr->ready_mask & GDB_EXCEPTION) { - fprintf (stderr, "Exception condition detected on fd %d\n", - file_ptr->fd); + fprintf (stderr, "Exception condition detected on fd %s\n", + pfildes (file_ptr->fd)); file_ptr->error = 1; } else @@ -502,7 +503,7 @@ handle_file_event (int event_file_desc) associated to FD when it was registered with the event loop. */ static gdb_event * -create_file_event (int fd) +create_file_event (gdb_fildes_t fd) { gdb_event *file_event_ptr; Index: src/gdb/gdbserver/remote-utils.c =================================================================== --- src.orig/gdb/gdbserver/remote-utils.c 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/remote-utils.c 2010-08-27 16:21:22.000000000 +0100 @@ -107,8 +107,8 @@ struct sym_cache int remote_debug = 0; struct ui_file *gdb_stdlog; -static int remote_desc = INVALID_DESCRIPTOR; -static int listen_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; /* FIXME headerize? */ extern int using_threads; Index: src/gdb/gdbserver/server.h =================================================================== --- src.orig/gdb/gdbserver/server.h 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/server.h 2010-08-27 16:27:02.000000000 +0100 @@ -334,13 +334,19 @@ extern int disable_packet_qfThreadInfo; extern int multi_process; extern int non_stop; +#if USE_WIN32API +typedef SOCKET gdb_fildes_t; +#else +typedef int gdb_fildes_t; +#endif + /* Functions from event-loop.c. */ typedef void *gdb_client_data; typedef int (handler_func) (int, gdb_client_data); typedef int (callback_handler_func) (gdb_client_data); -extern void delete_file_handler (int fd); -extern void add_file_handler (int fd, handler_func *proc, +extern void delete_file_handler (gdb_fildes_t fd); +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, gdb_client_data client_data); extern int append_callback_event (callback_handler_func *proc, gdb_client_data client_data); @@ -473,6 +479,7 @@ char *paddress (CORE_ADDR addr); char *pulongest (ULONGEST u); char *plongest (LONGEST l); char *phex_nz (ULONGEST l, int sizeof_l); +char *pfildes (gdb_fildes_t fd); #define gdb_assert(expr) \ ((void) ((expr) ? 0 : \ Index: src/gdb/gdbserver/utils.c =================================================================== --- src.orig/gdb/gdbserver/utils.c 2010-07-21 19:13:37.000000000 +0100 +++ src/gdb/gdbserver/utils.c 2010-08-27 16:30:51.000000000 +0100 @@ -370,3 +370,15 @@ paddress (CORE_ADDR addr) { return phex_nz (addr, sizeof (CORE_ADDR)); } + +/* Convert a file descriptor into a printable string. */ + +char * +pfildes (gdb_fildes_t fd) +{ +#if USE_WIN32API + return phex_nz (fd, sizeof (gdb_fildes_t)); +#else + return plongest (fd); +#endif +} ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdbserver with -Werror, win64 socket type 2010-08-27 15:34 ` Pedro Alves @ 2010-08-27 15:46 ` Ozkan Sezer 2010-08-27 16:06 ` Pedro Alves 0 siblings, 1 reply; 7+ messages in thread From: Ozkan Sezer @ 2010-08-27 15:46 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On Fri, Aug 27, 2010 at 6:34 PM, Pedro Alves <pedro@codesourcery.com> wrote: > On Friday 27 August 2010 16:09:37, Ozkan Sezer wrote: >> Hi Pedro, thanks for looking into this, > > >> > s/gdb/gdbserver, and there is actually no such assumption. The mingw >> >> Not exactly correct, see gdb/serial.h, struct serial where fd is int type >> and is used socket() for assigning its data. > > Note the "s/gdb/gdbserver". > Speaking only for gdbserver, OK. >> ... I get these: >> >> ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'handle_file_event': >> ../../../gdb-cvs/gdb/gdbserver/event-loop.c:476: error: format '%d' >> expects type 'int', but argument 3 has type 'gdb_fildes_t' >> ../../../gdb-cvs/gdb/gdbserver/event-loop.c: In function 'create_file_event': >> ../../../gdb-cvs/gdb/gdbserver/event-loop.c:511: error: assignment >> from incompatible pointer type > > Try this version. If this still fails, please use "make -k" so that we > see the most errors as possible in one run. > > -- > Pedro Alves > > --- > gdb/gdbserver/event-loop.c | 23 ++++++++++++----------- > gdb/gdbserver/remote-utils.c | 4 ++-- > gdb/gdbserver/server.h | 11 +++++++++-- > gdb/gdbserver/utils.c | 12 ++++++++++++ > 4 files changed, 35 insertions(+), 15 deletions(-) > > Index: src/gdb/gdbserver/event-loop.c > =================================================================== > --- src.orig/gdb/gdbserver/event-loop.c 2010-08-27 15:58:56.000000000 +0100 > +++ src/gdb/gdbserver/event-loop.c 2010-08-27 16:28:18.000000000 +0100 > @@ -39,7 +39,7 @@ > #endif > > typedef struct gdb_event gdb_event; > -typedef int (event_handler_func) (int); > +typedef int (event_handler_func) (gdb_fildes_t); > > /* Tell create_file_handler what events we are interested in. */ > > @@ -64,7 +64,7 @@ struct gdb_event > event_handler_func *proc; > > /* File descriptor that is ready. */ > - int fd; > + gdb_fildes_t fd; > > /* Next in list of events or NULL. */ > struct gdb_event *next_event; > @@ -76,7 +76,7 @@ struct gdb_event > typedef struct file_handler > { > /* File descriptor. */ > - int fd; > + gdb_fildes_t fd; > > /* Events we want to monitor. */ > int mask; > @@ -202,7 +202,7 @@ process_event (void) > { > gdb_event *event_ptr, *prev_ptr; > event_handler_func *proc; > - int fd; > + gdb_fildes_t fd; > > /* Look in the event queue to find an event that is ready > to be processed. */ > @@ -332,7 +332,7 @@ process_callback (void) > occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ > > static void > -create_file_handler (int fd, int mask, handler_func *proc, > +create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc, > gdb_client_data client_data) > { > file_handler *file_ptr; > @@ -382,7 +382,8 @@ create_file_handler (int fd, int mask, h > /* Wrapper function for create_file_handler. */ > > void > -add_file_handler (int fd, handler_func *proc, gdb_client_data client_data) > +add_file_handler (gdb_fildes_t fd, > + handler_func *proc, gdb_client_data client_data) > { > create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data); > } > @@ -391,7 +392,7 @@ add_file_handler (int fd, handler_func * > i.e. we don't care anymore about events on the FD. */ > > void > -delete_file_handler (int fd) > +delete_file_handler (gdb_fildes_t fd) > { > file_handler *file_ptr, *prev_ptr = NULL; > int i; > @@ -454,7 +455,7 @@ delete_file_handler (int fd) > event in the front of the event queue. */ > > static int > -handle_file_event (int event_file_desc) > +handle_file_event (gdb_fildes_t event_file_desc) > { > file_handler *file_ptr; > int mask; > @@ -471,8 +472,8 @@ handle_file_event (int event_file_desc) > > if (file_ptr->ready_mask & GDB_EXCEPTION) > { > - fprintf (stderr, "Exception condition detected on fd %d\n", > - file_ptr->fd); > + fprintf (stderr, "Exception condition detected on fd %s\n", > + pfildes (file_ptr->fd)); > file_ptr->error = 1; > } > else > @@ -502,7 +503,7 @@ handle_file_event (int event_file_desc) > associated to FD when it was registered with the event loop. */ > > static gdb_event * > -create_file_event (int fd) > +create_file_event (gdb_fildes_t fd) > { > gdb_event *file_event_ptr; > > Index: src/gdb/gdbserver/remote-utils.c > =================================================================== > --- src.orig/gdb/gdbserver/remote-utils.c 2010-08-27 15:58:56.000000000 +0100 > +++ src/gdb/gdbserver/remote-utils.c 2010-08-27 16:21:22.000000000 +0100 > @@ -107,8 +107,8 @@ struct sym_cache > int remote_debug = 0; > struct ui_file *gdb_stdlog; > > -static int remote_desc = INVALID_DESCRIPTOR; > -static int listen_desc = INVALID_DESCRIPTOR; > +static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; > +static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; > > /* FIXME headerize? */ > extern int using_threads; > Index: src/gdb/gdbserver/server.h > =================================================================== > --- src.orig/gdb/gdbserver/server.h 2010-08-27 15:58:56.000000000 +0100 > +++ src/gdb/gdbserver/server.h 2010-08-27 16:27:02.000000000 +0100 > @@ -334,13 +334,19 @@ extern int disable_packet_qfThreadInfo; > extern int multi_process; > extern int non_stop; > > +#if USE_WIN32API > +typedef SOCKET gdb_fildes_t; > +#else > +typedef int gdb_fildes_t; > +#endif > + > /* Functions from event-loop.c. */ > typedef void *gdb_client_data; > typedef int (handler_func) (int, gdb_client_data); > typedef int (callback_handler_func) (gdb_client_data); > > -extern void delete_file_handler (int fd); > -extern void add_file_handler (int fd, handler_func *proc, > +extern void delete_file_handler (gdb_fildes_t fd); > +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, > gdb_client_data client_data); > extern int append_callback_event (callback_handler_func *proc, > gdb_client_data client_data); > @@ -473,6 +479,7 @@ char *paddress (CORE_ADDR addr); > char *pulongest (ULONGEST u); > char *plongest (LONGEST l); > char *phex_nz (ULONGEST l, int sizeof_l); > +char *pfildes (gdb_fildes_t fd); > > #define gdb_assert(expr) \ > ((void) ((expr) ? 0 : \ > Index: src/gdb/gdbserver/utils.c > =================================================================== > --- src.orig/gdb/gdbserver/utils.c 2010-07-21 19:13:37.000000000 +0100 > +++ src/gdb/gdbserver/utils.c 2010-08-27 16:30:51.000000000 +0100 > @@ -370,3 +370,15 @@ paddress (CORE_ADDR addr) > { > return phex_nz (addr, sizeof (CORE_ADDR)); > } > + > +/* Convert a file descriptor into a printable string. */ > + > +char * > +pfildes (gdb_fildes_t fd) > +{ > +#if USE_WIN32API > + return phex_nz (fd, sizeof (gdb_fildes_t)); > +#else > + return plongest (fd); > +#endif > +} > In file included from version.c:1: ../../../gdb-cvs/gdb/gdbserver/server.h:338: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'gdb_fildes_t' ../../../gdb-cvs/gdb/gdbserver/server.h:348: error: expected ')' before 'fd' ../../../gdb-cvs/gdb/gdbserver/server.h:349: error: expected ')' before 'fd' ../../../gdb-cvs/gdb/gdbserver/server.h:482: error: expected ')' before 'fd' This can be fixed by inserting an #include <winsock2.h> before the gdb_fildes_t typedefinition in server.h. After doing this, the build reaches completion without errors. Of you want, I can send my full build logs, -- Ozkan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdbserver with -Werror, win64 socket type 2010-08-27 15:46 ` Ozkan Sezer @ 2010-08-27 16:06 ` Pedro Alves 2010-08-27 16:12 ` Ozkan Sezer 0 siblings, 1 reply; 7+ messages in thread From: Pedro Alves @ 2010-08-27 16:06 UTC (permalink / raw) To: gdb-patches; +Cc: Ozkan Sezer On Friday 27 August 2010 16:46:02, Ozkan Sezer wrote: > On Fri, Aug 27, 2010 at 6:34 PM, Pedro Alves <pedro@codesourcery.com> wrote: > > Note the "s/gdb/gdbserver". > > Speaking only for gdbserver, OK. Yeah, that's usual sed-like-speak for, "if you substitute gdb for gdbserver in your statement above, ...". Sorry for not being clear. > > In file included from version.c:1: > ../../../gdb-cvs/gdb/gdbserver/server.h:338: error: expected '=', ',', > ';', 'asm' or '__attribute__' before 'gdb_fildes_t' > ../../../gdb-cvs/gdb/gdbserver/server.h:348: error: expected ')' before 'fd' > ../../../gdb-cvs/gdb/gdbserver/server.h:349: error: expected ')' before 'fd' > ../../../gdb-cvs/gdb/gdbserver/server.h:482: error: expected ')' before 'fd' > > This can be fixed by inserting an #include <winsock2.h> before the > gdb_fildes_t typedefinition in server.h. After doing this, the build reaches > completion without errors. Thanks, I guess we can live with that. I've done that change, and applied the patch, as below. > Of you want, I can send my full build logs, No need. Let me know if something is still not right. -- Pedro Alves 2010-08-27 Pedro Alves <pedro@codesourcery.com> * event-loop.c (event_handle_func): Adjust to use gdb_fildes_t. (struct gdb_event) <fd>: Change type to gdb_fildes_t. (struct file_handler) <fd>: Change type to gdb_fildes_t. (process_event): Change local fd's type to gdb_fildes_t. (create_file_handler): Adjust prototype. (delete_file_handler): Adjust prototype. (handle_file_event): Adjust prototype. Use pfildes. (create_file_event): Adjsut prototype. * remote-utils.c (remote_desc, listen_desc): Change type to gdb_fildes_t. * server.h: New gdb_fildes_t typedef. [USE_WIN32API]: Include winsock2.h. (delete_file_handler, add_file_handler): Adjust prototypes. (pfildes): Declare. * utils.c (pfildes): New. --- gdb/gdbserver/event-loop.c | 23 ++++++++++++----------- gdb/gdbserver/remote-utils.c | 4 ++-- gdb/gdbserver/server.h | 12 ++++++++++-- gdb/gdbserver/utils.c | 12 ++++++++++++ 4 files changed, 36 insertions(+), 15 deletions(-) Index: src/gdb/gdbserver/event-loop.c =================================================================== --- src.orig/gdb/gdbserver/event-loop.c 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/event-loop.c 2010-08-27 16:28:18.000000000 +0100 @@ -39,7 +39,7 @@ #endif typedef struct gdb_event gdb_event; -typedef int (event_handler_func) (int); +typedef int (event_handler_func) (gdb_fildes_t); /* Tell create_file_handler what events we are interested in. */ @@ -64,7 +64,7 @@ struct gdb_event event_handler_func *proc; /* File descriptor that is ready. */ - int fd; + gdb_fildes_t fd; /* Next in list of events or NULL. */ struct gdb_event *next_event; @@ -76,7 +76,7 @@ struct gdb_event typedef struct file_handler { /* File descriptor. */ - int fd; + gdb_fildes_t fd; /* Events we want to monitor. */ int mask; @@ -202,7 +202,7 @@ process_event (void) { gdb_event *event_ptr, *prev_ptr; event_handler_func *proc; - int fd; + gdb_fildes_t fd; /* Look in the event queue to find an event that is ready to be processed. */ @@ -332,7 +332,7 @@ process_callback (void) occurs for FD. CLIENT_DATA is the argument to pass to PROC. */ static void -create_file_handler (int fd, int mask, handler_func *proc, +create_file_handler (gdb_fildes_t fd, int mask, handler_func *proc, gdb_client_data client_data) { file_handler *file_ptr; @@ -382,7 +382,8 @@ create_file_handler (int fd, int mask, h /* Wrapper function for create_file_handler. */ void -add_file_handler (int fd, handler_func *proc, gdb_client_data client_data) +add_file_handler (gdb_fildes_t fd, + handler_func *proc, gdb_client_data client_data) { create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION, proc, client_data); } @@ -391,7 +392,7 @@ add_file_handler (int fd, handler_func * i.e. we don't care anymore about events on the FD. */ void -delete_file_handler (int fd) +delete_file_handler (gdb_fildes_t fd) { file_handler *file_ptr, *prev_ptr = NULL; int i; @@ -454,7 +455,7 @@ delete_file_handler (int fd) event in the front of the event queue. */ static int -handle_file_event (int event_file_desc) +handle_file_event (gdb_fildes_t event_file_desc) { file_handler *file_ptr; int mask; @@ -471,8 +472,8 @@ handle_file_event (int event_file_desc) if (file_ptr->ready_mask & GDB_EXCEPTION) { - fprintf (stderr, "Exception condition detected on fd %d\n", - file_ptr->fd); + fprintf (stderr, "Exception condition detected on fd %s\n", + pfildes (file_ptr->fd)); file_ptr->error = 1; } else @@ -502,7 +503,7 @@ handle_file_event (int event_file_desc) associated to FD when it was registered with the event loop. */ static gdb_event * -create_file_event (int fd) +create_file_event (gdb_fildes_t fd) { gdb_event *file_event_ptr; Index: src/gdb/gdbserver/remote-utils.c =================================================================== --- src.orig/gdb/gdbserver/remote-utils.c 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/remote-utils.c 2010-08-27 16:21:22.000000000 +0100 @@ -107,8 +107,8 @@ struct sym_cache int remote_debug = 0; struct ui_file *gdb_stdlog; -static int remote_desc = INVALID_DESCRIPTOR; -static int listen_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; /* FIXME headerize? */ extern int using_threads; Index: src/gdb/gdbserver/server.h =================================================================== --- src.orig/gdb/gdbserver/server.h 2010-08-27 15:58:56.000000000 +0100 +++ src/gdb/gdbserver/server.h 2010-08-27 16:55:30.000000000 +0100 @@ -334,13 +334,20 @@ extern int disable_packet_qfThreadInfo; extern int multi_process; extern int non_stop; +#if USE_WIN32API +#include <winsock2.h> +typedef SOCKET gdb_fildes_t; +#else +typedef int gdb_fildes_t; +#endif + /* Functions from event-loop.c. */ typedef void *gdb_client_data; typedef int (handler_func) (int, gdb_client_data); typedef int (callback_handler_func) (gdb_client_data); -extern void delete_file_handler (int fd); -extern void add_file_handler (int fd, handler_func *proc, +extern void delete_file_handler (gdb_fildes_t fd); +extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, gdb_client_data client_data); extern int append_callback_event (callback_handler_func *proc, gdb_client_data client_data); @@ -473,6 +480,7 @@ char *paddress (CORE_ADDR addr); char *pulongest (ULONGEST u); char *plongest (LONGEST l); char *phex_nz (ULONGEST l, int sizeof_l); +char *pfildes (gdb_fildes_t fd); #define gdb_assert(expr) \ ((void) ((expr) ? 0 : \ Index: src/gdb/gdbserver/utils.c =================================================================== --- src.orig/gdb/gdbserver/utils.c 2010-07-21 19:13:37.000000000 +0100 +++ src/gdb/gdbserver/utils.c 2010-08-27 16:30:51.000000000 +0100 @@ -370,3 +370,15 @@ paddress (CORE_ADDR addr) { return phex_nz (addr, sizeof (CORE_ADDR)); } + +/* Convert a file descriptor into a printable string. */ + +char * +pfildes (gdb_fildes_t fd) +{ +#if USE_WIN32API + return phex_nz (fd, sizeof (gdb_fildes_t)); +#else + return plongest (fd); +#endif +} ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: gdbserver with -Werror, win64 socket type 2010-08-27 16:06 ` Pedro Alves @ 2010-08-27 16:12 ` Ozkan Sezer 0 siblings, 0 replies; 7+ messages in thread From: Ozkan Sezer @ 2010-08-27 16:12 UTC (permalink / raw) To: Pedro Alves; +Cc: gdb-patches On Fri, Aug 27, 2010 at 7:06 PM, Pedro Alves <pedro@codesourcery.com> wrote: > On Friday 27 August 2010 16:46:02, Ozkan Sezer wrote: >> On Fri, Aug 27, 2010 at 6:34 PM, Pedro Alves <pedro@codesourcery.com> wrote: >> > Note the "s/gdb/gdbserver". >> >> Speaking only for gdbserver, OK. > > Yeah, that's usual sed-like-speak for, > "if you substitute gdb for gdbserver in your statement above, ...". > Sorry for not being clear. > >> >> In file included from version.c:1: >> ../../../gdb-cvs/gdb/gdbserver/server.h:338: error: expected '=', ',', >> ';', 'asm' or '__attribute__' before 'gdb_fildes_t' >> ../../../gdb-cvs/gdb/gdbserver/server.h:348: error: expected ')' before 'fd' >> ../../../gdb-cvs/gdb/gdbserver/server.h:349: error: expected ')' before 'fd' >> ../../../gdb-cvs/gdb/gdbserver/server.h:482: error: expected ')' before 'fd' >> >> This can be fixed by inserting an #include <winsock2.h> before the >> gdb_fildes_t typedefinition in server.h. After doing this, the build reaches >> completion without errors. > > Thanks, I guess we can live with that. I've done that change, and applied > the patch, as below. > Thank you very much. >> Of you want, I can send my full build logs, > > No need. Let me know if something is still not right. > Things seem OK for now. Someday, gdb itself will need proper adjustments for SOCKET type, but that's for another time. Thanks again. > -- > Pedro Alves > -- 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).