From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31229 invoked by alias); 14 Jan 2003 23:12:25 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31178 invoked from network); 14 Jan 2003 23:12:23 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by 209.249.29.67 with SMTP; 14 Jan 2003 23:12:23 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h0EMhvB16825 for ; Tue, 14 Jan 2003 17:43:57 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h0ENCBa06272; Tue, 14 Jan 2003 18:12:11 -0500 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h0ENCAb16652; Tue, 14 Jan 2003 18:12:11 -0500 Received: by localhost.redhat.com (Postfix, from userid 469) id 3178BFF79; Tue, 14 Jan 2003 18:16:32 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15908.39503.970119.48841@localhost.redhat.com> Date: Tue, 14 Jan 2003 23:12:00 -0000 To: fnasser@redhat.com, gdb-patches@sources.redhat.com Subject: [RFA/testsuite] advance.exp/until.exp X-SW-Source: 2003-01/txt/msg00543.txt.bz2 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 " works. (This is really just syntactic -# sugar for "tbreak ; 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 " works. (This is really just syntactic +# sugar for "tbreak ; 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 " works. (This is really just syntactic +# sugar for "tbreak ; 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 " works. +# +gdb_test "advance func" \ + "func.*at.*x = x \\+ 5." \ + "advance func" + +# Verify that "advance " 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 " 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" +