Commit 8f447cc753ac5f095be3cd9c404bf590319bc696

Authored by bellard
1 parent eda9b09b

gdb stub for win32


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1972 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 20 additions and 11 deletions
configure
... ... @@ -312,7 +312,6 @@ fi
312 312 if test "$mingw32" = "yes" ; then
313 313 linux="no"
314 314 EXESUF=".exe"
315   - gdbstub="no"
316 315 oss="no"
317 316 if [ "$cpu" = "i386" ] ; then
318 317 kqemu="yes"
... ...
gdbstub.c
... ... @@ -30,10 +30,18 @@
30 30 #include "vl.h"
31 31 #endif
32 32  
33   -#include <sys/socket.h>
34   -#include <netinet/in.h>
35   -#include <netinet/tcp.h>
  33 +#include "qemu_socket.h"
  34 +#ifdef _WIN32
  35 +/* XXX: these constants may be independent of the host ones even for Unix */
  36 +#ifndef SIGTRAP
  37 +#define SIGTRAP 5
  38 +#endif
  39 +#ifndef SIGINT
  40 +#define SIGINT 2
  41 +#endif
  42 +#else
36 43 #include <signal.h>
  44 +#endif
37 45  
38 46 //#define DEBUG_GDB
39 47  
... ... @@ -69,7 +77,7 @@ static int get_char(GDBState *s)
69 77 int ret;
70 78  
71 79 for(;;) {
72   - ret = read(s->fd, &ch, 1);
  80 + ret = recv(s->fd, &ch, 1, 0);
73 81 if (ret < 0) {
74 82 if (errno != EINTR && errno != EAGAIN)
75 83 return -1;
... ... @@ -87,7 +95,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len)
87 95 int ret;
88 96  
89 97 while (len > 0) {
90   - ret = write(s->fd, buf, len);
  98 + ret = send(s->fd, buf, len, 0);
91 99 if (ret < 0) {
92 100 if (errno != EINTR && errno != EAGAIN)
93 101 return;
... ... @@ -829,7 +837,7 @@ static void gdb_read(void *opaque)
829 837 int i, size;
830 838 uint8_t buf[4096];
831 839  
832   - size = read(s->fd, buf, sizeof(buf));
  840 + size = recv(s->fd, buf, sizeof(buf), 0);
833 841 if (size < 0)
834 842 return;
835 843 if (size == 0) {
... ... @@ -866,7 +874,7 @@ static void gdb_accept(void *opaque)
866 874  
867 875 /* set short latency */
868 876 val = 1;
869   - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
  877 + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
870 878  
871 879 #ifdef CONFIG_USER_ONLY
872 880 s = &gdbserver_state;
... ... @@ -881,9 +889,11 @@ static void gdb_accept(void *opaque)
881 889 s->env = first_cpu; /* XXX: allow to change CPU */
882 890 s->fd = fd;
883 891  
  892 +#ifdef CONFIG_USER_ONLY
884 893 fcntl(fd, F_SETFL, O_NONBLOCK);
  894 +#else
  895 + socket_set_nonblock(fd);
885 896  
886   -#ifndef CONFIG_USER_ONLY
887 897 /* stop the VM */
888 898 vm_stop(EXCP_INTERRUPT);
889 899  
... ... @@ -907,7 +917,7 @@ static int gdbserver_open(int port)
907 917  
908 918 /* allow fast reuse */
909 919 val = 1;
910   - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
  920 + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
911 921  
912 922 sockaddr.sin_family = AF_INET;
913 923 sockaddr.sin_port = htons(port);
... ... @@ -923,7 +933,7 @@ static int gdbserver_open(int port)
923 933 return -1;
924 934 }
925 935 #ifndef CONFIG_USER_ONLY
926   - fcntl(fd, F_SETFL, O_NONBLOCK);
  936 + socket_set_nonblock(fd);
927 937 #endif
928 938 return fd;
929 939 }
... ...