2012-01-16 Pedro Alves <palves@redhat.com>
[external/binutils.git] / gdb / testsuite / gdb.base / advance.exp
1 # Copyright 2003, 2007-2012 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 # advance.exp -- Expect script to test 'advance' in gdb
17
18 set testfile advance
19 set srcfile ${testfile}.c
20 set binfile ${objdir}/${subdir}/${testfile}
21
22 remote_exec build "rm -f ${binfile}"
23 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
24     untested advance.exp
25     return -1
26 }
27
28 gdb_exit
29 gdb_start
30 gdb_reinitialize_dir $srcdir/$subdir
31 gdb_load ${binfile}
32
33 if ![runto_main] then {
34     fail "Can't run to main"
35     return 0
36 }
37
38 # Verify that "advance <location>" works.  (This is really just syntactic
39 # sugar for "tbreak <location>; continue".)
40 #
41 gdb_test "advance [gdb_get_line_number "advance this location"]" \
42         "main .* at .*:.*b = 3.*advance this location.*" \
43         "advance line number"
44
45 # Verify that a malformed "advance" is gracefully caught.
46 #
47 gdb_test "advance [gdb_get_line_number "advance malformed"] then stop" \
48         "Junk at end of arguments." "malformed advance"
49
50 # Verify that "advance <funcname>" works.
51 #
52 gdb_test "advance func" \
53         "func.*at.*x = x \\+ 5." \
54         "advance func"
55
56 # Verify that "advance <funcname>" when funcname is NOT called by the current
57 # frame, stops at the end of the current frame.
58 #
59 # gdb can legitimately stop on either the current line or the next line,
60 # depending on whether the machine instruction for 'call' on the current
61 # line has more instructions after it or not.
62 #
63 gdb_test "advance func3" \
64         "(in main|).*(func \\(c\\)|marker1 \\(\\)).*stop here after leaving current frame..."\
65         "advance function not called by current frame"
66
67 # break at main again
68 #
69 gdb_test "break [gdb_get_line_number "break here"]" \
70         ".*Breakpoint.* at .*" \
71         "set breakpoint at call to func3"
72 gdb_test "continue" \
73         ".*Breakpoint ${decimal}, main.*func3.*break here.*" \
74         "continue to call to func3 in main"
75
76 # Verify that "advance <funcname>" when funcname is called as parameter to 
77 # another function works.
78 #
79 gdb_test "advance foo" \
80         "foo \\(a=5\\).*int b = a \\+ 10;"\
81         "advance function called as param"
82
83 # Verify that we get an error if we use 'advance' w/o argument
84 #
85 gdb_test "advance" \
86         "Argument required \\(a location\\)."\
87         "advance with no argument"
88