This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: How do I get regexp from expect at gdb_expect?
- From: Paul Hilfinger <hilfingr at EECS dot Berkeley dot EDU>
- To: GDB <gdb at sources dot redhat dot com>
- Cc: Bob Rossi <bob at brasko dot net>
- Date: Fri, 28 Jan 2005 19:09:15 -0800
- Subject: Re: How do I get regexp from expect at gdb_expect?
> 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