2003-01-15 Elena Zannoni <ezannoni@redhat.com>

* 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.
This commit is contained in:
Elena Zannoni 2003-01-15 14:25:11 +00:00
parent aa23648714
commit 82025e1307
5 changed files with 226 additions and 25 deletions

View File

@ -1,3 +1,10 @@
2003-01-15 Elena Zannoni <ezannoni@redhat.com>
* 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.
2003-01-14 Elena Zannoni <ezannoni@redhat.com>
* gdb.base/args.c: New file.

View File

@ -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 */
}

View File

@ -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"

View File

@ -1,5 +1,5 @@
# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2002
# 2000, 2002, 2003
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@ -154,6 +154,7 @@ if {$hp_aCC_compiler} {
} else {
set proto ""
}
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
@ -166,7 +167,6 @@ gdb_test "info break" \
\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:124" \
"breakpoint info"
# FIXME: The rest of this test doesn't work with anything that can't
# handle arguments.
# Huh? There doesn't *appear* to be anything that passes arguments
@ -363,29 +363,6 @@ gdb_expect {
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
# on a nonexistent source line.
#

View File

@ -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"