From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fk0SG-0003Nc-S6 for qemu-devel@nongnu.org; Sat, 27 May 2006 11:11:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fk0SF-0003N9-5c for qemu-devel@nongnu.org; Sat, 27 May 2006 11:11:52 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fk0SF-0003N5-12 for qemu-devel@nongnu.org; Sat, 27 May 2006 11:11:51 -0400 Received: from [147.11.1.11] (helo=mail.wrs.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fk0XN-0000t4-0R for qemu-devel@nongnu.org; Sat, 27 May 2006 11:17:09 -0400 Received: from ala-mail04.corp.ad.wrs.com (ala-mail04 [147.11.57.145]) by mail.wrs.com (8.13.6/8.13.3) with ESMTP id k4RFBlU0019304 for ; Sat, 27 May 2006 08:11:48 -0700 (PDT) Message-ID: <44786C31.6060200@windriver.com> Date: Sat, 27 May 2006 10:11:45 -0500 From: Jason Wessel MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050702090007010009020203" Subject: [Qemu-devel] gdb-stub support for Win32 host Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------050702090007010009020203 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This patch adds support for the gdb-stub to work on the Win32 host and compile in by default. I retested to make sure everything was compatible so as not to break the unix side. signed-off-by: jason.wessel@windriver.com Thanks, Jason. --------------050702090007010009020203 Content-Type: text/plain; name="gdb-stub-win32.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-stub-win32.patch" Index: qemu/configure =================================================================== --- qemu.orig/configure +++ qemu/configure @@ -312,7 +312,6 @@ fi if test "$mingw32" = "yes" ; then linux="no" EXESUF=".exe" - gdbstub="no" oss="no" if [ "$cpu" = "i386" ] ; then kqemu="yes" Index: qemu/gdbstub.c =================================================================== --- qemu.orig/gdbstub.c +++ qemu/gdbstub.c @@ -30,10 +30,22 @@ #include "vl.h" #endif +#ifndef _WIN32 #include #include #include #include +#else +#include +#include +typedef unsigned int socklen_t; +#ifndef SIGTRAP +#define SIGTRAP 5 +#endif +#ifndef SIGINT +#define SIGINT 2 +#endif +#endif //#define DEBUG_GDB @@ -69,7 +81,7 @@ static int get_char(GDBState *s) int ret; for(;;) { - ret = read(s->fd, &ch, 1); + ret = recv(s->fd, &ch, 1, 0); if (ret < 0) { if (errno != EINTR && errno != EAGAIN) return -1; @@ -87,7 +99,7 @@ static void put_buffer(GDBState *s, cons int ret; while (len > 0) { - ret = write(s->fd, buf, len); + ret = send(s->fd, buf, len, 0); if (ret < 0) { if (errno != EINTR && errno != EAGAIN) return; @@ -829,7 +841,7 @@ static void gdb_read(void *opaque) int i, size; uint8_t buf[4096]; - size = read(s->fd, buf, sizeof(buf)); + size = recv(s->fd, buf, sizeof(buf), 0); if (size < 0) return; if (size == 0) { @@ -866,7 +878,7 @@ static void gdb_accept(void *opaque) /* set short latency */ val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); #ifdef CONFIG_USER_ONLY s = &gdbserver_state; @@ -881,7 +893,14 @@ static void gdb_accept(void *opaque) s->env = first_cpu; /* XXX: allow to change CPU */ s->fd = fd; +#ifndef _WIN32 fcntl(fd, F_SETFL, O_NONBLOCK); +#else + { + unsigned long tmp = 1; + ioctlsocket (fd, FIONBIO, &tmp); + } +#endif #ifndef CONFIG_USER_ONLY /* stop the VM */ @@ -907,7 +926,7 @@ static int gdbserver_open(int port) /* allow fast reuse */ val = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)); + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)); sockaddr.sin_family = AF_INET; sockaddr.sin_port = htons(port); @@ -923,7 +942,14 @@ static int gdbserver_open(int port) return -1; } #ifndef CONFIG_USER_ONLY +#ifndef _WIN32 fcntl(fd, F_SETFL, O_NONBLOCK); +#else + { + unsigned long tmp = 1; + ioctlsocket (fd, FIONBIO, &tmp); + } +#endif #endif return fd; } --------------050702090007010009020203--