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