===== Remote debugging of win32-target on UNIX-like host using Gdbserver and Cgdb =====
The article describes a use-case of how can you remotely debug a win32-target process using [[http://en.wikipedia.org/wiki/Gdbserver|Gdbserver]] and [[http://cgdb.github.io/|Cgdb]] in the comfortable UNIX-like OS/Shell and get STDOUT output from the target.
Assuming that you have gdbserver installed on the target and the executable compiled with debug symbols.
Also we set that your host=192.168.1.1, target=192.168.1.2. For Gdbserver we are using port=5555, for STDOUT - port=7777.
Firstly, run in one of the host's terminals command to view output messages of the target:
user@host$ while [ 1 ]; do echo '--- NEW STDOUT CONNECTION ---'; socat STDOUT TCP4-LISTEN:7777; sleep 1; done
Secondly, run Gdbserver on the target:
user@target$ gdbserver 192.168.1.2:5555 run/Application.exe --arg1=hello --arg2=world | socat TCP4:192.168.1.1:7777 STDIN
Finally, connect to the target using Cgdb, specifying executable with debug symbols and the source code dirs:
user@host$ cgdb -s Application.exe -d src -d test # or cgdb -s MyDLL.dll -d src -d test
(gdb) target remote 192.168.1.2:5555
(gdb) b main
(gdb) c