]> Git Repo - binutils.git/blob - gdb/testsuite/gdb.ctf/funcreturn.exp
Automatic date update in version.in
[binutils.git] / gdb / testsuite / gdb.ctf / funcreturn.exp
1 # Copyright 2021-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 if [skip_ctf_tests] {
17     unsupported "no CTF debug format support, or CTF disabled in GDB"
18     return 0
19 }
20
21 if [target_info exists no_long_long] {
22     set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
23 } else {
24     set exec_opts [list debug]
25 }
26
27 # Some tests require GCC.
28 set gcc_compiled [is_c_compiler_gcc]
29
30 standard_testfile whatis.c
31
32 # Using `-gctf` generates full-fledged CTF debug information.
33 set opts {}
34 lappend opts additional_flags=-gctf
35 lappend opts ldflags=-Wl,--export-dynamic
36 lappend opts ldflags=-Wl,--strip-debug
37 lappend opts nowarning
38
39 if { [prepare_for_testing "failed to prepare" ${testfile} \
40           [list $srcfile] $opts] } {
41     return 0
42 }
43
44 # test print command with functions return type
45 set void "(void|)"
46 gdb_test "print v_char_func" \
47     "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ <v_char_func>.*" \
48     "print char function"
49
50 gdb_test "print v_signed_char_func" \
51     "$decimal = \{signed char \\(\\)\} 0x\[0-9a-z\]+ <v_signed_char_func>.*" \
52     "print signed char function"
53
54 gdb_test "print v_unsigned_char_func" \
55     "$decimal = \{unsigned char \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_char_func>.*" \
56     "print unsigned char function"
57
58 gdb_test "print v_short_func" \
59     "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ <v_short_func>.*" \
60     "print short function"
61
62 gdb_test "print v_signed_short_func" \
63     "$decimal = \{signed short|short \\(\\)\} 0x\[0-9a-z\]+ <v_signed_short_func>.*" \
64     "print signed short function"
65
66 gdb_test "print v_unsigned_short_func" \
67     "$decimal = \{unsigned short \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_short_func>.*" \
68     "print unsigned short function"
69
70 gdb_test "print v_int_func" \
71     "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ <v_int_func>.*" \
72     "print int function"
73
74 gdb_test "print v_signed_int_func" \
75     "$decimal = \{signed int|int \\(\\)\} 0x\[0-9a-z\]+ <v_signed_int_func>.*" \
76     "print signed int function"
77
78 gdb_test "print v_unsigned_int_func" \
79     "$decimal = \{unsigned int \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_int_func>.*" \
80     "print unsigned int function"
81
82 gdb_test "print v_long_func" \
83     "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ <v_long_func>.*" \
84     "print long function"
85
86 gdb_test "print v_signed_long_func" \
87     "$decimal = \{signed long|long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_func>.*" \
88     "print signed long function"
89
90 gdb_test "print v_unsigned_long_func" \
91     "$decimal = \{unsigned long|long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_func>.*" \
92     "print unsigned long function"
93
94 if ![target_info exists no_long_long] {
95     gdb_test "print v_long_long_func" \
96             "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_long_long_func>.*" \
97                 "print long long function"
98
99     gdb_test "print v_signed_long_long_func" \
100             "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_long_func>.*" \
101                 "print signed long long function"
102
103     gdb_test "print v_unsigned_long_long_func" \
104             "$decimal = \{unsigned long long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_long_func>.*" \
105                 "print unsigned long long function"
106 }
107
108 # Sun /bin/cc calls this a function returning double.
109 if {!$gcc_compiled} {setup_xfail "*-sun-sunos4*"}
110 gdb_test "print v_float_func" \
111     "$decimal = \{float \\(\\)\} 0x\[0-9a-z\]+.*" \
112     "print float function"
113
114 gdb_test "print v_double_func" \
115     "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \
116     "print double function"
117
118 # test whatis command with functions return type
119 gdb_test "whatis v_char_func" \
120     "type = (signed |unsigned |)char \\($void\\)" \
121     "whatis char function"
122
123 gdb_test "whatis v_signed_char_func" \
124     "type = (signed |unsigned |)char \\($void\\)" \
125     "whatis signed char function"
126
127 gdb_test "whatis v_unsigned_char_func" \
128     "type = unsigned char \\($void\\)"  \
129     "whatis unsigned char function"
130
131 gdb_test "whatis v_short_func" \
132     "type = short (int |)\\($void\\)" \
133     "whatis short function"
134
135 gdb_test "whatis v_signed_short_func" \
136     "type = (signed |)short (int |)\\($void\\)" \
137     "whatis signed short function"
138
139 gdb_test "whatis v_unsigned_short_func" \
140     "type = (unsigned short|short unsigned int) \\($void\\)" \
141     "whatis unsigned short function"
142
143 gdb_test "whatis v_int_func" \
144     "type = int \\($void\\)" \
145     "whatis int function"
146
147 gdb_test "whatis v_signed_int_func" \
148     "type = (signed |)int \\($void\\)" \
149     "whatis signed int function"
150
151 gdb_test "whatis v_unsigned_int_func" \
152     "type = unsigned int \\($void\\)" \
153     "whatis unsigned int function"
154
155 gdb_test "whatis v_long_func" \
156     "type = (long|int|long int) \\($void\\)" \
157     "whatis long function"
158
159 gdb_test "whatis v_signed_long_func" \
160     "type = (signed |)(int|long|long int) \\($void\\)" \
161     "whatis signed long function"
162
163 gdb_test "whatis v_unsigned_long_func" \
164     "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
165     "whatis unsigned long function"
166
167 if ![target_info exists no_long_long] {
168     gdb_test "whatis v_long_long_func" \
169         "type = long long(| int) \\($void\\)" \
170         "whatis long long function"
171
172     gdb_test "whatis v_signed_long_long_func" \
173         "type = (signed |)long long(| int) \\($void\\)" \
174         "whatis signed long long function"
175
176     gdb_test "whatis v_unsigned_long_long_func" \
177         "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \
178         "whatis unsigned long long function"
179 }
180
181 # Sun /bin/cc calls this a function returning double.
182 if {!$gcc_compiled} {setup_xfail "*-sun-sunos4*"}
183 gdb_test "whatis v_float_func" \
184     "type = float \\($void\\)" \
185     "whatis float function"
186
187 gdb_test "whatis v_double_func" \
188     "type = double \\($void\\)" \
189     "whatis double function"
This page took 0.036623 seconds and 4 git commands to generate.