]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/until.exp
Fix for PR gdb/1543.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / until.exp
1 # Copyright 2003, 2007, 2008 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 # until.exp -- Expect script to test 'until' in gdb
17
18 if $tracelevel then {
19 strace $tracelevel
20 }
21
22 set testfile "break"
23 set srcfile ${testfile}.c
24 set srcfile1 ${testfile}1.c
25 set binfile ${objdir}/${subdir}/${testfile}
26
27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
28 untested until.exp
29 return -1
30 }
31
32 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
33 untested until.exp
34 return -1
35 }
36
37 if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
38 untested until.exp
39 return -1
40 }
41
42 gdb_exit
43 gdb_start
44 gdb_reinitialize_dir $srcdir/$subdir
45 gdb_load ${binfile}
46
47 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
48 set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
49 set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
50 set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
51
52 if ![runto_main] then {
53 fail "Can't run to main"
54 return 0
55 }
56
57 # Verify that "until <location>" works. (This is really just syntactic
58 # sugar for "tbreak <location>; continue".)
59 #
60 gdb_test "until $bp_location1" \
61 "main .* at .*:$bp_location1.*" \
62 "until line number"
63
64 # Verify that a malformed "advance" is gracefully caught.
65 #
66 gdb_test "until 80 then stop" \
67 "Junk at end of arguments." "malformed until"
68
69 # Rerun up to factorial, outer invocation
70 if { ![runto factorial] } then { gdb_suppress_tests; }
71 delete_breakpoints
72
73 # At this point, 'until' should continue the inferior up to when all the
74 # inner invocations of factorial() are completed and we are back at this
75 # frame.
76 #
77 gdb_test "until $bp_location19" \
78 "factorial.*value=720.*at.*${srcfile}:$bp_location19.*return \\(value\\).*" \
79 "until factorial, recursive function"
80
81 # Run to a function called by main
82 #
83 if { ![runto marker2] } then { gdb_suppress_tests; }
84 delete_breakpoints
85
86 # Now issue an until with another function, not called by the current
87 # frame, as argument. This should not work, i.e. the program should
88 # stop at main, the caller, where we put the 'guard' breakpoint.
89 #
90 gdb_test "until marker3" \
91 "($hex in |)main.*argc.*argv.*envp.*at.*${srcfile}:($bp_location20.*marker2 \\(43\\)|$bp_location21.*marker3 \\(.stack., .trace.\\)).*" \
92 "until func, not called by current frame"
93