diff options
author | Peter Wu <peter@lekensteyn.nl> | 2016-06-05 16:35:48 +0200 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-06-06 11:15:54 +0100 |
commit | 5819e3e072f41cbf81ad80d822a5c468a91f54e0 (patch) | |
tree | d1da050ae4b9e78f1b0fbfd06f10b0934d7d9a39 | |
parent | de5dca1b792ada25c29a95c8f84e01f4300aef9c (diff) | |
download | qemu-5819e3e072f41cbf81ad80d822a5c468a91f54e0.tar.gz qemu-5819e3e072f41cbf81ad80d822a5c468a91f54e0.tar.bz2 qemu-5819e3e072f41cbf81ad80d822a5c468a91f54e0.zip |
gdbstub: avoid busy loop while waiting for gdb
While waiting for a gdb response, or while sending an acknowledgement
there is not much to do, so do not mark the socket as non-blocking to
avoid a busy loop while paused at gdb. This only affects the user-mode
emulation (qemu-arm -g 1234 ./a.out).
Note that this issue was reported before at
https://lists.nongnu.org/archive/html/qemu-devel/2013-02/msg02277.html.
While at it, close the gdb client fd on EOF or error while reading.
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | gdbstub.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -333,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); @@ -394,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; @@ -1543,9 +1543,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; } } @@ -1600,8 +1604,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) |