1 # Copyright 2021-2022 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/>.
17 unsupported "no CTF debug format support, or CTF disabled in GDB"
21 if [target_info exists no_long_long] {
22 set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
24 set exec_opts [list debug]
27 standard_testfile whatis.c
29 # Using `-gctf` generates full-fledged CTF debug information.
30 set opts "additional_flags=-gctf -Wl,--export-dynamic"
32 if { [prepare_for_testing "failed to prepare" ${testfile} \
33 [list $srcfile] [list $opts nowarnings]] } {
37 # Create and source the file that provides information about the compiler
38 # used to compile the test case.
39 if [get_compiler_info] {
43 # test print command with functions return type
45 gdb_test "print v_char_func" \
46 "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ <v_char_func>.*" \
49 gdb_test "print v_signed_char_func" \
50 "$decimal = \{signed char \\(\\)\} 0x\[0-9a-z\]+ <v_signed_char_func>.*" \
51 "print signed char function"
53 gdb_test "print v_unsigned_char_func" \
54 "$decimal = \{unsigned char \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_char_func>.*" \
55 "print unsigned char function"
57 gdb_test "print v_short_func" \
58 "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ <v_short_func>.*" \
59 "print short function"
61 gdb_test "print v_signed_short_func" \
62 "$decimal = \{signed short|short \\(\\)\} 0x\[0-9a-z\]+ <v_signed_short_func>.*" \
63 "print signed short function"
65 gdb_test "print v_unsigned_short_func" \
66 "$decimal = \{unsigned short \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_short_func>.*" \
67 "print unsigned short function"
69 gdb_test "print v_int_func" \
70 "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ <v_int_func>.*" \
73 gdb_test "print v_signed_int_func" \
74 "$decimal = \{signed int|int \\(\\)\} 0x\[0-9a-z\]+ <v_signed_int_func>.*" \
75 "print signed int function"
77 gdb_test "print v_unsigned_int_func" \
78 "$decimal = \{unsigned int \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_int_func>.*" \
79 "print unsigned int function"
81 gdb_test "print v_long_func" \
82 "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ <v_long_func>.*" \
85 gdb_test "print v_signed_long_func" \
86 "$decimal = \{signed long|long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_func>.*" \
87 "print signed long function"
89 gdb_test "print v_unsigned_long_func" \
90 "$decimal = \{unsigned long|long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_func>.*" \
91 "print unsigned long function"
93 if ![target_info exists no_long_long] {
94 gdb_test "print v_long_long_func" \
95 "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_long_long_func>.*" \
96 "print long long function"
98 gdb_test "print v_signed_long_long_func" \
99 "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_signed_long_long_func>.*" \
100 "print signed long long function"
102 gdb_test "print v_unsigned_long_long_func" \
103 "$decimal = \{unsigned long long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_long_func>.*" \
104 "print unsigned long long function"
107 # Sun /bin/cc calls this a function returning double.
108 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
109 gdb_test "print v_float_func" \
110 "$decimal = \{float \\(\\)\} 0x\[0-9a-z\]+.*" \
111 "print float function"
113 gdb_test "print v_double_func" \
114 "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \
115 "print double function" \
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"
123 gdb_test "whatis v_signed_char_func" \
124 "type = (signed |unsigned |)char \\($void\\)" \
125 "whatis signed char function"
127 gdb_test "whatis v_unsigned_char_func" \
128 "type = unsigned char \\($void\\)" \
129 "whatis unsigned char function"
131 gdb_test "whatis v_short_func" \
132 "type = short (int |)\\($void\\)" \
133 "whatis short function"
135 gdb_test "whatis v_signed_short_func" \
136 "type = (signed |)short (int |)\\($void\\)" \
137 "whatis signed short function"
139 gdb_test "whatis v_unsigned_short_func" \
140 "type = (unsigned short|short unsigned int) \\($void\\)" \
141 "whatis unsigned short function"
143 gdb_test "whatis v_int_func" \
144 "type = int \\($void\\)" \
145 "whatis int function"
147 gdb_test "whatis v_signed_int_func" \
148 "type = (signed |)int \\($void\\)" \
149 "whatis signed int function"
151 gdb_test "whatis v_unsigned_int_func" \
152 "type = unsigned int \\($void\\)" \
153 "whatis unsigned int function"
155 gdb_test "whatis v_long_func" \
156 "type = (long|int|long int) \\($void\\)" \
157 "whatis long function"
159 gdb_test "whatis v_signed_long_func" \
160 "type = (signed |)(int|long|long int) \\($void\\)" \
161 "whatis signed long function"
163 gdb_test "whatis v_unsigned_long_func" \
164 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
165 "whatis unsigned long function"
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"
172 gdb_test "whatis v_signed_long_long_func" \
173 "type = (signed |)long long(| int) \\($void\\)" \
174 "whatis signed long long function"
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"
181 # Sun /bin/cc calls this a function returning double.
182 if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"}
183 gdb_test "whatis v_float_func" \
184 "type = float \\($void\\)" \
185 "whatis float function"
187 gdb_test "whatis v_double_func" \
188 "type = double \\($void\\)" \
189 "whatis double function" \