Remotely debugging a Linux process from Windows with gdb and gdbserver: what exactly is needed on the Windows side?

rewbs picture rewbs · Aug 17, 2010 · Viewed 15.6k times · Source

I am running Eclipse CDT on Windows to develop C code that is built & tested on remote Linux systems. Currently, the code is never compiled on Windows.

I am able to use CDT to begin the remote process on the Linux target under gdbserver, and then attach gdb from the Windows host. However, gdb immediately fails with errors like:

warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB.  Attempting to continue with the default i386 settings.
[...]
Remote 'g' packet reply is too long: 74afe9bff0aee9bf02000000f4af4a00a0aee9bf[...]

Debugging between two Linux systems works fine, so it's clear that I'm doing something wrong on the Windows host side. My specific questions are:

  • Is the Cygwin version of gdb sufficient to debug remote Linux processes, or do I need a special cross-gdb in order to run it on Windows and work with Linux processes? If so, is there anywhere can I get hold of such a gdb?

  • Remote debugging with gdb requires that symbols are available on the host system. What is the easiest way to achieve this? Can I just copy the symbols produced by the build on the Linux target to the Windows host, or do have to get a full build going on Windows? Is there a way to avoid this requirement, such that I can supply symbols only on the target?

Thanks,

-R


More info: The RSE FAQ provides some pointers, but unfortunately I'm still blocked. The FAQ describes two approaches:

  • Launch the gdb client on the remote system over ssh. Problem here is that certain fields in the CDT debug launcher are tied to the local system (project path, executable path etc...).
  • Build/obtain a cross-debugging version of gdb that supports debugging Linux processes from Windows. Problem here is that there's little info on how to achieve this.

I have also raised this issue on the CDT forum.

Answer

Eugene Weiss picture Eugene Weiss · Dec 15, 2017

Just rebuild gdb with target platform supporting. You can use Cygwin for this. Example for RHEL target platform:

> wget http://ftp.gnu.org/gnu/gdb/gdb-<ver>.tar.xz
> tar -xJvf gdb-<ver>.tar.xz
> mkdir -p gdb-<ver>/build/x86_64-redhat-linux-gnu
> cd gdb-<ver>/build/x86_64-redhat-linux-gnu
> ../../configure --target=x86_64-redhat-linux-gnu
> make && make install
> x86_64-redhat-linux-gnu-gdb.exe --version

Don't forget to reconfigure your toolchain after this. To obtain the target configuration name, you can use:

> echo ${BASH_VERSINFO[5]}