From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31570 invoked by alias); 29 Jan 2005 03:09:30 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 31551 invoked from network); 29 Jan 2005 03:09:25 -0000 Received: from unknown (HELO tully.CS.Berkeley.EDU) (128.32.153.227) by sourceware.org with SMTP; 29 Jan 2005 03:09:25 -0000 Received: from tully.CS.Berkeley.EDU (localhost [127.0.0.1]) by tully.CS.Berkeley.EDU (8.12.7/8.12.7/3.141592645) with ESMTP id j0T39FIh020837; Fri, 28 Jan 2005 19:09:15 -0800 (PST) Received: from tully.CS.Berkeley.EDU (hilfingr@localhost) by tully.CS.Berkeley.EDU (8.12.7/8.12.7/Submit) with ESMTP id j0T39F1i020834; Fri, 28 Jan 2005 19:09:15 -0800 (PST) Message-Id: <200501290309.j0T39F1i020834@tully.CS.Berkeley.EDU> To: GDB cc: Bob Rossi Subject: Re: How do I get regexp from expect at gdb_expect? In-Reply-To: Message from Bob Rossi of "Fri, 28 Jan 2005 21:57:43 EST." <20050129025743.GA4053@white> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20830.1106968155.1@tully.CS.Berkeley.EDU> Date: Sat, 29 Jan 2005 03:09:00 -0000 From: Paul Hilfinger X-SW-Source: 2005-01/txt/msg00156.txt.bz2 > Hi, > > I'm using expect with GDB and I've come across a problem. For instance, > say I have, > > gdb_expect $tmt { > -re "(Ending remote debugging.*$mi_gdb_prompt\[ \]*$)" { > # at this point, how do I get the string that matched the above > # regex? > } > } > } Here is some relevant documentation: Upon matching a pattern (or eof or full_buffer), any matching and previously unmatched output is saved in the variable expect_out(buffer) [as in $expect_out(buffer)]. Up to 9 regexp sub- string matches are saved in the variables expect_out(1,string) through expect_out(9,string). If the -indices flag is used before a pattern, the start- ing and ending indices (in a form suitable for lrange) of the 10 strings are stored in the variables expect_out(X,start) and expect_out(X,end) where X is a digit, corresponds to the substring position in the buffer. 0 refers to strings which matched the entire pattern... P. Hilfinger