Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Bob Rossi <bob@brasko.net>
To: Paul Hilfinger <hilfingr@EECS.Berkeley.EDU>
Cc: GDB <gdb@sources.redhat.com>
Subject: Re: How do I get regexp from expect at gdb_expect?
Date: Mon, 31 Jan 2005 15:07:00 -0000	[thread overview]
Message-ID: <20050131150652.GA7955@white> (raw)
In-Reply-To: <200501290309.j0T39F1i020834@tully.CS.Berkeley.EDU>

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
 }

COMMAND(201-break-list)

ENTIRE_OUT###201-break-list
201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
###

PATTER_TO_END###201-break-list
201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
###

PATTER_OUT###201-break-list
201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}###

BUFFER###201-break-list
201^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
###

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

Also, if I run the commands manually, I do not see the extra
'201-break-list' in the MI output command. 

   Is there any way I can make Expect tell me only the output? 
   Does the regular expression also parse the input to GDB?

Any help would be greatly appreciated.

Thanks,
Bob Rossi


  parent reply	other threads:[~2005-01-31 15:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-29  2:57 Bob Rossi
2005-01-29  3:09 ` Paul Hilfinger
2005-01-29  3:11   ` Bob Rossi
2005-01-29  3:16     ` Bob Rossi
2005-01-31 15:07   ` Bob Rossi [this message]
2005-01-31 16:28     ` Daniel Jacobowitz
2005-01-31 16:59       ` Bob Rossi
2005-01-31 21:10       ` Bob Rossi
2005-01-31 21:21         ` Daniel Jacobowitz
2005-01-31 22:00           ` Bob Rossi
2005-01-31 22:04             ` Daniel Jacobowitz
2005-01-31 22:12               ` Bob Rossi
2005-02-01  3:52                 ` Daniel Jacobowitz
2005-02-01 14:20                   ` Bob Rossi
2005-02-01 14:23                     ` Daniel Jacobowitz
2005-02-01 14:39                       ` Bob Rossi
2005-02-01 15:20                         ` Daniel Jacobowitz
2005-02-01 15:38                           ` Bob Rossi
2005-02-01 15:58                         ` Dave Korn
2005-02-01 16:10                           ` 'Bob Rossi'

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=20050131150652.GA7955@white \
    --to=bob@brasko.net \
    --cc=gdb@sources.redhat.com \
    --cc=hilfingr@EECS.Berkeley.EDU \
    /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