Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 2000, 2004, 2007, 2008, 2009, 2010 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 | ||
efb66345 MS |
22 | |
23 | # re-use the program from the "return2" test. | |
aa81e255 JK |
24 | if { [prepare_for_testing finish.exp finish return2.c] } { |
25 | return -1 | |
efb66345 MS |
26 | } |
27 | ||
28 | proc finish_1 { type } { | |
29 | global gdb_prompt | |
30 | ||
31 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
32 | "set break on ${type}_func" | |
33 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
34 | "continue to ${type}_func" | |
35 | send_gdb "finish\n" | |
36 | gdb_expect { | |
315f8b0e | 37 | -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" { |
efb66345 MS |
38 | if { $type == "char" } { |
39 | pass "finish from char_func" | |
40 | } else { | |
315f8b0e MS |
41 | fail "finish from ${type}_func" |
42 | } | |
43 | } | |
44 | -re ".*Value returned is .* = \[0123456789\]* '1'\r\n$gdb_prompt $" { | |
45 | if { $type == "char" } { | |
46 | pass "finish from char_func (non-ASCII char set?)" | |
47 | } else { | |
48 | fail "finish from ${type}_func" | |
efb66345 MS |
49 | } |
50 | } | |
51 | -re ".*Value returned is .* = 1\r\n$gdb_prompt $" { | |
52 | pass "finish from ${type}_func" | |
53 | } | |
54 | -re ".*$gdb_prompt $" { | |
55 | fail "finish from ${type}_func" | |
56 | } | |
57 | timeout { | |
58 | fail "finish from ${type}_func (timeout)" | |
59 | } | |
60 | } | |
61 | } | |
62 | ||
63 | proc finish_void { } { | |
64 | global gdb_prompt | |
65 | ||
66 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
67 | "set break on void_func" | |
68 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
69 | "continue to void_func" | |
70 | send_gdb "finish\n" | |
6b0b0a9e KB |
71 | # Some architectures will have one or more instructions after the |
72 | # call instruction which still is part of the call sequence, so we | |
73 | # must be prepared for a "finish" to show us the void_func call | |
74 | # again as well as the statement after. | |
efb66345 MS |
75 | gdb_expect { |
76 | -re ".*void_checkpoint.*$gdb_prompt $" { | |
77 | pass "finish from void_func" | |
78 | } | |
f6dc23a9 | 79 | -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" { |
6b0b0a9e KB |
80 | pass "finish from void_func" |
81 | } | |
efb66345 MS |
82 | -re ".*$gdb_prompt $" { |
83 | fail "finish from void_func" | |
84 | } | |
85 | timeout { | |
86 | fail "finish from void_func (timeout)" | |
87 | } | |
88 | } | |
89 | } | |
90 | ||
5943254b JB |
91 | # A function that tests that the given ABBREV is a working abbreviation |
92 | # of the "finish" command. | |
93 | ||
94 | proc finish_abbreviation { abbrev } { | |
95 | ||
96 | if { ! [ runto "int_func" ] } then { | |
97 | fail "running to int_func" | |
98 | return -1 | |
99 | } | |
100 | ||
101 | gdb_test "$abbrev" \ | |
102 | "Value returned is .* = 1" \ | |
103 | "Testing the \"$abbrev\" abbreviation for \"finish\"" | |
104 | } | |
105 | ||
efb66345 MS |
106 | proc finish_tests { } { |
107 | global gdb_prompt | |
108 | ||
3ad13771 | 109 | if { ! [ runto_main ] } then { |
b60f0898 JB |
110 | untested finish.exp |
111 | return -1 | |
efb66345 MS |
112 | } |
113 | ||
114 | finish_void | |
115 | finish_1 "char" | |
116 | finish_1 "short" | |
117 | finish_1 "int" | |
118 | finish_1 "long" | |
119 | finish_1 "long_long" | |
120 | finish_1 "float" | |
121 | finish_1 "double" | |
5943254b | 122 | finish_abbreviation "fin" |
efb66345 MS |
123 | } |
124 | ||
97f2ed50 | 125 | set prev_timeout $timeout |
efb66345 MS |
126 | set timeout 30 |
127 | finish_tests | |
97f2ed50 | 128 | set timeout $prev_timeout |