From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27574 invoked by alias); 6 Nov 2009 09:12:27 -0000 Received: (qmail 27565 invoked by uid 22791); 6 Nov 2009 09:12:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smarthost01.mail.zen.net.uk (HELO smarthost01.mail.zen.net.uk) (212.23.3.140) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Nov 2009 09:12:20 +0000 Received: from [82.69.137.158] (helo=[10.17.20.102]) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1N6Krh-0000JY-Gp; Fri, 06 Nov 2009 09:12:17 +0000 Message-ID: <4AF3E86E.2080101@undo-software.com> Date: Fri, 06 Nov 2009 10:39:00 -0000 From: Greg Law User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: fpga CC: gdb@sourceware.org Subject: Re: controlling gdb via python's pexpect References: <26221261.post@talk.nabble.com> <26227761.post@talk.nabble.com> In-Reply-To: <26227761.post@talk.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Originating-Smarthost01-IP: [82.69.137.158] Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-11/txt/msg00059.txt.bz2 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/