… could not be easier.
On the remote machine start the gdbserver with a port:
$ gdbserver host:port programname [args]
Then on the machine that contains source code, start gdb, load symbols, and start debugging:
$ gdb (gdb) symbol-file programname (gdb) target remote tcp:host:port (gdb) break main (gdb) continue
More info on documentation pages:
gdbserver
connecting