Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2021-2022 Free Software Foundation, Inc. |
ea11a98d WP |
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 | standard_testfile whatis.c | |
28 | ||
29 | # Using `-gt` generates full-fledged CTF debug information. | |
30 | set opts "additional_flags=-gt -Wl,--export-dynamic" | |
31 | ||
32 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
33 | [list $srcfile] [list $opts nowarnings]] } { | |
34 | return 0 | |
35 | } | |
36 | ||
37 | # Create and source the file that provides information about the compiler | |
38 | # used to compile the test case. | |
39 | if [get_compiler_info] { | |
40 | return -1 | |
41 | } | |
42 | ||
43 | # test print command with functions return type | |
44 | set void "(void|)" | |
45 | gdb_test "print v_char_func" \ | |
46 | "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ <v_char_func>.*" \ | |
47 | "print char function" | |
48 | ||
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" | |
52 | ||
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" | |
56 | ||
57 | gdb_test "print v_short_func" \ | |
58 | "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ <v_short_func>.*" \ | |
59 | "print short function" | |
60 | ||
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" | |
64 | ||
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" | |
68 | ||
69 | gdb_test "print v_int_func" \ | |
70 | "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ <v_int_func>.*" \ | |
71 | "print int function" | |
72 | ||
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" | |
76 | ||
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" | |
80 | ||
81 | gdb_test "print v_long_func" \ | |
82 | "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ <v_long_func>.*" \ | |
83 | "print long function" | |
84 | ||
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" | |
88 | ||
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" | |
92 | ||
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" | |
97 | ||
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" | |
101 | ||
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" | |
105 | } | |
106 | ||
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" | |
112 | ||
113 | gdb_test "print v_double_func" \ | |
114 | "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \ | |
115 | "print double function" \ | |
116 | } | |
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} then {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" \ | |
190 | } |