Commit 8f447cc753ac5f095be3cd9c404bf590319bc696
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,7 +312,6 @@ fi | ||
| 312 | if test "$mingw32" = "yes" ; then | 312 | if test "$mingw32" = "yes" ; then |
| 313 | linux="no" | 313 | linux="no" |
| 314 | EXESUF=".exe" | 314 | EXESUF=".exe" |
| 315 | - gdbstub="no" | ||
| 316 | oss="no" | 315 | oss="no" |
| 317 | if [ "$cpu" = "i386" ] ; then | 316 | if [ "$cpu" = "i386" ] ; then |
| 318 | kqemu="yes" | 317 | kqemu="yes" |
gdbstub.c
| @@ -30,10 +30,18 @@ | @@ -30,10 +30,18 @@ | ||
| 30 | #include "vl.h" | 30 | #include "vl.h" |
| 31 | #endif | 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 | #include <signal.h> | 43 | #include <signal.h> |
| 44 | +#endif | ||
| 37 | 45 | ||
| 38 | //#define DEBUG_GDB | 46 | //#define DEBUG_GDB |
| 39 | 47 | ||
| @@ -69,7 +77,7 @@ static int get_char(GDBState *s) | @@ -69,7 +77,7 @@ static int get_char(GDBState *s) | ||
| 69 | int ret; | 77 | int ret; |
| 70 | 78 | ||
| 71 | for(;;) { | 79 | for(;;) { |
| 72 | - ret = read(s->fd, &ch, 1); | 80 | + ret = recv(s->fd, &ch, 1, 0); |
| 73 | if (ret < 0) { | 81 | if (ret < 0) { |
| 74 | if (errno != EINTR && errno != EAGAIN) | 82 | if (errno != EINTR && errno != EAGAIN) |
| 75 | return -1; | 83 | return -1; |
| @@ -87,7 +95,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) | @@ -87,7 +95,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) | ||
| 87 | int ret; | 95 | int ret; |
| 88 | 96 | ||
| 89 | while (len > 0) { | 97 | while (len > 0) { |
| 90 | - ret = write(s->fd, buf, len); | 98 | + ret = send(s->fd, buf, len, 0); |
| 91 | if (ret < 0) { | 99 | if (ret < 0) { |
| 92 | if (errno != EINTR && errno != EAGAIN) | 100 | if (errno != EINTR && errno != EAGAIN) |
| 93 | return; | 101 | return; |
| @@ -829,7 +837,7 @@ static void gdb_read(void *opaque) | @@ -829,7 +837,7 @@ static void gdb_read(void *opaque) | ||
| 829 | int i, size; | 837 | int i, size; |
| 830 | uint8_t buf[4096]; | 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 | if (size < 0) | 841 | if (size < 0) |
| 834 | return; | 842 | return; |
| 835 | if (size == 0) { | 843 | if (size == 0) { |
| @@ -866,7 +874,7 @@ static void gdb_accept(void *opaque) | @@ -866,7 +874,7 @@ static void gdb_accept(void *opaque) | ||
| 866 | 874 | ||
| 867 | /* set short latency */ | 875 | /* set short latency */ |
| 868 | val = 1; | 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 | #ifdef CONFIG_USER_ONLY | 879 | #ifdef CONFIG_USER_ONLY |
| 872 | s = &gdbserver_state; | 880 | s = &gdbserver_state; |
| @@ -881,9 +889,11 @@ static void gdb_accept(void *opaque) | @@ -881,9 +889,11 @@ static void gdb_accept(void *opaque) | ||
| 881 | s->env = first_cpu; /* XXX: allow to change CPU */ | 889 | s->env = first_cpu; /* XXX: allow to change CPU */ |
| 882 | s->fd = fd; | 890 | s->fd = fd; |
| 883 | 891 | ||
| 892 | +#ifdef CONFIG_USER_ONLY | ||
| 884 | fcntl(fd, F_SETFL, O_NONBLOCK); | 893 | fcntl(fd, F_SETFL, O_NONBLOCK); |
| 894 | +#else | ||
| 895 | + socket_set_nonblock(fd); | ||
| 885 | 896 | ||
| 886 | -#ifndef CONFIG_USER_ONLY | ||
| 887 | /* stop the VM */ | 897 | /* stop the VM */ |
| 888 | vm_stop(EXCP_INTERRUPT); | 898 | vm_stop(EXCP_INTERRUPT); |
| 889 | 899 | ||
| @@ -907,7 +917,7 @@ static int gdbserver_open(int port) | @@ -907,7 +917,7 @@ static int gdbserver_open(int port) | ||
| 907 | 917 | ||
| 908 | /* allow fast reuse */ | 918 | /* allow fast reuse */ |
| 909 | val = 1; | 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 | sockaddr.sin_family = AF_INET; | 922 | sockaddr.sin_family = AF_INET; |
| 913 | sockaddr.sin_port = htons(port); | 923 | sockaddr.sin_port = htons(port); |
| @@ -923,7 +933,7 @@ static int gdbserver_open(int port) | @@ -923,7 +933,7 @@ static int gdbserver_open(int port) | ||
| 923 | return -1; | 933 | return -1; |
| 924 | } | 934 | } |
| 925 | #ifndef CONFIG_USER_ONLY | 935 | #ifndef CONFIG_USER_ONLY |
| 926 | - fcntl(fd, F_SETFL, O_NONBLOCK); | 936 | + socket_set_nonblock(fd); |
| 927 | #endif | 937 | #endif |
| 928 | return fd; | 938 | return fd; |
| 929 | } | 939 | } |