X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=gdbstub.c;h=ecea8c42cffd871544b05f3097f3b431a3f797e7;hb=6b39b06339ee59559b31f860d4af635b046322df;hp=0e431fd4dfcd22f7a89fede84fc6f0ac1f5f0f36;hpb=f348b6d1a53e5271cf1c9f9acc4646b4b98c1771;p=mirror_qemu.git diff --git a/gdbstub.c b/gdbstub.c index 0e431fd4df..ecea8c42cf 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -19,7 +19,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/cutils.h" - +#include "cpu.h" #ifdef CONFIG_USER_ONLY #include "qemu.h" #else @@ -35,6 +35,7 @@ #include "qemu/sockets.h" #include "sysemu/kvm.h" #include "exec/semihost.h" +#include "exec/exec-all.h" #ifdef CONFIG_USER_ONLY #define GDB_ATTACHED "0" @@ -332,7 +333,7 @@ static int get_char(GDBState *s) if (ret < 0) { if (errno == ECONNRESET) s->fd = -1; - if (errno != EINTR && errno != EAGAIN) + if (errno != EINTR) return -1; } else if (ret == 0) { close(s->fd); @@ -393,7 +394,7 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) while (len > 0) { ret = send(s->fd, buf, len, 0); if (ret < 0) { - if (errno != EINTR && errno != EAGAIN) + if (errno != EINTR) return; } else { buf += ret; @@ -401,7 +402,9 @@ static void put_buffer(GDBState *s, const uint8_t *buf, int len) } } #else - qemu_chr_fe_write(s->chr, buf, len); + /* XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks */ + qemu_chr_fe_write_all(s->chr, buf, len); #endif } @@ -1492,19 +1495,6 @@ void gdb_exit(CPUArchState *env, int code) } #ifdef CONFIG_USER_ONLY -int -gdb_queuesig (void) -{ - GDBState *s; - - s = gdbserver_state; - - if (gdbserver_fd < 0 || s->fd < 0) - return 0; - else - return 1; -} - int gdb_handlesig(CPUState *cpu, int sig) { @@ -1542,9 +1532,13 @@ gdb_handlesig(CPUState *cpu, int sig) for (i = 0; i < n; i++) { gdb_read_byte(s, buf[i]); } - } else if (n == 0 || errno != EAGAIN) { + } else { /* XXX: Connection closed. Should probably wait for another connection before continuing. */ + if (n == 0) { + close(s->fd); + } + s->fd = -1; return sig; } } @@ -1599,8 +1593,6 @@ static void gdb_accept(void) gdb_has_xml = false; gdbserver_state = s; - - fcntl(fd, F_SETFL, O_NONBLOCK); } static int gdbserver_open(int port) @@ -1628,7 +1620,7 @@ static int gdbserver_open(int port) close(fd); return -1; } - ret = listen(fd, 0); + ret = listen(fd, 1); if (ret < 0) { perror("listen"); close(fd);