From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20318 invoked by alias); 6 Nov 2009 10:28:38 -0000 Received: (qmail 20126 invoked by uid 22791); 6 Nov 2009 10:28:36 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mta3.glam.ac.uk (HELO mta3.glam.ac.uk) (193.63.147.53) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 06 Nov 2009 10:28:31 +0000 Received: from j228-gm.comp.glam.ac.uk ([193.63.148.84] helo=j228-gm) by mta3.glam.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1N6M3P-0001Wj-79; Fri, 06 Nov 2009 10:28:27 +0000 Received: from gaius by j228-gm with local (Exim 4.69) (envelope-from ) id 1N6M3M-0005X4-2U; Fri, 06 Nov 2009 10:28:24 +0000 To: George Russell Cc: fpga , gdb@sourceware.org Subject: Re: controlling gdb via python's pexpect References: <26221261.post@talk.nabble.com> <4AF336E4.5000002@codeplay.com> From: Gaius Mulley Date: Fri, 06 Nov 2009 10:56:00 -0000 In-Reply-To: <4AF336E4.5000002@codeplay.com> (George Russell's message of "Thu\, 05 Nov 2009 21\:34\:44 +0100") Message-ID: <87ocnghrqv.fsf@j228-gm.comp.glam.ac.uk> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes 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/msg00061.txt.bz2 George Russell writes: > fpga wrote: >> Can someone please give me an example of how this is done. >> I'm afraid the documentation is not helping me. >> Thx >> > Hi, > > I have had some success in controlling GDB (via MI) from python, using > the subprocess module and communicating with GDB via > pipes. (http://docs.python.org/library/subprocess.html) > > The main issue so far is that some applications detect when they are > running with pipes instead of a terminal for output, and buffer > program output by block rather than line as on a terminal, leading to > delays in receiving program output issued via printf, for example, > unless it is followed by an explicit fflush call. > > (I too would be interested in an example of using pexpect to control GDB) > Cheers, > George Russell Hi, for what it is worth feel free to download http://floppsie.comp.glam.ac.uk/download/python/twingdb.tar.gz which was written to run two gdb's debugging a stage1 and stage2 generation of a compiler and single step until a line number differs. It is written in Python and uses pexpect The code is very alpha - but it worked well enough to find the bug I was hunting. regards, Gaius