0

I have a requirement to run a 'C'-module in gdb but this gdb should be involked by python script.

2
  • the subprocess module, which according to [python.org/dev/peps/pep-0324/] is to replace the os.system call (among other things) Commented Jan 13, 2011 at 12:57
  • W_P are there any existing commands in gdb enabled python. Commented Jan 18, 2011 at 11:40

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

5 Comments

I think this is the only way for this. And thanks for reply.
Can you give some sample python scripts to control gdb
You can check this: tromey.com/blog/?p=548
Are you familear with this python enaled with gdb. If so how to import gdb in python.
Unfortunately no, I never used gdb with Python
0

Hacky solution as always: os.system.

os.system("gdb arg1 arg2 etc")

2 Comments

Apart from this are there any commands to do this.
the subprocess module makes this inappropriate for the majority of use cases.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.