This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: controlling gdb via python's pexpect
fpga wrote:
fpga wrote:
Can someone please give me an example of how this is done.
I'm afraid the documentation is not helping me.
Thx
George
You've got further than I have!
I tried to use subprocess but failed.
Yeah, pipes might appear to work at first if you're "lucky", but pretty
quickly you'll come unstuck due to problems with buffering.
Here's a trivial example for gdb with pexpect:
import pexpect, sys
child = pexpect.spawn( 'gdb a.out')
child.setlog( sys.stdout)
child.expect_exact ('(gdb) ')
child.send ('run\n')
child.expect_exact ('Program exited normally.')
child.expect_exact ('(gdb) ')
child.send ('quit\n')
child.expect( pexpect.EOF
Note that the pexpect.expect method takes a regular expression but
"expect_exact" doesn't. If you're going to use the expect method be
sure to escape things like parentheses.
Greg
--
Greg Law, Undo Software http://undo-software.com/