Search code examples
gdbremote-debugginggdbserver

Run file with gdbserver --multi


Given:

gdbserver --multi :2345

is running on remote machine. I can connect to it with gdb:

(gdb) target remote 192.168.10.248:2345
Remote debugging using 192.168.10.248:2345
The target is not running (try extended-remote?)

(gdb) target extended-remote 192.168.10.248:2345
Remote debugging using 192.168.10.248:2345

What next? How to run some file, say a.out on remote machine and debug it?


Solution

  • What next?

    (gdb) set remote exec-file a.out
    (gdb) file a.out
    Reading symbols from a.out...
    (gdb) b main
    Breakpoint 1 at 0x4015ab: file 1.cpp, line 60.
    (gdb) r
    
    • set remote exec-file a.out is used to set the program which you want to debug in the target.
    • file a.out is used to load the debugging symbols from the program in the host.

    See full example for gdbserver --multi here: https://www.thegeekstuff.com/2014/04/gdbserver-example//