xlen(0),
sim(sim),
client_fd(0),
- recv_buf(64 * 1024), send_buf(64 * 1024)
+ // gdb likes to send 0x100000 bytes at once when downloading.
+ recv_buf(0x180000), send_buf(64 * 1024)
{
socket_fd = socket(AF_INET, SOCK_STREAM, 0);
if (socket_fd == -1) {
// available.
size_t count = recv_buf.contiguous_empty_size();
- assert(count > 0);
ssize_t bytes = ::read(client_fd, recv_buf.contiguous_empty(), count);
if (bytes == -1) {
if (errno == EAGAIN) {
break;
}
}
+
+ if (recv_buf.full()) {
+ fprintf(stderr,
+ "Receive buffer is full, but no complete packet was found!\n");
+ for (unsigned line = 0; line < 8; line++) {
+ for (unsigned i = 0; i < 16; i++) {
+ fprintf(stderr, "%02x ", recv_buf.entry(line * 16 + i));
+ }
+ for (unsigned i = 0; i < 16; i++) {
+ uint8_t e = recv_buf.entry(line * 16 + i);
+ if (e >= ' ' && e <= '~')
+ fprintf(stderr, "%c", e);
+ else
+ fprintf(stderr, ".");
+ }
+ fprintf(stderr, "\n");
+ }
+ assert(!recv_buf.full());
+ }
}
void gdbserver_t::handle_halt_reason(const std::vector<uint8_t> &packet)
unsigned int size() const;
bool empty() const { return start == end; }
bool full() const { return ((end+1) % capacity) == start; }
+ T entry(unsigned index) { return data[(start + index) % capacity]; }
// Return size and address of the block of RAM where more data can be copied
// to be added to the buffer.