6
\$\begingroup\$

I am using GDB to load and debug my executable. At the moment, each time I want to run my program I first have to load it, and then continue it to start execution.

Apparently the run command starts execution from the start, but when I try to run I get the error:

The "remote" target does not support "run".  Try "help target" or "continue".

My board is an STM32F2. Is there a way to easily start execution from the start of the executable without having the reload the damn thing onto memory again?

EDIT: I have tried Leo's suggestion, but when I do run I get the following error:

(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) [answered Y; input not from terminal]
../../gdb-7.2/gdb/thread.c:79: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) [answered Y; input not from terminal]
../../gdb-7.2/gdb/thread.c:79: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) [answered Y; input not from terminal]

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I have tried that but I get an error. (Please see the edited question for the error.) \$\endgroup\$
    – Randomblue
    Mar 22, 2012 at 17:35
3
\$\begingroup\$

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

\$\endgroup\$
0
\$\begingroup\$

For full embedded platforms without a dedicated loader, restarting at the entry point is sufficient -- the startup code clears BSS, copies the initialized data, sets the initial stack pointer and calls global constructors (if any).

For anything that uses an executable loader, you need to go through that loader.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.