1# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003, 2# 2004, 2007 Free Software Foundation, Inc. 3 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation; either version 3 of the License, or 7# (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17# This file was written by Rob Savoye. (rob@cygnus.com) 18 19if $tracelevel { 20 strace $tracelevel 21} 22 23# 24# test running programs 25# 26set prms_id 0 27set bug_id 0 28 29set testfile whatis 30set srcfile ${testfile}.c 31set binfile ${objdir}/${subdir}/${testfile} 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 33 untested whatis.exp 34 return -1 35} 36 37# Create and source the file that provides information about the compiler 38# used to compile the test case. 39if [get_compiler_info ${binfile}] { 40 return -1; 41} 42 43# Start with a fresh gdb. 44 45gdb_exit 46gdb_start 47gdb_reinitialize_dir $srcdir/$subdir 48gdb_load $binfile 49 50# Define a procedure to set up an xfail for all targets that put out a 51# `long' type as an `int' type. 52# Sun/Ultrix cc have this problem. 53# It was said that COFF targets can not distinguish int from long either. 54 55proc setup_xfail_on_long_vs_int {} { 56 global gcc_compiled 57 58 if {!$gcc_compiled} { 59 setup_xfail "*-sun-sunos4*" "*-*-ultrix*" "i*86-sequent-bsd*" 60 } 61} 62 63# 64# Test whatis command with basic C types 65# 66# The name printed now (as of 23 May 1993) is whatever name the compiler 67# uses in the stabs. So we need to deal with names both from gcc and 68# native compilers. 69# 70 71gdb_test "whatis v_char" \ 72 "type = (unsigned char|char)" \ 73 "whatis char" 74 75if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } 76gdb_test "whatis v_signed_char" \ 77 "type = (signed char|char)" \ 78 "whatis signed char" 79 80gdb_test "whatis v_unsigned_char" \ 81 "type = unsigned char" \ 82 "whatis unsigned char" 83 84gdb_test "whatis v_short" \ 85 "type = (short|short int)" \ 86 "whatis short" 87 88gdb_test "whatis v_signed_short" \ 89 "type = (short|short int|signed short|signed short int)" \ 90 "whatis signed short" 91 92gdb_test "whatis v_unsigned_short" \ 93 "type = (unsigned short|short unsigned int)" \ 94 "whatis unsigned short" 95 96gdb_test "whatis v_int" \ 97 "type = int" \ 98 "whatis int" 99 100gdb_test "whatis v_signed_int" \ 101 "type = (signed |)int" \ 102 "whatis signed int" 103 104gdb_test "whatis v_unsigned_int" \ 105 "type = unsigned int" \ 106 "whatis unsigned int" 107 108setup_xfail_on_long_vs_int 109# AIX xlc gets this wrong and unsigned long right. Go figure. 110if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} 111gdb_test "whatis v_long" \ 112 "type = (long|long int)" \ 113 "whatis long" 114 115setup_xfail_on_long_vs_int 116# AIX xlc gets this wrong and unsigned long right. Go figure. 117if {!$gcc_compiled} then {setup_xfail "rs6000-*-aix*"} 118gdb_test "whatis v_signed_long" \ 119 "type = (signed |)(long|long int)" \ 120 "whatis signed long" 121 122setup_xfail_on_long_vs_int 123gdb_test "whatis v_unsigned_long" \ 124 "type = (unsigned long|long unsigned int)" \ 125 "whatis unsigned long" 126 127gdb_test "whatis v_float" \ 128 "type = float" \ 129 "whatis float" 130 131gdb_test "whatis v_double" \ 132 "type = double" \ 133 "whatis double" 134 135 136# test whatis command with arrays 137# 138# We already tested whether char prints as "char", so here we accept 139# "unsigned char", "signed char", and other perversions. No need for more 140# than one xfail for the same thing. 141gdb_test "whatis v_char_array" \ 142 "type = (signed |unsigned |)char \\\[2\\\]" \ 143 "whatis char array" 144 145gdb_test "whatis v_signed_char_array" \ 146 "type = (signed |unsigned |)char \\\[2\\\]" \ 147 "whatis signed char array" 148 149gdb_test "whatis v_unsigned_char_array" \ 150 "type = unsigned char \\\[2\\\]" \ 151 "whatis unsigned char array" 152 153gdb_test "whatis v_short_array" \ 154 "type = (short|short int) \\\[2\\\]" \ 155 "whatis short array" 156 157gdb_test "whatis v_signed_short_array" \ 158 "type = (signed |)(short|short int) \\\[2\\\]" \ 159 "whatis signed short array" 160 161gdb_test "whatis v_unsigned_short_array" \ 162 "type = (unsigned short|short unsigned int) \\\[2\\\]" \ 163 "whatis unsigned short array" 164 165gdb_test "whatis v_int_array" \ 166 "type = int \\\[2\\\]" \ 167 "whatis int array" 168 169gdb_test "whatis v_signed_int_array" \ 170 "type = (signed |)int \\\[2\\\]" \ 171 "whatis signed int array" 172 173gdb_test "whatis v_unsigned_int_array" \ 174 "type = unsigned int \\\[2\\\]" \ 175 "whatis unsigned int array" 176 177# We already tested whether long prints as long, so here we accept int 178# No need for more than one xfail for the same thing. 179gdb_test "whatis v_long_array" \ 180 "type = (int|long|long int) \\\[2\\\]" \ 181 "whatis long array" 182 183gdb_test "whatis v_signed_long_array" \ 184 "type = (signed |)(int|long|long int) \\\[2\\\]" \ 185 "whatis signed long array" 186 187gdb_test "whatis v_unsigned_long_array" \ 188 "type = (unsigned (int|long|long int)|long unsigned int) \\\[2\\\]" \ 189 "whatis unsigned long array" 190 191gdb_test "whatis v_float_array" \ 192 "type = float \\\[2\\\]" \ 193 "whatis float array" 194 195gdb_test "whatis v_double_array" \ 196 "type = double \\\[2\\\]" \ 197 "whatis double array" 198 199 200# test whatis command with pointers 201# 202# We already tested whether char prints as char, so accept various perversions 203# here. We especially want to make sure we test that it doesn't print as 204# caddr_t. 205gdb_test "whatis v_char_pointer" \ 206 "type = (unsigned |signed |)char \\*" \ 207 "whatis char pointer" 208 209gdb_test "whatis v_signed_char_pointer" \ 210 "type = (unsigned |signed |)char \\*" \ 211 "whatis signed char pointer" 212 213gdb_test "whatis v_unsigned_char_pointer" \ 214 "type = unsigned char \\*" \ 215 "whatis unsigned char pointer" 216 217gdb_test "whatis v_short_pointer" \ 218 "type = (short|short int) \\*" \ 219 "whatis short pointer" 220 221gdb_test "whatis v_signed_short_pointer" \ 222 "type = (signed |)(short|short int) \\*" \ 223 "whatis signed short pointer" 224 225gdb_test "whatis v_unsigned_short_pointer" \ 226 "type = (unsigned short|short unsigned int) \\*" \ 227 "whatis unsigned short pointer" 228 229gdb_test "whatis v_int_pointer" \ 230 "type = int \\*" \ 231 "whatis int pointer" 232 233gdb_test "whatis v_signed_int_pointer" \ 234 "type = (signed |)int \\*" \ 235 "whatis signed int pointer" 236 237gdb_test "whatis v_unsigned_int_pointer" \ 238 "type = unsigned int \\*" \ 239 "whatis unsigned int pointer" 240 241# We already tested whether long prints as long, so here we accept int 242gdb_test "whatis v_long_pointer" \ 243 "type = (long|int|long int) \\*" \ 244 "whatis long pointer" 245 246gdb_test "whatis v_signed_long_pointer" \ 247 "type = (signed |)(long|int|long int) \\*" \ 248 "whatis signed long pointer" 249 250gdb_test "whatis v_unsigned_long_pointer" \ 251 "type = (unsigned (int|long|long int)|long unsigned int) \\*" \ 252 "whatis unsigned long pointer" 253 254gdb_test "whatis v_float_pointer" \ 255 "type = float \\*" \ 256 "whatis float pointer" 257 258gdb_test "whatis v_double_pointer" \ 259 "type = double \\*" \ 260 "whatis double pointer" 261 262 263if { $hp_aCC_compiler } { 264 set unstruct "unnamed\.struct\..*" 265 set ununion "unnamed\.union\..*" 266} else { 267 set unstruct "\.\.\." 268 set ununion "\.\.\." 269} 270 271# test whatis command with structure types 272gdb_test "whatis v_struct1" \ 273 "type = struct t_struct" \ 274 "whatis named structure" 275 276gdb_test "whatis struct t_struct" \ 277 "type = struct t_struct" \ 278 "whatis named structure using type name" 279 280gdb_test "whatis v_struct2" \ 281 "type = struct \{$unstruct\}" \ 282 "whatis unnamed structure" 283 284 285# test whatis command with union types 286gdb_test "whatis v_union" \ 287 "type = union t_union" \ 288 "whatis named union" 289 290gdb_test "whatis union t_union" \ 291 "type = union t_union" \ 292 "whatis named union using type name" 293 294gdb_test "whatis v_union2" \ 295 "type = union \{$ununion\}" \ 296 "whatis unnamed union" 297 298 299# HP-UX: HP aCC compiler w/ +objdebug option detects language as 300# c++, so we need the 'void' pattern here. 301# Without +objdebug compilation option we still need to match ''. 302# - guo 303# Also, using stabs we will mark these functions as prototyped. This 304# is harmless but causes an extra VOID to be printed. 305set void "(void|)" 306 307# test whatis command with functions return type 308gdb_test "whatis v_char_func" \ 309 "type = (signed |unsigned |)char \\($void\\)" \ 310 "whatis char function" 311 312gdb_test "whatis v_signed_char_func" \ 313 "type = (signed |unsigned |)char \\($void\\)" \ 314 "whatis signed char function" 315 316gdb_test "whatis v_unsigned_char_func" \ 317 "type = unsigned char \\($void\\)" \ 318 "whatis unsigned char function" 319 320gdb_test "whatis v_short_func" \ 321 "type = short (int |)\\($void\\)" \ 322 "whatis short function" 323 324gdb_test "whatis v_signed_short_func" \ 325 "type = (signed |)short (int |)\\($void\\)" \ 326 "whatis signed short function" 327 328gdb_test "whatis v_unsigned_short_func" \ 329 "type = (unsigned short|short unsigned int) \\($void\\)" \ 330 "whatis unsigned short function" 331 332gdb_test "whatis v_int_func" \ 333 "type = int \\($void\\)" \ 334 "whatis int function" 335 336gdb_test "whatis v_signed_int_func" \ 337 "type = (signed |)int \\($void\\)" \ 338 "whatis signed int function" 339 340gdb_test "whatis v_unsigned_int_func" \ 341 "type = unsigned int \\($void\\)" \ 342 "whatis unsigned int function" 343 344gdb_test "whatis v_long_func" \ 345 "type = (long|int|long int) \\($void\\)" \ 346 "whatis long function" 347 348gdb_test "whatis v_signed_long_func" \ 349 "type = (signed |)(int|long|long int) \\($void\\)" \ 350 "whatis signed long function" 351 352gdb_test "whatis v_unsigned_long_func" \ 353 "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ 354 "whatis unsigned long function" 355 356# Sun /bin/cc calls this a function returning double. 357if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} 358gdb_test "whatis v_float_func" \ 359 "type = float \\($void\\)" \ 360 "whatis float function" 361 362gdb_test "whatis v_double_func" \ 363 "type = double \\($void\\)" \ 364 "whatis double function" \ 365 366 367# test whatis command with some misc complicated types 368gdb_test "whatis s_link" \ 369 "type = struct link \\*" \ 370 "whatis complicated structure" 371 372gdb_test "whatis u_link" \ 373 "type = union tu_link" \ 374 "whatis complicated union" 375 376 377# test whatis command with enumerations 378gdb_test "whatis clunker" \ 379 "type = enum cars" \ 380 "whatis enumeration" 381 382gdb_test "whatis enum cars" \ 383 "type = enum cars" \ 384 "whatis enumeration using type name" 385 386 387# test whatis command with nested struct and union 388gdb_test "whatis nested_su" \ 389 "type = struct outer_struct" \ 390 "whatis outer structure" 391 392gdb_test "whatis nested_su.outer_int" \ 393 "type = int" \ 394 "whatis outer structure member" 395 396if {$hp_aCC_compiler} { 397 set outer "outer_struct::" 398} else { 399 set outer "" 400} 401 402gdb_test "whatis nested_su.inner_struct_instance" \ 403 "type = struct ${outer}inner_struct" \ 404 "whatis inner structure" 405 406gdb_test "whatis nested_su.inner_struct_instance.inner_int" \ 407 "type = int" \ 408 "whatis inner structure member" 409 410gdb_test "whatis nested_su.inner_union_instance" \ 411 "type = union ${outer}inner_union" \ 412 "whatis inner union" 413 414gdb_test "whatis nested_su.inner_union_instance.inner_union_int" \ 415 "type = int" \ 416 "whatis inner union member" 417 418# test whatis command with typedefs 419 420gdb_test "whatis char_addr" \ 421 "type = char \\*" \ 422 "whatis using typedef type name" 423 424gdb_test "whatis a_char_addr" \ 425 "type = char_addr" \ 426 "whatis applied to variable defined by typedef" 427