Remotely debugging a Linux process from Windows with gdb and gdbserver: what exactly is needed on the Windows side?
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]}
Now there is a plugin http://marketplace.eclipse.org/content/direct-remote-c-debugging
Which allows you to launch gdb on the server remotely over ssh. It takes care about path mapping and others things.
You don't need gdb server to be running remotely
I failed to build on Windows, but found quite easy building it under Linux. To summarize and complete @Eugene response: First, prepare sources:
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
Download Windows compiler:
sudo apt-get install mingw-w64
Check out the target configuration platform you want to debug your binaries (what to put in --target parameter):
echo ${BASH_VERSINFO[5]}
Prepare makefiles targeted for your desired platform but running on different host. We compiling it static so that it doesn't depend on any DLLs or other libraries. Also we disabling building other binaries as gdb wiki suggests:
../../configure --host=x86_64-w64-mingw32 --target=x86_64-pc-linux-gnu --enable-static=yes --disable-interprocess-agent --disable-binutils --disable-ld --disable-gold --disable-gas --disable-sim --disable-gprof
finally, build (takes like 30-60 min):
make LDFLAGS=-static
You can find your debugger in gdb folder. It is also good to strip it of debugging symbols as after building executable is huge:
strip -s gdb/gdb.exe
Voila! gdb.exe ready to run in Windows and remotely debug Linux executables!