summaryrefslogtreecommitdiff
path: root/src/base/remote_gdb.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2017-05-09 23:18:48 -0700
committerGabe Black <gabeblack@google.com>2017-05-12 09:43:14 +0000
commit7c94dc236389a9c3bbb656e2666496c060e38334 (patch)
treee9a50d5bd3273ace7660efcc39230c726afc76ac /src/base/remote_gdb.hh
parent6b1069c4073ba51bdd18a716955ee37915ef89dd (diff)
downloadgem5-7c94dc236389a9c3bbb656e2666496c060e38334.tar.xz
misc: Make the remote GDB stub more resilient to bad connections.
Currently, if the remote gdb stub fails to read a byte from an incoming packet because the connection has been dropped, the read call will return anyway and the calling code will have no way to know something bad happened. It might reattempt the read over and over again waiting for some particular byte, doomed to never make forward progress. This change modifies the remote GDB code so that if a read or write call fails, it will instead detach from the debugger and continue. Before this change, When simulating a port scan, ie connecting to the debugger port and then immediately dropping the connection using this command: nc -v -n -z -w 1 127.0.0.1 7000 gem5 would enter the previously described death spiral. After it, gem5 detaches from the bad connection and resumes execution. Subsequently attaching with gdb was successful. This code is written in a C centric style, and would benefit from some refactoring. Change-Id: Ie3c0bb35b9cfe3671d0f731e3907548bae0d292f Reviewed-on: https://gem5-review.googlesource.com/3180 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/base/remote_gdb.hh')
-rw-r--r--src/base/remote_gdb.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 2ab7a84dd..b3a2b5c60 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -203,11 +203,11 @@ class BaseRemoteGDB
};
protected:
- uint8_t getbyte();
- void putbyte(uint8_t b);
+ bool getbyte(uint8_t &b);
+ bool putbyte(uint8_t b);
int recv(char *data, int len);
- void send(const char *data);
+ ssize_t send(const char *data);
protected:
// Machine memory