0

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

Sagar Gupta M.
  • 359
  • 1
  • 3
  • 5
  • the `subprocess` module, which according to [http://www.python.org/dev/peps/pep-0324/] is to replace the os.system call (among other things) –  Jan 13 '11 at 12:57
  • W_P are there any existing commands in gdb enabled python. – Sagar Gupta M. Jan 18 '11 at 11:40

2 Answers2

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

Community
  • 1
  • 1
rubik
  • 8,814
  • 9
  • 58
  • 88
0

Hacky solution as always: os.system.

os.system("gdb arg1 arg2 etc")

orlp
  • 112,504
  • 36
  • 218
  • 315