Fix GDB remote 'g' packet reply is too long


This post gives a quick walk through for steps to fix the GDB error : “remote ‘g’ packet reply is too long”.

If you already know the steps to patch, skip the rest of the article, the patch file is here.

This post serves to help those who are not familiar with the usual steps to apply patch and build from source. Steps are tested on Ubuntu 17.04.

Step 0:

Remove existing GDB

sudo apt remove gdb

Step 1:

Get the GDB source:

# Download the source archive
wget "http://ftp.gnu.org/gnu/gdb/gdb-7.11.tar.gz"

# Extract
tar -xzf gdb-7.11.tar.gz

cd gdb-7.11

Step 2:

Download the patch file and apply it.

wget -O fix.diff "https://sourceware.org/bugzilla/attachment.cgi?id=8512"
patch gdb/remote.c fix.diff

Step 3

You would need some packages to build (Skip if present, use appropriate package manager command if using a different distro)

sudo apt install texinfo build-essential

Compile GDB and install it. This step might take few minutes.

./configure
make
sudo make install

Done.


[1] https://compas.cs.stonybrook.edu/courses/cse506-operating-systems-fall-17/cse506-project-hints/