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 # Some tests require GCC.
28 set gcc_compiled [is_c_compiler_gcc]
30 standard_testfile whatis.c
32 # Using `-gctf` generates full-fledged CTF debug information.
34 lappend opts additional_flags=-gctf
35 lappend opts ldflags=-Wl,--export-dynamic
36 lappend opts ldflags=-Wl,--strip-debug
37 lappend opts nowarning
39 if { [prepare_for_testing "failed to prepare" ${testfile} \
40 [list $srcfile] $opts] } {
44 # test print command with functions return type
46 gdb_test "print v_char_func" \
47 "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ <v_char_func>.*" \
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"
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"
58 gdb_test "print v_short_func" \
59 "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ <v_short_func>.*" \
60 "print short function"
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"
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"
70 gdb_test "print v_int_func" \
71 "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ <v_int_func>.*" \
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"
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"
82 gdb_test "print v_long_func" \
83 "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ <v_long_func>.*" \
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"
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"
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"
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"
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"
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"
114 gdb_test "print v_double_func" \
115 "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \
116 "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} {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"