1# Copyright (C) 2001 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 2 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, write to the Free Software 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 17# Please email any bugs, comments, and/or additions to this file to: 18# bug-gdb@prep.ai.mit.edu 19 20# Written by Michael Snyder, Red Hat, Inc., 9/20/2001 21 22# This file is part of the gdb testsuite 23# Tests for type expressions using the new "@code" and "@data" modifiers. 24 25if $tracelevel then { 26 strace $tracelevel 27 } 28 29# 30# test running programs 31# 32set prms_id 0 33set bug_id 0 34 35set testfile "cvexpr" 36set srcfile ${testfile}.c 37set binfile ${objdir}/${subdir}/${testfile} 38 39if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 40 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." 41} 42 43gdb_exit 44gdb_start 45gdb_reinitialize_dir $srcdir/$subdir 46gdb_load ${binfile} 47 48if [target_info exists gdb_stub] { 49 gdb_step_for_stub; 50} 51 52gdb_test "set print sevenbit-strings" "" "" 53gdb_test "set print address off" "" "" 54gdb_test "set width 0" "" "" 55 56set ws "\[ \t\]*" 57 58# 59# Test casting a scalar to const 60# 61 62gdb_test "whatis (@code char) v_char" \ 63 "type = @code char" \ 64 "(@code char)" 65gdb_test "whatis (@code signed char) v_signed_char" \ 66 "type = @code signed char" \ 67 "(@code signed char)" 68gdb_test "whatis (@code unsigned char) v_unsigned_char" \ 69 "type = @code (unsigned char|char)" \ 70 "(@code unsigned char)" 71gdb_test "whatis (@code short) v_short" \ 72 "type = @code (short|short int)" \ 73 "(@code short)" 74gdb_test "whatis (@code signed short) v_signed_short" \ 75 "type = @code (short|short int|signed short|signed short int)" \ 76 "(@code signed short)" 77gdb_test "whatis (@code unsigned short) v_unsigned_short" \ 78 "type = @code (unsigned short|short unsigned int)" \ 79 "(@code unsigned short)" 80gdb_test "whatis (@code int) v_int" \ 81 "type = @code int" \ 82 "(@code int)" 83gdb_test "whatis (@code signed int) v_signed_int" \ 84 "type = @code (signed int|int)" \ 85 "(@code signed int)" 86gdb_test "whatis (@code unsigned int) v_unsigned_int" \ 87 "type = @code unsigned int" \ 88 "(@code unsigned int)" 89gdb_test "whatis (@code long) v_long" \ 90 "type = @code (long|long int)" \ 91 "(@code long)" 92gdb_test "whatis (@code signed long) v_signed_long" \ 93 "type = @code (signed |)long( int|)" \ 94 "(@code signed long)" 95gdb_test "whatis (@code unsigned long) v_unsigned_long" \ 96 "type = @code (unsigned long|long unsigned int)" \ 97 "(@code unsigned long)" 98gdb_test "whatis (@code long long) v_long_long" \ 99 "type = @code long long( int|)" \ 100 "(@code long long)" 101gdb_test "whatis (@code signed long long) v_signed_long_long" \ 102 "type = @code (signed |)long long( int|)" \ 103 "(@code signed long long)" 104gdb_test "whatis (@code unsigned long long) v_unsigned_long_long" \ 105 "type = @code (unsigned long long|long long unsigned int)" \ 106 "(@code unsigned long long)" 107gdb_test "whatis (@code float) v_float" \ 108 "type = @code float" \ 109 "(@code float)" 110gdb_test "whatis (@code double) v_double" \ 111 "type = @code double" \ 112 "(@code double)" 113 114# 115# Test casting a scalar to @data 116# 117 118gdb_test "whatis (@data char) v_char" \ 119 "type = @data char" \ 120 "(@data char)" 121gdb_test "whatis (@data signed char) v_signed_char" \ 122 "type = @data signed char" \ 123 "(@data signed char)" 124gdb_test "whatis (@data unsigned char) v_unsigned_char" \ 125 "type = @data (unsigned char|char)" \ 126 "(@data unsigned char)" 127gdb_test "whatis (@data short) v_short" \ 128 "type = @data (short|short int)" \ 129 "(@data short)" 130gdb_test "whatis (@data signed short) v_signed_short" \ 131 "type = @data (short|short int|signed short|signed short int)" \ 132 "(@data signed short)" 133gdb_test "whatis (@data unsigned short) v_unsigned_short" \ 134 "type = @data (unsigned short|short unsigned int)" \ 135 "(@data unsigned short)" 136gdb_test "whatis (@data int) v_int" \ 137 "type = @data int" \ 138 "(@data int)" 139gdb_test "whatis (@data signed int) v_signed_int" \ 140 "type = @data (signed int|int)" \ 141 "(@data signed int)" 142gdb_test "whatis (@data unsigned int) v_unsigned_int" \ 143 "type = @data unsigned int" \ 144 "(@data unsigned int)" 145gdb_test "whatis (@data long) v_long" \ 146 "type = @data (long|long int)" \ 147 "(@data long)" 148gdb_test "whatis (@data signed long) v_signed_long" \ 149 "type = @data (signed |)long( int|)" \ 150 "(@data signed long)" 151gdb_test "whatis (@data unsigned long) v_unsigned_long" \ 152 "type = @data (unsigned long|long unsigned int)" \ 153 "(@data unsigned long)" 154gdb_test "whatis (@data long long) v_long_long" \ 155 "type = @data long long( int|)" \ 156 "(@data long long)" 157gdb_test "whatis (@data signed long long) v_signed_long_long" \ 158 "type = @data (signed |)long long( int|)" \ 159 "(@data signed long long)" 160gdb_test "whatis (@data unsigned long long) v_unsigned_long_long" \ 161 "type = @data (unsigned long long|long long unsigned int)" \ 162 "(@data unsigned long long)" 163gdb_test "whatis (@data float) v_float" \ 164 "type = @data float" \ 165 "(@data float)" 166gdb_test "whatis (@data double) v_double" \ 167 "type = @data double" \ 168 "(@data double)" 169 170# 171# Now put the '@code' and '@data' keywords after the base type. 172# 173 174gdb_test "whatis (char @code) v_char" \ 175 "type = @code char" \ 176 "(char @code)" 177gdb_test "whatis (signed char @code) v_signed_char" \ 178 "type = @code signed char" \ 179 "(signed char @code)" 180gdb_test "whatis (unsigned char @code) v_unsigned_char" \ 181 "type = @code (unsigned char|char)" \ 182 "(unsigned char @code)" 183gdb_test "whatis (short @code) v_short" \ 184 "type = @code (short|short int)" \ 185 "(short @code)" 186gdb_test "whatis (signed short @code) v_signed_short" \ 187 "type = @code (short|short int|signed short|signed short int)" \ 188 "(signed short @code)" 189gdb_test "whatis (unsigned short @code) v_unsigned_short" \ 190 "type = @code (unsigned short|short unsigned int)" \ 191 "(unsigned short @code)" 192gdb_test "whatis (int @code) v_int" \ 193 "type = @code int" \ 194 "(int @code)" 195gdb_test "whatis (signed int @code) v_signed_int" \ 196 "type = @code (signed int|int)" \ 197 "(signed int @code)" 198gdb_test "whatis (unsigned int @code) v_unsigned_int" \ 199 "type = @code unsigned int" \ 200 "(unsigned int @code)" 201gdb_test "whatis (long @code) v_long" \ 202 "type = @code (long|long int)" \ 203 "(long @code)" 204gdb_test "whatis (signed long @code) v_signed_long" \ 205 "type = @code (signed |)long( int|)" \ 206 "(signed long @code)" 207gdb_test "whatis (unsigned long @code) v_unsigned_long" \ 208 "type = @code (unsigned long|long unsigned int)" \ 209 "(unsigned long @code)" 210gdb_test "whatis (long long @code) v_long_long" \ 211 "type = @code long long( int|)" \ 212 "(long long @code)" 213gdb_test "whatis (signed long long @code) v_signed_long_long" \ 214 "type = @code (signed |)long long( int|)" \ 215 "(signed long long @code)" 216gdb_test "whatis (unsigned long long @code) v_unsigned_long_long" \ 217 "type = @code (unsigned long long|long long unsigned int)" \ 218 "(unsigned long long @code)" 219gdb_test "whatis (float @code) v_float" \ 220 "type = @code float" \ 221 "(float @code)" 222gdb_test "whatis (double @code) v_double" \ 223 "type = @code double" \ 224 "(double @code)" 225 226gdb_test "whatis (char @data) v_char" \ 227 "type = @data char" \ 228 "(char @data)" 229gdb_test "whatis (signed char @data) v_signed_char" \ 230 "type = @data signed char" \ 231 "(signed char @data)" 232gdb_test "whatis (unsigned char @data) v_unsigned_char" \ 233 "type = @data (unsigned char|char)" \ 234 "(unsigned char @data)" 235gdb_test "whatis (short @data) v_short" \ 236 "type = @data (short|short int)" \ 237 "(short @data)" 238gdb_test "whatis (signed short @data) v_signed_short" \ 239 "type = @data (short|short int|signed short|signed short int)" \ 240 "(signed short @data)" 241gdb_test "whatis (unsigned short @data) v_unsigned_short" \ 242 "type = @data (unsigned short|short unsigned int)" \ 243 "(unsigned short @data)" 244gdb_test "whatis (int @data) v_int" \ 245 "type = @data int" \ 246 "(int @data)" 247gdb_test "whatis (signed int @data) v_signed_int" \ 248 "type = @data (signed int|int)" \ 249 "(signed int @data)" 250gdb_test "whatis (unsigned int @data) v_unsigned_int" \ 251 "type = @data unsigned int" \ 252 "(unsigned int @data)" 253gdb_test "whatis (long @data) v_long" \ 254 "type = @data (long|long int)" \ 255 "(long @data)" 256gdb_test "whatis (signed long @data) v_signed_long" \ 257 "type = @data (signed |)long( int|)" \ 258 "(signed long @data)" 259gdb_test "whatis (unsigned long @data) v_unsigned_long" \ 260 "type = @data (unsigned long|long unsigned int)" \ 261 "(unsigned long @data)" 262gdb_test "whatis (long long @data) v_long_long" \ 263 "type = @data long long( int|)" \ 264 "(long long @data)" 265gdb_test "whatis (signed long long @data) v_signed_long_long" \ 266 "type = @data (signed |)long long( int|)" \ 267 "(signed long long @data)" 268gdb_test "whatis (unsigned long long @data) v_unsigned_long_long" \ 269 "type = @data (unsigned long long|long long unsigned int)" \ 270 "(unsigned long long @data)" 271gdb_test "whatis (float @data) v_float" \ 272 "type = @data float" \ 273 "(float @data)" 274gdb_test "whatis (double @data) v_double" \ 275 "type = @data double" \ 276 "(double @data)" 277 278# 279# enums 280# 281 282gdb_test "whatis (@code enum misordered) v_misordered" \ 283 "type = @code enum misordered" \ 284 "(@code enum misordered)" 285gdb_test "whatis (enum misordered @code) v_misordered" \ 286 "type = @code enum misordered" \ 287 "(enum misordered @code)" 288gdb_test "whatis (@data enum misordered) v_misordered" \ 289 "type = @data enum misordered" \ 290 "(@data enum misordered)" 291gdb_test "whatis (enum misordered @data) v_misordered" \ 292 "type = @data enum misordered" \ 293 "(enum misordered @data)" 294 295# 296# Pointers 297# 298 299gdb_test "whatis (@code int *) v_int_pointer" \ 300 "type = @code int${ws}\\*" \ 301 "(@code int *)" 302gdb_test "whatis (int @code *) v_int_pointer" \ 303 "type = @code int${ws}\\*" \ 304 "(int @code *)" 305gdb_test "whatis (int * @code) v_int_pointer" \ 306 "type = int \\*${ws}@code" \ 307 "(int * @code)" 308gdb_test "whatis (@code int * @code) v_int_pointer" \ 309 "type = @code int${ws}\\*${ws}@code" \ 310 "(@code int * @code)" 311gdb_test "whatis (int @code * @code) v_int_pointer" \ 312 "type = @code int${ws}\\*${ws}@code" \ 313 "(int @code * @code)" 314 315gdb_test "whatis (@code int **) v_int_pointer_pointer" \ 316 "type = @code int${ws}\\*${ws}\\*" \ 317 "(@code int **)" 318gdb_test "whatis (int @code **) v_int_pointer_pointer" \ 319 "type = @code int${ws}\\*${ws}\\*" \ 320 "(int @code **)" 321gdb_test "whatis (int ** @code) v_int_pointer_pointer" \ 322 "type = int \\*${ws}\\*${ws}@code" \ 323 "(int ** @code)" 324gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \ 325 "type = @code int${ws}\\*${ws}@code${ws}\\*" \ 326 "(@code int * @code *)" 327gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \ 328 "type = @code int${ws}\\*${ws}@code${ws}\\*" \ 329 "(int @code * @code *)" 330gdb_test "whatis (@code int * @code * @code) v_int_pointer_pointer" \ 331 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \ 332 "(@code int * @code * @code)" 333gdb_test "whatis (int @code * @code * @code) v_int_pointer_pointer" \ 334 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \ 335 "(int @code * @code * @code)" 336 337# 338# Arrays TODO 339# 340 341# 342# Pointers to arrays, arrays of pointers TODO 343# 344 345# 346# Structs and Unions 347# 348 349gdb_test "whatis (@code struct t_struct) v_struct1" \ 350 "type = @code struct t_struct" \ 351 "(@code struct t_struct)" 352gdb_test "whatis (@code union t_union) v_union" \ 353 "type = @code union t_union" \ 354 "(@code union t_union)" 355gdb_test "whatis (struct t_struct @code) v_struct1" \ 356 "type = @code struct t_struct" \ 357 "(struct t_struct @code)" 358gdb_test "whatis (union t_union @code) v_union" \ 359 "type = @code union t_union" \ 360 "(union t_union @code)" 361gdb_test "whatis (@code struct t_struct *) &v_struct1" \ 362 "type = @code struct t_struct${ws}\\*" \ 363 "(@code struct t_struct *)" 364gdb_test "whatis (@code union t_union *) &v_union" \ 365 "type = @code union t_union${ws}\\*" \ 366 "(@code union t_union *)" 367gdb_test "whatis (struct t_struct @code *) &v_struct1" \ 368 "type = @code struct t_struct${ws}\\*" \ 369 "(struct t_struct @code *)" 370gdb_test "whatis (union t_union @code *) &v_union" \ 371 "type = @code union t_union${ws}\\*" \ 372 "(union t_union @code *)" 373gdb_test "whatis (struct t_struct * @code) &v_struct1" \ 374 "type = struct t_struct${ws}\\*${ws}@code" \ 375 "(struct t_struct * @code)" 376gdb_test "whatis (union t_union * @code) &v_union" \ 377 "type = union t_union${ws}\\*${ws}@code" \ 378 "(union t_union * @code)" 379gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \ 380 "type = @code struct t_struct${ws}\\*${ws}@code" \ 381 "(@code struct t_struct * @code)" 382gdb_test "whatis (@code union t_union * @code) &v_union" \ 383 "type = @code union t_union${ws}\\*${ws}@code" \ 384 "(@code union t_union * @code)" 385gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \ 386 "type = @code struct t_struct${ws}\\*${ws}@code" \ 387 "(struct t_struct @code * @code)" 388gdb_test "whatis (union t_union @code * @code) &v_union" \ 389 "type = @code union t_union${ws}\\*${ws}@code" \ 390 "(union t_union @code * @code)" 391 392# 393# Function pointers TODO 394# 395 396