1# Copyright 2003, 2007 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16# Please email any bugs, comments, and/or additions to this file to: 17# bug-gdb@prep.ai.mit.edu 18 19# until.exp -- Expect script to test 'until' in gdb 20 21if $tracelevel then { 22 strace $tracelevel 23} 24 25set testfile "break" 26set srcfile ${testfile}.c 27set srcfile1 ${testfile}1.c 28set binfile ${objdir}/${subdir}/${testfile} 29 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { 31 untested until.exp 32 return -1 33} 34 35if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { 36 untested until.exp 37 return -1 38} 39 40if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { 41 untested until.exp 42 return -1 43} 44 45gdb_exit 46gdb_start 47gdb_reinitialize_dir $srcdir/$subdir 48gdb_load ${binfile} 49 50set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] 51set bp_location19 [gdb_get_line_number "set breakpoint 19 here"] 52set bp_location20 [gdb_get_line_number "set breakpoint 20 here"] 53set bp_location21 [gdb_get_line_number "set breakpoint 21 here"] 54 55if ![runto_main] then { 56 fail "Can't run to main" 57 return 0 58} 59 60# Verify that "until <location>" works. (This is really just syntactic 61# sugar for "tbreak <location>; continue".) 62# 63gdb_test "until $bp_location1" \ 64 "main .* at .*:$bp_location1.*" \ 65 "until line number" 66 67# Verify that a malformed "advance" is gracefully caught. 68# 69gdb_test "until 80 then stop" \ 70 "Junk at end of arguments." "malformed until" 71 72# Rerun up to factorial, outer invocation 73if { ![runto factorial] } then { gdb_suppress_tests; } 74delete_breakpoints 75 76# At this point, 'until' should continue the inferior up to when all the 77# inner invocations of factorial() are completed and we are back at this 78# frame. 79# 80gdb_test "until $bp_location19" \ 81 "factorial.*value=720.*at.*${srcfile}:$bp_location19.*return \\(value\\).*" \ 82 "until factorial, recursive function" 83 84# Run to a function called by main 85# 86if { ![runto marker2] } then { gdb_suppress_tests; } 87delete_breakpoints 88 89# Now issue an until with another function, not called by the current 90# frame, as argument. This should not work, i.e. the program should 91# stop at main, the caller, where we put the 'guard' breakpoint. 92# 93gdb_test "until marker3" \ 94 "($hex in |)main.*argc.*argv.*envp.*at.*${srcfile}:($bp_location20.*marker2 \\(43\\)|$bp_location21.*marker3 \\(.stack., .trace.\\)).*" \ 95 "until func, not called by current frame" 96 97