I have a requirement to run a 'C'-module in gdb but this gdb should be involked by python script.
2 Answers
I think the best way to do this is to use subprocess:
subprocess.Popen(['gdb', 'arg1', 'arg2', 'etc'])
If you are using Python 2.x and you only want to record the output, you can use commands, but it is deprecated since 2.6.
You might want to check Invoke and control GDB from Python
5 Comments
Sagar Gupta M.
I think this is the only way for this. And thanks for reply.
Sagar Gupta M.
Can you give some sample python scripts to control gdb
rubik
You can check this: tromey.com/blog/?p=548
Sagar Gupta M.
Are you familear with this python enaled with gdb. If so how to import gdb in python.
rubik
Unfortunately no, I never used gdb with Python
Hacky solution as always: os.system.
os.system("gdb arg1 arg2 etc")
2 Comments
Sagar Gupta M.
Apart from this are there any commands to do this.
subprocessmodule, which according to [python.org/dev/peps/pep-0324/] is to replace the os.system call (among other things)