From: Greg Law <glaw@undo-software.com>
To: fpga <mgbg25171@blueyonder.co.uk>
Cc: gdb@sourceware.org
Subject: Re: controlling gdb via python's pexpect
Date: Fri, 06 Nov 2009 10:39:00 -0000 [thread overview]
Message-ID: <4AF3E86E.2080101@undo-software.com> (raw)
In-Reply-To: <26227761.post@talk.nabble.com>
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/
next prev parent reply other threads:[~2009-11-06 9:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 20:27 fpga
2009-11-05 20:35 ` George Russell
2009-11-06 10:56 ` Gaius Mulley
2009-11-06 10:56 ` Gaius Mulley
2009-11-06 11:07 ` fpga
2009-11-06 16:55 ` Gaius Mulley
2009-11-06 17:57 ` fpga
2009-11-06 9:11 ` fpga
2009-11-06 7:15 ` fpga
2009-11-06 9:12 ` fpga
2009-11-06 10:23 ` fpga
2009-11-06 10:28 ` George Russell
2009-11-06 10:39 ` Greg Law [this message]
2009-11-06 10:44 ` fpga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AF3E86E.2080101@undo-software.com \
--to=glaw@undo-software.com \
--cc=gdb@sourceware.org \
--cc=mgbg25171@blueyonder.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox