This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Windows sockets
- From: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- To: mark at codesourcery dot com
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sat, 26 Mar 2005 09:45:47 +0100 (CET)
- Subject: Re: PATCH: Windows sockets
- References: <200503260127.j2Q1R59a022152@sethra.codesourcery.com>
Date: Fri, 25 Mar 2005 17:27:05 -0800
From: Mark Mitchell <mark@codesourcery.com>
Here's the first "interesting" patch for Windows support. This patch
modifies ser-tcp.c to support Windows, so that we can use a GDB
running on Windows to talk to a gdbserver process.
Yikes. This is real ugly and I'm not too happy about this.
Here is a sumary of the changes in this patch:
1. Link with -lws2_32 on MinGW so we can use sockets.
Can't you just use a standard autoconf check to check for that library
instead of hardcoding it to be linked in on MinGW?
2. In defs.h, define WINAPI so that source files know whether they are
supposed to use the Windows API.
This is bad. Yet another #ifdef WINDHOOS when we really are trying to
get rid of those.
3. Move ser_unix_readchar and friends (which were only barely
UNIX-specific) into ser-base.c, renaming appropriately.
Fair enough.
4. Add a new member (read_prim) to struct serial_ops, and use it from
ser_base_readchar. The reason for this is that sockets must be
read with "recv" on Windows; plain "read" does not work. So, we
need a way to indicate which low-level primitive to use to read
from a file descriptor.
But write(2) does work and you don't need to use send(2). Oh you do
but things are not quite symmetric. Could you fix that? Isn't it a
better idea to change the #ifdef WINAPI in a #ifdef HAVE_RECV, add an
autoconf check for recv(2), and always prefer it over read(2) if
available for reading from a socket?
5. Make a handful of minor changes to ter-tcp.c to account for
differences in the BSD and Windows sockets APIs.
You mean that Windows doesn't have the proper BSD socket API even
though Microsoft stole^Wused the BSD TCP stack?
I really think these changes are too pervasive and that you really
need to create a ser-win32.c that has all the Windows-specific cruft
in it.
6. Tweak safe_strerror to deal with Windows sockets error codes.
I'm defenitely not thrilled by this tweak. You're only changing
"undocumented" into "winsock". I presume it helps with debugging this
stuff, but is it really worth the clutter it adds?
Sorry,
Mark