This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA/testsuite] advance.exp/until.exp
- From: Elena Zannoni <ezannoni at redhat dot com>
- To: Fernando Nasser <fnasser at redhat dot com>
- Cc: Elena Zannoni <ezannoni at redhat dot com>, gdb-patches at sources dot redhat dot com
- Date: Wed, 15 Jan 2003 09:29:40 -0500
- Subject: Re: [RFA/testsuite] advance.exp/until.exp
- References: <15908.39503.970119.48841@localhost.redhat.com><3E256D8F.1060908@redhat.com>
Fernando Nasser writes:
> his is great. Thanks Elena.
>
committed, thanks.
Elena
> Fernando
>
> Elena Zannoni wrote:> This is a rework of the tests I alreaded posted, based on
> the fact
> > that the command is not called advance.
> > http://sources.redhat.com/ml/gdb-patches/2002-12/msg00585.html
> >
> > I added 2 new tests, one for until, one for advance.
> >
> > * gdb.base/break.exp: Move the tests of until command from here...
> > * gdb.base/until.exp: ... to here. New file. Add other tests.
> > * gdb.base/advance.c: New file.
> > * gdb.base/advance.exp: New file.
> >
> >
> > Index: break.exp
> > ===================================================================
> > RCS file: /cvs/uberbaum/gdb/testsuite/gdb.base/break.exp,v
> > retrieving revision 1.12
> > diff -u -p -r1.12 break.exp
> > --- break.exp 13 May 2002 01:18:19 -0000 1.12
> > +++ break.exp 20 Dec 2002 18:15:01 -0000
> > @@ -361,29 +361,6 @@ gdb_expect {
> > {pass $name}
> > -re "$gdb_prompt $" {fail $name}
> > timeout {fail "(timeout) $name"}
> > -}
> > -
> > -# Verify that "until <location>" works. (This is really just syntactic
> > -# sugar for "tbreak <location>; continue".)
> > -#
> > -send_gdb "until 79\n"
> > -gdb_expect {
> > - -re "main .* at .*:79.*$gdb_prompt $"\
> > - {pass "until 79"}
> > - -re "$gdb_prompt $"\
> > - {fail "until 79"}
> > - timeout {fail "(timeout) until 79"}
> > -}
> > -
> > -# Verify that a malformed "until" is gracefully caught.
> > -#
> > -send_gdb "until 80 then stop\n"
> > -gdb_expect {
> > - -re "Junk at end of arguments..*$gdb_prompt $"\
> > - {pass "malformed until"}
> > - -re "$gdb_prompt $"\
> > - {fail "malformed until"}
> > - timeout {fail "(timeout) malformed until"}
> > }
> >
> > # Verify that GDB responds gracefully when asked to set a breakpoint
> >
> > --- /dev/null Thu Aug 30 16:30:55 2001
> > +++ until.exp Tue Jan 14 17:58:36 2003
> > @@ -0,0 +1,81 @@
> > +# Copyright 2003 Free Software Foundation, Inc.
> > +
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write to the Free Software
> > +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
> > +
> > +# Please email any bugs, comments, and/or additions to this file to:
> > +# bug-gdb@prep.ai.mit.edu
> > +
> > +# until.exp -- Expect script to test 'until' in gdb
> > +
> > +if $tracelevel then {
> > + strace $tracelevel
> > +}
> > +
> > +set testfile break
> > +set srcfile ${srcdir}/${subdir}/${testfile}.c
> > +set binfile ${objdir}/${subdir}/${testfile}
> > +
> > +remote_exec build "rm -f ${binfile}"
> > +if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } {
> > + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> > +}
> > +
> > +gdb_exit
> > +gdb_start
> > +gdb_reinitialize_dir $srcdir/$subdir
> > +gdb_load ${binfile}
> > +
> > +if ![runto_main] then {
> > + fail "Can't run to main"
> > + return 0
> > +}
> > +
> > +# Verify that "until <location>" works. (This is really just syntactic
> > +# sugar for "tbreak <location>; continue".)
> > +#
> > +gdb_test "until 79" \
> > + "main .* at .*:79.*" \
> > + "until line number"
> > +
> > +# Verify that a malformed "advance" is gracefully caught.
> > +#
> > +gdb_test "until 80 then stop" \
> > + "Junk at end of arguments." "malformed until"
> > +
> > +# Rerun up to factorial, outer invocation
> > +if { ![runto factorial] } then { gdb_suppress_tests; }
> > +delete_breakpoints
> > +
> > +# At this point, 'until' should continue the inferior up to when all the
> > +# inner invocations of factorial() are completed and we are back at this
> > +# frame.
> > +#
> > +gdb_test "until 99" \
> > + "factorial.*value=720.*at ${srcfile}:99.*return \\(value\\)." \
> > + "until factorial, recursive function"
> > +
> > +# Run to a function called by main
> > +#
> > +if { ![runto marker2] } then { gdb_suppress_tests; }
> > +delete_breakpoints
> > +
> > +# Now issue an until with another function, not called by the current
> > +# frame, as argument. This should not work, i.e. the program should
> > +# stop at main, the caller, where we put the 'guard' breakpoint.
> > +#
> > +gdb_test "until marker3" \
> > + "$hex in main.*argc.*argv.*envp.*at ${srcfile}:82.*marker2 \\(43\\)." \
> > + "until func, not called by current frame"
> > +
> >
> >
> > --- /dev/null Thu Aug 30 16:30:55 2001
> > +++ advance.c Tue Jan 14 17:06:09 2003
> > @@ -0,0 +1,45 @@
> > +
> > +static int x;
> > +
> > +int foo (int a)
> > +{
> > + int b = a + 10;
> > + return b;
> > +}
> > +
> > +int bar (int y)
> > +{
> > + int z = y + 20;
> > + return z;
> > +}
> > +
> > +void func()
> > +{
> > + x = x + 5;
> > + func2 ();
> > +}
> > +
> > +int func2 ()
> > +{
> > + x = 6;
> > +}
> > +
> > +int func3 ()
> > +{
> > + x = 4;
> > +}
> > +
> > +int
> > +main ()
> > +{
> > + int result;
> > + int b, c;
> > + c = 5;
> > + b = 3; /* advance this location */
> > +
> > + func (c); /* stop here after leaving current frame */
> > + func3 (); /* break here */
> > + result = bar (b + foo (c));
> > + return 0; /* advance malformed */
> > +}
> > +
> >
> > --- /dev/null Thu Aug 30 16:30:55 2001
> > +++ advance.exp Tue Jan 14 17:58:44 2003
> > @@ -0,0 +1,91 @@
> > +# Copyright 2003 Free Software Foundation, Inc.
> > +
> > +# This program is free software; you can redistribute it and/or modify
> > +# it under the terms of the GNU General Public License as published by
> > +# the Free Software Foundation; either version 2 of the License, or
> > +# (at your option) any later version.
> > +#
> > +# This program is distributed in the hope that it will be useful,
> > +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > +# GNU General Public License for more details.
> > +#
> > +# You should have received a copy of the GNU General Public License
> > +# along with this program; if not, write to the Free Software
> > +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
> > +
> > +# Please email any bugs, comments, and/or additions to this file to:
> > +# bug-gdb@prep.ai.mit.edu
> > +
> > +# advance.exp -- Expect script to test 'advance' in gdb
> > +
> > +if $tracelevel then {
> > + strace $tracelevel
> > +}
> > +
> > +set testfile advance
> > +set srcfile ${srcdir}/${subdir}/${testfile}.c
> > +set binfile ${objdir}/${subdir}/${testfile}
> > +
> > +remote_exec build "rm -f ${binfile}"
> > +if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } {
> > + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
> > +}
> > +
> > +gdb_exit
> > +gdb_start
> > +gdb_reinitialize_dir $srcdir/$subdir
> > +gdb_load ${binfile}
> > +
> > +if ![runto_main] then {
> > + fail "Can't run to main"
> > + return 0
> > +}
> > +
> > +# Verify that "advance <location>" works. (This is really just syntactic
> > +# sugar for "tbreak <location>; continue".)
> > +#
> > +gdb_test "advance [gdb_get_line_number "advance this location"]" \
> > + "main .* at .*:.*b = 3.*advance this location.*" \
> > + "advance line number"
> > +
> > +# Verify that a malformed "advance" is gracefully caught.
> > +#
> > +gdb_test "advance [gdb_get_line_number "advance malformed"] then stop" \
> > + "Junk at end of arguments." "malformed advance"
> > +
> > +# Verify that "advance <funcname>" works.
> > +#
> > +gdb_test "advance func" \
> > + "func.*at.*x = x \\+ 5." \
> > + "advance func"
> > +
> > +# Verify that "advance <funcname>" when funcname is NOT called by the current
> > +# frame, stops at the end of the current frame.
> > +#
> > +gdb_test "advance func3" \
> > + "in main.*func \\(c\\).*stop here after leaving current frame..."\
> > + "advance function not called by current frame"
> > +
> > +# break at main again
> > +#
> > +gdb_test "break [gdb_get_line_number "break here"]" \
> > + ".*Breakpoint.* at .*" \
> > + "set breakpoint at call to func3"
> > +gdb_test "continue" \
> > + ".*Breakpoint ${decimal}, main.*func3.*break here.*" \
> > + "continue to call to func3 in main"
> > +
> > +# Verify that "advance <funcname>" when funcname is called as parameter to
> > +# another function works.
> > +#
> > +gdb_test "advance foo" \
> > + "foo \\(a=5\\).*int b = a \\+ 10;"\
> > + "advance function called as param"
> > +
> > +# Verify that we get an error if we use 'advance' w/o argument
> > +#
> > +gdb_test "advance" \
> > + "Argument required \\(a location\\)."\
> > + "advance with no argument"
> > +
> >
>
>
>
> --
> Fernando Nasser
> Red Hat - Toronto E-Mail: fnasser@redhat.com
> 2323 Yonge Street, Suite #300
> Toronto, Ontario M4P 2C9