]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2000, 2004, 2007 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 | |
5 | # the Free Software Foundation; either version 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Michael Snyder (msnyder@redhat.com) | |
21 | ||
22 | if $tracelevel then { | |
23 | strace $tracelevel | |
24 | } | |
25 | ||
26 | set prms_id 0 | |
27 | set bug_id 0 | |
28 | ||
29 | # re-use the program from the "return2" test. | |
30 | set testfile "return2" | |
31 | set srcfile ${testfile}.c | |
32 | set binfile ${objdir}/${subdir}/${testfile} | |
33 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
34 | untested finish.exp |
35 | return -1 | |
efb66345 MS |
36 | } |
37 | ||
38 | proc finish_1 { type } { | |
39 | global gdb_prompt | |
40 | ||
41 | gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \ | |
42 | "set break on ${type}_func" | |
43 | gdb_test "continue" "Breakpoint.* ${type}_func.*" \ | |
44 | "continue to ${type}_func" | |
45 | send_gdb "finish\n" | |
46 | gdb_expect { | |
315f8b0e | 47 | -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" { |
efb66345 MS |
48 | if { $type == "char" } { |
49 | pass "finish from char_func" | |
50 | } else { | |
315f8b0e MS |
51 | fail "finish from ${type}_func" |
52 | } | |
53 | } | |
54 | -re ".*Value returned is .* = \[0123456789\]* '1'\r\n$gdb_prompt $" { | |
55 | if { $type == "char" } { | |
56 | pass "finish from char_func (non-ASCII char set?)" | |
57 | } else { | |
58 | fail "finish from ${type}_func" | |
efb66345 MS |
59 | } |
60 | } | |
61 | -re ".*Value returned is .* = 1\r\n$gdb_prompt $" { | |
62 | pass "finish from ${type}_func" | |
63 | } | |
64 | -re ".*$gdb_prompt $" { | |
65 | fail "finish from ${type}_func" | |
66 | } | |
67 | timeout { | |
68 | fail "finish from ${type}_func (timeout)" | |
69 | } | |
70 | } | |
71 | } | |
72 | ||
73 | proc finish_void { } { | |
74 | global gdb_prompt | |
75 | ||
76 | gdb_test "break void_func" "Breakpoint \[0123456789\].*" \ | |
77 | "set break on void_func" | |
78 | gdb_test "continue" "Breakpoint.* void_func.*" \ | |
79 | "continue to void_func" | |
80 | send_gdb "finish\n" | |
6b0b0a9e KB |
81 | # Some architectures will have one or more instructions after the |
82 | # call instruction which still is part of the call sequence, so we | |
83 | # must be prepared for a "finish" to show us the void_func call | |
84 | # again as well as the statement after. | |
efb66345 MS |
85 | gdb_expect { |
86 | -re ".*void_checkpoint.*$gdb_prompt $" { | |
87 | pass "finish from void_func" | |
88 | } | |
f6dc23a9 | 89 | -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" { |
6b0b0a9e KB |
90 | pass "finish from void_func" |
91 | } | |
efb66345 MS |
92 | -re ".*$gdb_prompt $" { |
93 | fail "finish from void_func" | |
94 | } | |
95 | timeout { | |
96 | fail "finish from void_func (timeout)" | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | proc finish_tests { } { | |
102 | global gdb_prompt | |
103 | ||
3ad13771 | 104 | if { ! [ runto_main ] } then { |
b60f0898 JB |
105 | untested finish.exp |
106 | return -1 | |
efb66345 MS |
107 | } |
108 | ||
109 | finish_void | |
110 | finish_1 "char" | |
111 | finish_1 "short" | |
112 | finish_1 "int" | |
113 | finish_1 "long" | |
114 | finish_1 "long_long" | |
115 | finish_1 "float" | |
116 | finish_1 "double" | |
117 | } | |
118 | ||
119 | # Start with a fresh gdb. | |
120 | ||
121 | gdb_exit | |
122 | gdb_start | |
123 | gdb_reinitialize_dir $srcdir/$subdir | |
124 | gdb_load ${binfile} | |
125 | ||
126 | set timeout 30 | |
127 | finish_tests |