gdb python: how to async stop and restart remote target

Salvatore Lionetti salvatorelionetti@gmail.com
Tue Jan 10 16:49:00 GMT 2017


Hi,

I'm trying to define and automatize test for a C/RTEMS application,
using gdb 7.11.1 with the lovely python extension.

I need to asynchronously stop the target remotely connected via TCP,
ex. to inject a fault or an input packet, then restarting the remote
system.

What is the preferred way to do it?

This is what I'm trying:

(EXAMPLE1)
gdb.execute('target remote ...')
gdb.execute('continue&')
time.sleep(2)
gdb.execute('interrupt')

The execution of "gdb --command ... --batch" leads to:
...
Cannot execute this command while the target is running.
Use the 'interrupt' command to stop the target and try again.

That is related to the last line with the 'interrupt' command.
The remote target is stopped. After that reading from target memory
leads to the same error.

(EXAMPLE2)
gdb.execute('target remote ...')
gdb.execute('continue&')
time.sleep(2)
gdb.execute('interrupt')
time.sleep(2)
gdb.execute('continue')

The command reported above leads to:
...
gdb.error: Cannot execute this command while the selected thread is running.
Program received signal SIGINT, Interrupt

In the remote target is running at the end of the script execution.
But seems to be in an inconsistent state.

Have a good day



More information about the Gdb mailing list