Commit | Line | Data |
---|---|---|
0fb0cc75 | 1 | # Copyright 2000, 2004, 2007, 2008, 2009 Free Software Foundation, Inc. |
efb66345 MS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
efb66345 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
efb66345 MS |
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. | |
e22f8b7c | 12 | # |
efb66345 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
efb66345 | 15 | |
efb66345 MS |
16 | # This file was written by Michael Snyder (msnyder@redhat.com) |
17 | ||
18 | if $tracelevel then { | |
19 | strace $tracelevel | |
20 | } | |
21 | ||
22 | set prms_id 0 | |
23 | set bug_id 0 | |
24 | ||
25 | # re-use the program from the "return2" test. | |
26 | set testfile "return2" | |
27 | set srcfile ${testfile}.c | |
28 | set binfile ${objdir}/${subdir}/${testfile} | |
29 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
30 | untested finish.exp |
31 | return -1 | |
efb66345 MS |
32 | } |
33 | ||
34 | proc finish_1 { type } { | |
35 | global gdb_prompt | |
36 | ||
37 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
38 | "set break on ${type}_func" | |
39 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
40 | "continue to ${type}_func" | |
41 | send_gdb "finish\n" | |
42 | gdb_expect { | |
315f8b0e | 43 | -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" { |
efb66345 MS |
44 | if { $type == "char" } { |
45 | pass "finish from char_func" | |
46 | } else { | |
315f8b0e MS |
47 | fail "finish from ${type}_func" |
48 | } | |
49 | } | |
50 | -re ".*Value returned is .* = \[0123456789\]* '1'\r\n$gdb_prompt $" { | |
51 | if { $type == "char" } { | |
52 | pass "finish from char_func (non-ASCII char set?)" | |
53 | } else { | |
54 | fail "finish from ${type}_func" | |
efb66345 MS |
55 | } |
56 | } | |
57 | -re ".*Value returned is .* = 1\r\n$gdb_prompt $" { | |
58 | pass "finish from ${type}_func" | |
59 | } | |
60 | -re ".*$gdb_prompt $" { | |
61 | fail "finish from ${type}_func" | |
62 | } | |
63 | timeout { | |
64 | fail "finish from ${type}_func (timeout)" | |
65 | } | |
66 | } | |
67 | } | |
68 | ||
69 | proc finish_void { } { | |
70 | global gdb_prompt | |
71 | ||
72 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
73 | "set break on void_func" | |
74 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
75 | "continue to void_func" | |
76 | send_gdb "finish\n" | |
6b0b0a9e KB |
77 | # Some architectures will have one or more instructions after the |
78 | # call instruction which still is part of the call sequence, so we | |
79 | # must be prepared for a "finish" to show us the void_func call | |
80 | # again as well as the statement after. | |
efb66345 MS |
81 | gdb_expect { |
82 | -re ".*void_checkpoint.*$gdb_prompt $" { | |
83 | pass "finish from void_func" | |
84 | } | |
f6dc23a9 | 85 | -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" { |
6b0b0a9e KB |
86 | pass "finish from void_func" |
87 | } | |
efb66345 MS |
88 | -re ".*$gdb_prompt $" { |
89 | fail "finish from void_func" | |
90 | } | |
91 | timeout { | |
92 | fail "finish from void_func (timeout)" | |
93 | } | |
94 | } | |
95 | } | |
96 | ||
5943254b JB |
97 | # A function that tests that the given ABBREV is a working abbreviation |
98 | # of the "finish" command. | |
99 | ||
100 | proc finish_abbreviation { abbrev } { | |
101 | ||
102 | if { ! [ runto "int_func" ] } then { | |
103 | fail "running to int_func" | |
104 | return -1 | |
105 | } | |
106 | ||
107 | gdb_test "$abbrev" \ | |
108 | "Value returned is .* = 1" \ | |
109 | "Testing the \"$abbrev\" abbreviation for \"finish\"" | |
110 | } | |
111 | ||
efb66345 MS |
112 | proc finish_tests { } { |
113 | global gdb_prompt | |
114 | ||
3ad13771 | 115 | if { ! [ runto_main ] } then { |
b60f0898 JB |
116 | untested finish.exp |
117 | return -1 | |
efb66345 MS |
118 | } |
119 | ||
120 | finish_void | |
121 | finish_1 "char" | |
122 | finish_1 "short" | |
123 | finish_1 "int" | |
124 | finish_1 "long" | |
125 | finish_1 "long_long" | |
126 | finish_1 "float" | |
127 | finish_1 "double" | |
5943254b | 128 | finish_abbreviation "fin" |
efb66345 MS |
129 | } |
130 | ||
131 | # Start with a fresh gdb. | |
132 | ||
133 | gdb_exit | |
134 | gdb_start | |
135 | gdb_reinitialize_dir $srcdir/$subdir | |
136 | gdb_load ${binfile} | |
137 | ||
138 | set timeout 30 | |
139 | finish_tests |