0

I have launched GDB using subprocess.call methond in python .Can any one help how to pass commands to gdb (like 'info threads') from python script.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
chenna
  • 159
  • 1
  • 4
  • 14

1 Answers1

1

It is better to use Pexpect module if you want to interact with interactive shells.

But I suggest you to use Python bindings that shipped with gdb.

infothreads.py:

import gdb
gdb.execute('info threads')
gdb.execute('continue')

Run it using -x option of gdb:

gdb -x infothreads.py -p 21686

Documentation on Python bindings may be found here: Python API

myaut
  • 11,174
  • 2
  • 30
  • 62