Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / finish.exp
1 # Copyright 2000-2022 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 # This file was written by Michael Snyder (msnyder@redhat.com)
17
18 set skip_float_test [gdb_skip_float_test]
19
20 # re-use the program from the "return2" test.
21 if { [prepare_for_testing "failed to prepare" finish return2.c] } {
22 return -1
23 }
24
25 proc 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"
32 gdb_test_multiple "finish" "finish from ${type}_func" {
33 -re ".*Value returned is .* = 49 '1'\r\n$gdb_prompt $" {
34 if { $type == "char" } {
35 pass "finish from char_func"
36 } else {
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"
45 }
46 }
47 -re ".*Value returned is .* = 1\r\n$gdb_prompt $" {
48 pass "finish from ${type}_func"
49 }
50 }
51 }
52
53 proc 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"
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.
64 gdb_test_multiple "finish" "finish from void_func" {
65 -re ".*void_checkpoint.*$gdb_prompt $" {
66 pass "finish from void_func"
67 }
68 -re "0x\[0-9a-fA-F\]+ in main.*call to void_func.*$gdb_prompt $" {
69 pass "finish from void_func"
70 }
71 }
72 }
73
74 # A function that tests that the given ABBREV is a working abbreviation
75 # of the "finish" command.
76
77 proc finish_abbreviation { abbrev } {
78
79 if { ! [ runto "int_func" ] } then {
80 fail "running to int_func"
81 return -1
82 }
83
84 gdb_test "$abbrev" \
85 "Value returned is .* = 1" \
86 "Testing the \"$abbrev\" abbreviation for \"finish\""
87 }
88
89 # Test "set print finish off".
90 proc finish_no_print {} {
91 global decimal
92
93 if {![runto "int_func"]} {
94 untested "couldn't run to main"
95 return
96 }
97 gdb_test_no_output "set print finish off"
98 gdb_test "finish" \
99 "Value returned is \\\$$decimal = <not displayed>"
100 gdb_test "print \$" " = 1" \
101 "Ensure return value was properly saved"
102 }
103
104 proc finish_tests { } {
105 global gdb_prompt skip_float_test
106
107 if { ! [ runto_main ] } then {
108 untested "couldn't run to main"
109 return -1
110 }
111
112 finish_void
113 finish_1 "char"
114 finish_1 "short"
115 finish_1 "int"
116 finish_1 "long"
117 finish_1 "long_long"
118 if {!$skip_float_test} {
119 finish_1 "float"
120 finish_1 "double"
121 }
122 finish_abbreviation "fin"
123 finish_no_print
124 }
125
126 set prev_timeout $timeout
127 set timeout 30
128 finish_tests
129 set timeout $prev_timeout
This page took 0.031084 seconds and 4 git commands to generate.