]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/finish.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / finish.exp
CommitLineData
213516ef 1# Copyright 2000-2023 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
27aba047 18set skip_float_test [gdb_skip_float_test]
efb66345
MS
19
20# re-use the program from the "return2" test.
5b362f04 21if { [prepare_for_testing "failed to prepare" finish return2.c] } {
aa81e255 22 return -1
efb66345
MS
23}
24
25proc finish_1 { type } {
26 global gdb_prompt
27
28 gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
29 "set break on ${type}_func"
30 gdb_test "continue" "Breakpoint.* ${type}_func.*" \
31 "continue to ${type}_func"
a76e022a 32 gdb_test_multiple "finish" "finish from ${type}_func" {
315f8b0e 33 -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" {
efb66345
MS
34 if { $type == "char" } {
35 pass "finish from char_func"
36 } else {
315f8b0e
MS
37 fail "finish from ${type}_func"
38 }
39 }
40 -re ".*Value returned is .* = \[0123456789\]* '1'\r\n$gdb_prompt $" {
41 if { $type == "char" } {
42 pass "finish from char_func (non-ASCII char set?)"
43 } else {
44 fail "finish from ${type}_func"
efb66345
MS
45 }
46 }
47 -re ".*Value returned is .* = 1\r\n$gdb_prompt $" {
48 pass "finish from ${type}_func"
49 }
efb66345
MS
50 }
51}
52
53proc finish_void { } {
54 global gdb_prompt
55
56 gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
57 "set break on void_func"
58 gdb_test "continue" "Breakpoint.* void_func.*" \
59 "continue to void_func"
6b0b0a9e
KB
60 # Some architectures will have one or more instructions after the
61 # call instruction which still is part of the call sequence, so we
62 # must be prepared for a "finish" to show us the void_func call
63 # again as well as the statement after.
a76e022a 64 gdb_test_multiple "finish" "finish from void_func" {
efb66345
MS
65 -re ".*void_checkpoint.*$gdb_prompt $" {
66 pass "finish from void_func"
67 }
f6dc23a9 68 -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" {
6b0b0a9e
KB
69 pass "finish from void_func"
70 }
efb66345
MS
71 }
72}
73
5943254b
JB
74# A function that tests that the given ABBREV is a working abbreviation
75# of the "finish" command.
76
77proc finish_abbreviation { abbrev } {
78
65a33d75 79 if {![runto "int_func"]} {
5943254b
JB
80 return -1
81 }
82
83 gdb_test "$abbrev" \
84 "Value returned is .* = 1" \
85 "Testing the \"$abbrev\" abbreviation for \"finish\""
86}
87
000439d5
TT
88# Test "set print finish off".
89proc finish_no_print {} {
90 global decimal
91
92 if {![runto "int_func"]} {
000439d5
TT
93 return
94 }
95 gdb_test_no_output "set print finish off"
96 gdb_test "finish" \
97 "Value returned is \\\$$decimal = <not displayed>"
98 gdb_test "print \$" " = 1" \
99 "Ensure return value was properly saved"
100}
101
efb66345 102proc finish_tests { } {
27aba047 103 global gdb_prompt skip_float_test
efb66345 104
65a33d75 105 if {![runto_main]} {
b60f0898 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"
27aba047 115 if {!$skip_float_test} {
d426f7b4
MS
116 finish_1 "float"
117 finish_1 "double"
118 }
5943254b 119 finish_abbreviation "fin"
000439d5 120 finish_no_print
efb66345
MS
121}
122
97f2ed50 123set prev_timeout $timeout
efb66345
MS
124set timeout 30
125finish_tests
97f2ed50 126set timeout $prev_timeout