From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7601 invoked by alias); 31 Jan 2005 16:59:39 -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 6586 invoked from network); 31 Jan 2005 16:59:10 -0000 Received: from unknown (HELO lakermmtao05.cox.net) (68.230.240.34) by sourceware.org with SMTP; 31 Jan 2005 16:59:10 -0000 Received: from white ([68.9.64.121]) by lakermmtao05.cox.net (InterMail vM.6.01.04.00 201-2131-117-20041022) with ESMTP id <20050131165910.EWTA17924.lakermmtao05.cox.net@white>; Mon, 31 Jan 2005 11:59:10 -0500 Received: from bob by white with local (Exim 3.35 #1 (Debian)) id 1CvetK-00028w-00; Mon, 31 Jan 2005 11:59:10 -0500 Date: Mon, 31 Jan 2005 16:59:00 -0000 From: Bob Rossi To: Paul Hilfinger , GDB Subject: Re: How do I get regexp from expect at gdb_expect? Message-ID: <20050131165910.GC7955@white> Mail-Followup-To: Paul Hilfinger , GDB References: <20050129025743.GA4053@white> <200501290309.j0T39F1i020834@tully.CS.Berkeley.EDU> <20050131150652.GA7955@white> <20050131162609.GA19459@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050131162609.GA19459@nevyn.them.org> User-Agent: Mutt/1.3.28i X-SW-Source: 2005-01/txt/msg00164.txt.bz2 On Mon, Jan 31, 2005 at 11:26:10AM -0500, Daniel Jacobowitz wrote: > On Mon, Jan 31, 2005 at 10:06:52AM -0500, Bob Rossi wrote: > > On Fri, Jan 28, 2005 at 07:09:15PM -0800, Paul Hilfinger wrote: > > > > > > > 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... > > > > As an update, I've written the MI Output Command parser as a Tcl extension > > and I've put a call in mi-support.exp:mi_gdb_test to test the syntax of > > the MI Output Command. > > > > I'm having a problem determining if GDB is broken, or if expect is > > giving me the wrong string back. I suspect it's the ladder. > > > > Here's the place where I get the string from Expect, I do several lines > > of instrumentation. The data is below, everything after ### and before > > ### is what's given from Expect. > > > > -re "(\[\r\n\]*(($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$))" { > > set entire_out $expect_out(1,string) > > set mi_out $expect_out(2,string) > > set pattern_out $expect_out(3,string) > > > > set parse_result [gdbmi_parse $mi_out] > > if [string match "syntax error" $parse_result] then { > > fail "parsing MI output command" > > puts "COMMAND($command)" > > puts "ENTIRE_OUT###$entire_out###" > > puts "PATTER_TO_END###$mi_out###" > > puts "PATTER_OUT###$pattern_out###" > > puts "BUFFER###$expect_out(buffer)###" > > } > > > > if ![string match "" $message] then { > > pass "$message" > > } > > set result 0 > > } > > You've left out your pattern, and the context. I recommend using > "exp_internal 1" to debug this sort of problem; that will show you what > expect is doing. > > > The problem is, Expect is saying that '201-break-list' is part of the MI > > output command. This is incorrect and would mean that GDB is not > > behaving properly. However, the log file shows that GDB is *not* > > outputting the unwanted data as part of the MI Output Command, > > > > 201-break-list^M > > 201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1" > > (gdb) ^M > > FAIL: gdb.mi/mi-basics.exp: parsing MI output command > > GDB echoes what you type. Expect receives this and treats it as > output, because that's what it is. You'll need to consume it > explicitly (but be careful - there are dragons here - what GDB outputs > may have extra non-printing characters for line wrapping on long > input). Why does GDB echo the MI commands? Isn't that functionality part of readline, which is not part of the MI interface? I've never noticed that GDB echo's the output, and it's not in the gdb.log file. BTW, I sent in the output of the dbg.log file from runtest, which is here, http://sources.redhat.com/ml/gdb/2005-01/msg00162.html Thanks, Bob Rossi