How to pass commands to gdb from python
Question: 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.


Answer: It is better to use [Pexpect](https://pexpect.readthedocs.org/en/latest/)
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](https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html#Python-API)

