* Expect fails to recognize regexp
@ 2002-09-13 11:06 Corinna Vinschen
2002-09-13 11:10 ` David Carlton
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Corinna Vinschen @ 2002-09-13 11:06 UTC (permalink / raw)
To: gdb
Hi,
I'm trying to fix an error in the testsuite lib but I'm stuck at one
point. For some mysterious reason, I can't get a regexp right.
Ok, the original preoblem I'm trying to solve is, that in lib/gdb.exp,
proc rerun_to_main() the procedure doesn't take into account, that
some targets never actually exit, but instead are programatically
trapped in some _exit function.
This means that rerun_to_main() must be able to manage the situation
that gdb not just reruns, but first asks
The program being debugged has been started already.
Start it from the beginning? (y or n)
What I did was adding the following patch to gdb.exp:
Index: lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.26
diff -u -p -r1.26 gdb.exp
--- lib/gdb.exp 13 Sep 2002 17:20:11 -0000 1.26
+++ lib/gdb.exp 13 Sep 2002 17:59:35 -0000
@@ -1685,6 +1685,10 @@ proc rerun_to_main {} {
} else {
send_gdb "run\n"
gdb_expect {
+ -re "The program .* has been started already.*y or n. $" {
+ send_gdb "y\n"
+ exp_continue
+ }
-re "Starting program.*$gdb_prompt $"\
{pass "rerun to main" ; return 0}
-re "$gdb_prompt $"\
but it doesn't work! I tried various... uhm... variations of the
expression, include simple stuff as
-re "The program.*"
or moving the -re back and forth in the gdb_expect expression but to
no avail. The result in gdb.log was always the same:
(gdb) PASS: gdb.base/ena-dis-br.exp: continue until exit at no stop
run^M
The program being debugged has been started already.^M
Start it from the beginning? (y or n) FAIL: gdb.base/ena-dis-br.exp:
(timeout) rerun to main
As you can see, there's no 'y' in the log so expect didn't recognize
the expression at all.
Does anybody have an idea what's going on here?
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Expect fails to recognize regexp
2002-09-13 11:06 Expect fails to recognize regexp Corinna Vinschen
@ 2002-09-13 11:10 ` David Carlton
2002-09-13 11:15 ` Daniel Jacobowitz
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: David Carlton @ 2002-09-13 11:10 UTC (permalink / raw)
To: gdb
On Fri, 13 Sep 2002 20:06:43 +0200, Corinna Vinschen <vinschen@redhat.com> said:
> I'm trying to fix an error in the testsuite lib but I'm stuck at one
> point. For some mysterious reason, I can't get a regexp right.
I think '.' doesn't match newlines (at least it doesn't in regexps in
Emacs); does modifying your regexp so that you have a newline in there
explicitly fix it?
David Carlton
carlton@math.stanford.edu
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Expect fails to recognize regexp
2002-09-13 11:06 Expect fails to recognize regexp Corinna Vinschen
2002-09-13 11:10 ` David Carlton
@ 2002-09-13 11:15 ` Daniel Jacobowitz
2002-09-13 11:24 ` Elena Zannoni
2002-09-13 17:53 ` Felix Lee
3 siblings, 0 replies; 8+ messages in thread
From: Daniel Jacobowitz @ 2002-09-13 11:15 UTC (permalink / raw)
To: gdb
On Fri, Sep 13, 2002 at 08:06:43PM +0200, Corinna Vinschen wrote:
> Hi,
>
> I'm trying to fix an error in the testsuite lib but I'm stuck at one
> point. For some mysterious reason, I can't get a regexp right.
>
> Ok, the original preoblem I'm trying to solve is, that in lib/gdb.exp,
> proc rerun_to_main() the procedure doesn't take into account, that
> some targets never actually exit, but instead are programatically
> trapped in some _exit function.
>
> This means that rerun_to_main() must be able to manage the situation
> that gdb not just reruns, but first asks
>
> The program being debugged has been started already.
> Start it from the beginning? (y or n)
>
> What I did was adding the following patch to gdb.exp:
>
> Index: lib/gdb.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
> retrieving revision 1.26
> diff -u -p -r1.26 gdb.exp
> --- lib/gdb.exp 13 Sep 2002 17:20:11 -0000 1.26
> +++ lib/gdb.exp 13 Sep 2002 17:59:35 -0000
> @@ -1685,6 +1685,10 @@ proc rerun_to_main {} {
> } else {
> send_gdb "run\n"
> gdb_expect {
> + -re "The program .* has been started already.*y or n. $" {
> + send_gdb "y\n"
> + exp_continue
> + }
> -re "Starting program.*$gdb_prompt $"\
> {pass "rerun to main" ; return 0}
> -re "$gdb_prompt $"\
>
> but it doesn't work! I tried various... uhm... variations of the
> expression, include simple stuff as
>
> -re "The program.*"
>
> or moving the -re back and forth in the gdb_expect expression but to
> no avail. The result in gdb.log was always the same:
>
> (gdb) PASS: gdb.base/ena-dis-br.exp: continue until exit at no stop
> run^M
> The program being debugged has been started already.^M
> Start it from the beginning? (y or n) FAIL: gdb.base/ena-dis-br.exp:
> (timeout) rerun to main
>
> As you can see, there's no 'y' in the log so expect didn't recognize
> the expression at all.
>
> Does anybody have an idea what's going on here?
What do you get if you put "exp_internal 1" before this expression?
[This is why I loathe DejaGNU sometimes. TCL/Expect are very...
picky.]
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Expect fails to recognize regexp
2002-09-13 11:06 Expect fails to recognize regexp Corinna Vinschen
2002-09-13 11:10 ` David Carlton
2002-09-13 11:15 ` Daniel Jacobowitz
@ 2002-09-13 11:24 ` Elena Zannoni
2002-09-13 14:23 ` Corinna Vinschen
2002-09-13 17:53 ` Felix Lee
3 siblings, 1 reply; 8+ messages in thread
From: Elena Zannoni @ 2002-09-13 11:24 UTC (permalink / raw)
To: gdb
Add
exp_internal 1
and
exp_internal 0
around the particualar send/expect interaction, then you will exacly
see in the output what expect think it matched.
That's the only way I know of making sense of stuff like this.
Elena
Corinna Vinschen writes:
> Hi,
>
> I'm trying to fix an error in the testsuite lib but I'm stuck at one
> point. For some mysterious reason, I can't get a regexp right.
>
> Ok, the original preoblem I'm trying to solve is, that in lib/gdb.exp,
> proc rerun_to_main() the procedure doesn't take into account, that
> some targets never actually exit, but instead are programatically
> trapped in some _exit function.
>
> This means that rerun_to_main() must be able to manage the situation
> that gdb not just reruns, but first asks
>
> The program being debugged has been started already.
> Start it from the beginning? (y or n)
>
> What I did was adding the following patch to gdb.exp:
>
> Index: lib/gdb.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
> retrieving revision 1.26
> diff -u -p -r1.26 gdb.exp
> --- lib/gdb.exp 13 Sep 2002 17:20:11 -0000 1.26
> +++ lib/gdb.exp 13 Sep 2002 17:59:35 -0000
> @@ -1685,6 +1685,10 @@ proc rerun_to_main {} {
> } else {
> send_gdb "run\n"
> gdb_expect {
> + -re "The program .* has been started already.*y or n. $" {
> + send_gdb "y\n"
> + exp_continue
> + }
> -re "Starting program.*$gdb_prompt $"\
> {pass "rerun to main" ; return 0}
> -re "$gdb_prompt $"\
>
> but it doesn't work! I tried various... uhm... variations of the
> expression, include simple stuff as
>
> -re "The program.*"
>
> or moving the -re back and forth in the gdb_expect expression but to
> no avail. The result in gdb.log was always the same:
>
> (gdb) PASS: gdb.base/ena-dis-br.exp: continue until exit at no stop
> run^M
> The program being debugged has been started already.^M
> Start it from the beginning? (y or n) FAIL: gdb.base/ena-dis-br.exp:
> (timeout) rerun to main
>
> As you can see, there's no 'y' in the log so expect didn't recognize
> the expression at all.
>
> Does anybody have an idea what's going on here?
>
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Developer
> Red Hat, Inc.
> mailto:vinschen@redhat.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Expect fails to recognize regexp
2002-09-13 11:24 ` Elena Zannoni
@ 2002-09-13 14:23 ` Corinna Vinschen
2002-09-13 15:01 ` Daniel Jacobowitz
0 siblings, 1 reply; 8+ messages in thread
From: Corinna Vinschen @ 2002-09-13 14:23 UTC (permalink / raw)
To: gdb
On Fri, Sep 13, 2002 at 02:22:43PM -0400, Elena Zannoni wrote:
>
> Add
>
> exp_internal 1
> and
> exp_internal 0
>
> around the particualar send/expect interaction, then you will exacly
> see in the output what expect think it matched.
>
> That's the only way I know of making sense of stuff like this.
>
> Elena
I tried it but it didn't add anything to the output. Nothing!
I added it this way:
Index: gdb.exp
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.182
diff -u -p -r1.182 gdb.exp
--- gdb.exp 2002/09/13 17:29:54 1.182
+++ gdb.exp 2002/09/13 21:22:12
@@ -1713,14 +1713,20 @@ proc rerun_to_main {} {
timeout {fail "(timeout) rerun to main" ; return 0}
}
} else {
+ exp_internal 1
send_gdb "run\n"
gdb_expect {
+ -re "The program .* has been started already.*y or n. $" {
+ send_gdb "y\n"
+ exp_continue
+ }
-re "Starting program.*$gdb_prompt $"\
{pass "rerun to main" ; return 0}
-re "$gdb_prompt $"\
{fail "rerun to main" ; return 0}
timeout {fail "(timeout) rerun to main" ; return 0}
}
+ exp_internal 0
}
}
Was that ok or did I do something wrong?
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: Expect fails to recognize regexp
2002-09-13 14:23 ` Corinna Vinschen
@ 2002-09-13 15:01 ` Daniel Jacobowitz
2002-09-14 2:28 ` Corinna Vinschen
0 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2002-09-13 15:01 UTC (permalink / raw)
To: gdb
On Fri, Sep 13, 2002 at 11:22:50PM +0200, Corinna Vinschen wrote:
> On Fri, Sep 13, 2002 at 02:22:43PM -0400, Elena Zannoni wrote:
> >
> > Add
> >
> > exp_internal 1
> > and
> > exp_internal 0
> >
> > around the particualar send/expect interaction, then you will exacly
> > see in the output what expect think it matched.
> >
> > That's the only way I know of making sense of stuff like this.
> >
> > Elena
>
> I tried it but it didn't add anything to the output. Nothing!
>
> I added it this way:
Are you sure you're in the right branch of the IF? Does a send_user
there get displayed?
> Was that ok or did I do something wrong?
Looks right.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Expect fails to recognize regexp
2002-09-13 15:01 ` Daniel Jacobowitz
@ 2002-09-14 2:28 ` Corinna Vinschen
0 siblings, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2002-09-14 2:28 UTC (permalink / raw)
To: gdb
On Fri, Sep 13, 2002 at 06:02:15PM -0400, Daniel Jacobowitz wrote:
> Are you sure you're in the right branch of the IF? Does a send_user
> there get displayed?
Thanks, David! This was the important hint. The ena-dis-br.exp
test defines it's own rerun_to_main procedure, which is absolutely
identical to the rerun_to_main proc in gdb.exp. I removed the proc
from ena-dis-br.exp and everythings fine now with my patch.
Corinna
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Expect fails to recognize regexp
2002-09-13 11:06 Expect fails to recognize regexp Corinna Vinschen
` (2 preceding siblings ...)
2002-09-13 11:24 ` Elena Zannoni
@ 2002-09-13 17:53 ` Felix Lee
3 siblings, 0 replies; 8+ messages in thread
From: Felix Lee @ 2002-09-13 17:53 UTC (permalink / raw)
To: gdb
Corinna Vinschen <vinschen@redhat.com>:
> What I did was adding the following patch to gdb.exp:
are you sure the gdb.exp you're editing is the one that's
being used when you run tests, rather than a gdb.exp that's
'installed' somewhere? the path of the gdb.exp that's read is
mentioned somewhere in the gdb.log file.
or you can just add a
verbose "got here" 0
somewhere in the file to check.
btw, "." does match "\n", which you can verify by doing:
$ expect
expect1.1> regexp "." "\n"
1
--
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2002-09-14 9:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-13 11:06 Expect fails to recognize regexp Corinna Vinschen
2002-09-13 11:10 ` David Carlton
2002-09-13 11:15 ` Daniel Jacobowitz
2002-09-13 11:24 ` Elena Zannoni
2002-09-13 14:23 ` Corinna Vinschen
2002-09-13 15:01 ` Daniel Jacobowitz
2002-09-14 2:28 ` Corinna Vinschen
2002-09-13 17:53 ` Felix Lee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox