1 # Copyright 2000, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was written by Michael Snyder (msnyder@redhat.com)
25 # re-use the program from the "return2" test.
26 if { [prepare_for_testing finish.exp finish return2.c] } {
30 proc finish_1 { type } {
33 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
34 "set break on ${type}_func"
35 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
36 "continue to ${type}_func"
39 -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" {
40 if { $type == "char" } {
41 pass "finish from char_func"
43 fail "finish from ${type}_func"
46 -re ".*Value returned is .* = \[0123456789\]* '1'\r\n$gdb_prompt $" {
47 if { $type == "char" } {
48 pass "finish from char_func (non-ASCII char set?)"
50 fail "finish from ${type}_func"
53 -re ".*Value returned is .* = 1\r\n$gdb_prompt $" {
54 pass "finish from ${type}_func"
56 -re ".*$gdb_prompt $" {
57 fail "finish from ${type}_func"
60 fail "finish from ${type}_func (timeout)"
65 proc finish_void { } {
68 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
69 "set break on void_func"
70 gdb_test "continue" "Breakpoint.* void_func.*" \
71 "continue to void_func"
73 # Some architectures will have one or more instructions after the
74 # call instruction which still is part of the call sequence, so we
75 # must be prepared for a "finish" to show us the void_func call
76 # again as well as the statement after.
78 -re ".*void_checkpoint.*$gdb_prompt $" {
79 pass "finish from void_func"
81 -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" {
82 pass "finish from void_func"
84 -re ".*$gdb_prompt $" {
85 fail "finish from void_func"
88 fail "finish from void_func (timeout)"
93 # A function that tests that the given ABBREV is a working abbreviation
94 # of the "finish" command.
96 proc finish_abbreviation { abbrev } {
98 if { ! [ runto "int_func" ] } then {
99 fail "running to int_func"
104 "Value returned is .* = 1" \
105 "Testing the \"$abbrev\" abbreviation for \"finish\""
108 proc finish_tests { } {
111 if { ! [ runto_main ] } then {
124 finish_abbreviation "fin"