Commit | Line | Data |
---|---|---|
7b6bb8da JB |
1 | # Copyright 2000, 2004, 2007, 2008, 2009, 2010, 2011 |
2 | # Free Software Foundation, Inc. | |
efb66345 MS |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
efb66345 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
efb66345 MS |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
efb66345 | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
efb66345 | 16 | |
efb66345 MS |
17 | # This file was written by Michael Snyder (msnyder@redhat.com) |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
efb66345 MS |
23 | |
24 | # re-use the program from the "return2" test. | |
aa81e255 JK |
25 | if { [prepare_for_testing finish.exp finish return2.c] } { |
26 | return -1 | |
efb66345 MS |
27 | } |
28 | ||
29 | proc finish_1 { type } { | |
30 | global gdb_prompt | |
31 | ||
32 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
33 | "set break on ${type}_func" | |
34 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
35 | "continue to ${type}_func" | |
a76e022a | 36 | gdb_test_multiple "finish" "finish from ${type}_func" { |
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 | } | |
efb66345 MS |
54 | } |
55 | } | |
56 | ||
57 | proc finish_void { } { | |
58 | global gdb_prompt | |
59 | ||
60 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
61 | "set break on void_func" | |
62 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
63 | "continue to void_func" | |
6b0b0a9e KB |
64 | # Some architectures will have one or more instructions after the |
65 | # call instruction which still is part of the call sequence, so we | |
66 | # must be prepared for a "finish" to show us the void_func call | |
67 | # again as well as the statement after. | |
a76e022a | 68 | gdb_test_multiple "finish" "finish from void_func" { |
efb66345 MS |
69 | -re ".*void_checkpoint.*$gdb_prompt $" { |
70 | pass "finish from void_func" | |
71 | } | |
f6dc23a9 | 72 | -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" { |
6b0b0a9e KB |
73 | pass "finish from void_func" |
74 | } | |
efb66345 MS |
75 | } |
76 | } | |
77 | ||
5943254b JB |
78 | # A function that tests that the given ABBREV is a working abbreviation |
79 | # of the "finish" command. | |
80 | ||
81 | proc finish_abbreviation { abbrev } { | |
82 | ||
83 | if { ! [ runto "int_func" ] } then { | |
84 | fail "running to int_func" | |
85 | return -1 | |
86 | } | |
87 | ||
88 | gdb_test "$abbrev" \ | |
89 | "Value returned is .* = 1" \ | |
90 | "Testing the \"$abbrev\" abbreviation for \"finish\"" | |
91 | } | |
92 | ||
efb66345 MS |
93 | proc finish_tests { } { |
94 | global gdb_prompt | |
95 | ||
3ad13771 | 96 | if { ! [ runto_main ] } then { |
b60f0898 JB |
97 | untested finish.exp |
98 | return -1 | |
efb66345 MS |
99 | } |
100 | ||
101 | finish_void | |
102 | finish_1 "char" | |
103 | finish_1 "short" | |
104 | finish_1 "int" | |
105 | finish_1 "long" | |
106 | finish_1 "long_long" | |
d426f7b4 MS |
107 | if ![target_info exists gdb,skip_float_tests] { |
108 | finish_1 "float" | |
109 | finish_1 "double" | |
110 | } | |
5943254b | 111 | finish_abbreviation "fin" |
efb66345 MS |
112 | } |
113 | ||
97f2ed50 | 114 | set prev_timeout $timeout |
efb66345 MS |
115 | set timeout 30 |
116 | finish_tests | |
97f2ed50 | 117 | set timeout $prev_timeout |