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