[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] gdb-stub support for Win32 host
From: |
Jason Wessel |
Subject: |
[Qemu-devel] gdb-stub support for Win32 host |
Date: |
Sat, 27 May 2006 10:11:45 -0500 |
User-agent: |
Thunderbird 1.5.0.2 (Windows/20060308) |
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: address@hidden
Thanks,
Jason.
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 <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <signal.h>
+#else
+#include <windows.h>
+#include <io.h>
+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;
}
- [Qemu-devel] gdb-stub support for Win32 host,
Jason Wessel <=