Restart execution from the start without having to reload
Take a look at https://stackoverflow.com/a/5200638/713554 which in turn links to http://sourceware.org/gdb/onlinedocs/gdb/Server.html
From what I understand, you should use target extended-remote
instead of target remote
.
Step-by-step procedure
Remote:
# pwd contains cross-compiled ./myexec
gdbserver --multi :1234
Local:
# pwd also contains the same cross-compiled ./myexec
gdb -ex 'target extended-remote 192.168.0.1:1234' \
-ex 'set remote exec-file ./myexec' \
--args ./myexec arg1
(gdb) r
[Inferior 1 (process 1234) exited normally]
(gdb) r
[Inferior 1 (process 1235) exited normally]
(gdb) monitor exit
Stdout shows on remote.
Tested in Ubuntu 14.04.
Related: https://stackoverflow.com/questions/75255/how-do-you-start-running-the-program-over-again-in-gdb-with-target-remote