1# This testcase is part of GDB, the GNU debugger. 2 3# Copyright 1992-2013 Free Software Foundation, Inc. 4 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18# Please email any bugs, comments, and/or additions to this file to: 19# bug-gdb@gnu.org 20 21# This file was written by Fred Fish. (fnf@cygnus.com) 22 23set testfile "printcmds" 24set srcfile ${testfile}.c 25set binfile ${objdir}/${subdir}/${testfile} 26if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 27 untested printcmds.exp 28 return -1 29} 30 31get_compiler_info 32 33proc test_integer_literals_accepted {} { 34 global gdb_prompt 35 36 # Test various decimal values. 37 38 gdb_test "p 123" " = 123" 39 gdb_test "p -123" " = -123" 40 gdb_test "p/d 123" " = 123" 41 42 # Test various octal values. 43 44 gdb_test "p 0123" " = 83" 45 gdb_test "p 00123" " = 83" 46 gdb_test "p -0123" " = -83" 47 gdb_test "p/o 0123" " = 0123" 48 49 # Test various hexadecimal values. 50 51 gdb_test "p 0x123" " = 291" 52 gdb_test "p -0x123" " = -291" 53 gdb_test "p 0x0123" " = 291" 54 gdb_test "p -0x0123" " = -291" 55 gdb_test "p 0xABCDEF" " = 11259375" 56 gdb_test "p 0xabcdef" " = 11259375" 57 gdb_test "p 0xAbCdEf" " = 11259375" 58 gdb_test "p/x 0x123" " = 0x123" 59 60 # Test various binary values. 61 62 gdb_test "p 0b0" " = 0" 63 gdb_test "p 0b1111" " = 15" 64 gdb_test "p 0B1111" " = 15" 65 gdb_test "p -0b1111" " = -15" 66} 67 68proc test_character_literals_accepted {} { 69 global gdb_prompt 70 71 gdb_test "p 'a'" " = 97 'a'" 72 gdb_test "p/c 'a'" " = 97 'a'" 73 gdb_test "p/x 'a'" " = 0x61" 74 gdb_test "p/d 'a'" " = 97" 75 gdb_test "p/t 'a'" " = 1100001" 76 gdb_test "p '\\141'" " = 97 'a'" 77 gdb_test "p/x '\\377'" " = 0xff" 78 # Note "p '\''" => "= 39 '\''" 79 gdb_test "p '\\''" " = 39 '\\\\''" 80 # Note "p '\\'" => "= 92 '\\'" 81 gdb_test "p '\\\\'" " = 92 '\\\\\\\\'" 82} 83 84proc test_integer_literals_rejected {} { 85 global gdb_prompt 86 87 test_print_reject "p 0x" 88 test_print_reject "p 0b" 89 gdb_test "p ''" "(Empty character constant\\.|A character constant must contain at least one character\\.)" 90 gdb_test "p '''" "(Empty character constant\\.|A character constant must contain at least one character\\.)" 91 test_print_reject "p '\\'" 92 93 # Note that this turns into "p '\\\'" at gdb's input. 94 test_print_reject "p '\\\\\\'" 95 96 # Test various decimal values. 97 98 test_print_reject "p DEADBEEF" 99 100 # Test various octal values. 101 102 test_print_reject "p 09" 103 test_print_reject "p 079" 104 105 # Test various hexadecimal values. 106 107 test_print_reject "p 0xG" 108 test_print_reject "p 0xAG" 109 110 # Test various binary values. 111 112 test_print_reject "p 0b2" 113 test_print_reject "p 0b12" 114} 115 116proc test_float_accepted {} { 117 global gdb_prompt 118 119 # This test is useful to catch successful parsing of the first fp value. 120 gdb_test "p 123.4+56.7" " = 180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition" 121 122 # Test all the suffixes (including no suffix). 123 gdb_test "p 1." " = 1" 124 gdb_test "p 1.5" " = 1.5" 125 gdb_test "p 1.f" " = 1" 126 gdb_test "p 1.5f" " = 1.5" 127 gdb_test "p 1.l" " = 1" 128 gdb_test "p 1.5l" " = 1.5" 129 130 # Test hexadecimal floating point. 131 set test "p 0x1.1" 132 gdb_test_multiple $test $test { 133 -re " = 1\\.0625\r\n$gdb_prompt $" { 134 pass $test 135 } 136 -re "Invalid number \"0x1\\.1\"\\.\r\n$gdb_prompt $" { 137 # Older glibc does not support hex float, newer does. 138 xfail $test 139 } 140 } 141} 142 143proc test_float_rejected {} { 144 # Gdb use to fail this test for all configurations. The C 145 # lexer thought that 123DEADBEEF was a floating point number, but 146 # then failed to notice that atof() only eats the 123 part. 147 # Fixed, 4/25/97, by Bob Manson. 148 test_print_reject "p 123DEADBEEF" 149 150 test_print_reject "p 123foobar.bazfoo3" 151 test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333" 152 153 # Test bad suffixes. 154 test_print_reject "p 1.1x" 155 test_print_reject "p 1.1ff" 156 test_print_reject "p 1.1ll" 157} 158 159proc test_print_all_chars {} { 160 global gdb_prompt 161 162 gdb_test "p ctable1\[0\]" " = 0 '\\\\000'" 163 gdb_test "p ctable1\[1\]" " = 1 '\\\\001'" 164 gdb_test "p ctable1\[2\]" " = 2 '\\\\002'" 165 gdb_test "p ctable1\[3\]" " = 3 '\\\\003'" 166 gdb_test "p ctable1\[4\]" " = 4 '\\\\004'" 167 gdb_test "p ctable1\[5\]" " = 5 '\\\\005'" 168 gdb_test "p ctable1\[6\]" " = 6 '\\\\006'" 169 gdb_test "p ctable1\[7\]" " = 7 '\\\\a'" 170 gdb_test "p ctable1\[8\]" " = 8 '\\\\b'" 171 gdb_test "p ctable1\[9\]" " = 9 '\\\\t'" 172 gdb_test "p ctable1\[10\]" " = 10 '\\\\n'" 173 gdb_test "p ctable1\[11\]" " = 11 '\\\\v'" 174 gdb_test "p ctable1\[12\]" " = 12 '\\\\f'" 175 gdb_test "p ctable1\[13\]" " = 13 '\\\\r'" 176 gdb_test "p ctable1\[14\]" " = 14 '\\\\016'" 177 gdb_test "p ctable1\[15\]" " = 15 '\\\\017'" 178 gdb_test "p ctable1\[16\]" " = 16 '\\\\020'" 179 gdb_test "p ctable1\[17\]" " = 17 '\\\\021'" 180 gdb_test "p ctable1\[18\]" " = 18 '\\\\022'" 181 gdb_test "p ctable1\[19\]" " = 19 '\\\\023'" 182 gdb_test "p ctable1\[20\]" " = 20 '\\\\024'" 183 gdb_test "p ctable1\[21\]" " = 21 '\\\\025'" 184 gdb_test "p ctable1\[22\]" " = 22 '\\\\026'" 185 gdb_test "p ctable1\[23\]" " = 23 '\\\\027'" 186 gdb_test "p ctable1\[24\]" " = 24 '\\\\030'" 187 gdb_test "p ctable1\[25\]" " = 25 '\\\\031'" 188 gdb_test "p ctable1\[26\]" " = 26 '\\\\032'" 189 gdb_test "p ctable1\[27\]" " = 27 '\\\\033'" 190 gdb_test "p ctable1\[28\]" " = 28 '\\\\034'" 191 gdb_test "p ctable1\[29\]" " = 29 '\\\\035'" 192 gdb_test "p ctable1\[30\]" " = 30 '\\\\036'" 193 gdb_test "p ctable1\[31\]" " = 31 '\\\\037'" 194 gdb_test "p ctable1\[32\]" " = 32 ' '" 195 gdb_test "p ctable1\[33\]" " = 33 '!'" 196 gdb_test "p ctable1\[34\]" " = 34 '\"'" 197 gdb_test "p ctable1\[35\]" " = 35 '#'" 198 gdb_test "p ctable1\[36\]" " = 36 '\\\$'" 199 gdb_test "p ctable1\[37\]" " = 37 '%'" 200 gdb_test "p ctable1\[38\]" " = 38 '&'" 201 gdb_test "p ctable1\[39\]" " = 39 '\\\\''" 202 gdb_test "p ctable1\[40\]" " = 40 '\\('" 203 gdb_test "p ctable1\[41\]" " = 41 '\\)'" 204 gdb_test "p ctable1\[42\]" " = 42 '\\*'" 205 gdb_test "p ctable1\[43\]" " = 43 '\\+'" 206 gdb_test "p ctable1\[44\]" " = 44 ','" 207 gdb_test "p ctable1\[45\]" " = 45 '-'" 208 gdb_test "p ctable1\[46\]" " = 46 '.'" 209 gdb_test "p ctable1\[47\]" " = 47 '/'" 210 gdb_test "p ctable1\[48\]" " = 48 '0'" 211 gdb_test "p ctable1\[49\]" " = 49 '1'" 212 gdb_test "p ctable1\[50\]" " = 50 '2'" 213 gdb_test "p ctable1\[51\]" " = 51 '3'" 214 gdb_test "p ctable1\[52\]" " = 52 '4'" 215 gdb_test "p ctable1\[53\]" " = 53 '5'" 216 gdb_test "p ctable1\[54\]" " = 54 '6'" 217 gdb_test "p ctable1\[55\]" " = 55 '7'" 218 gdb_test "p ctable1\[56\]" " = 56 '8'" 219 gdb_test "p ctable1\[57\]" " = 57 '9'" 220 gdb_test "p ctable1\[58\]" " = 58 ':'" 221 gdb_test "p ctable1\[59\]" " = 59 ';'" 222 gdb_test "p ctable1\[60\]" " = 60 '<'" 223 gdb_test "p ctable1\[61\]" " = 61 '='" 224 gdb_test "p ctable1\[62\]" " = 62 '>'" 225 gdb_test "p ctable1\[63\]" " = 63 '\\?'" 226 gdb_test "p ctable1\[64\]" " = 64 '@'" 227 gdb_test "p ctable1\[65\]" " = 65 'A'" 228 gdb_test "p ctable1\[66\]" " = 66 'B'" 229 gdb_test "p ctable1\[67\]" " = 67 'C'" 230 gdb_test "p ctable1\[68\]" " = 68 'D'" 231 gdb_test "p ctable1\[69\]" " = 69 'E'" 232 gdb_test "p ctable1\[70\]" " = 70 'F'" 233 gdb_test "p ctable1\[71\]" " = 71 'G'" 234 gdb_test "p ctable1\[72\]" " = 72 'H'" 235 gdb_test "p ctable1\[73\]" " = 73 'I'" 236 gdb_test "p ctable1\[74\]" " = 74 'J'" 237 gdb_test "p ctable1\[75\]" " = 75 'K'" 238 gdb_test "p ctable1\[76\]" " = 76 'L'" 239 gdb_test "p ctable1\[77\]" " = 77 'M'" 240 gdb_test "p ctable1\[78\]" " = 78 'N'" 241 gdb_test "p ctable1\[79\]" " = 79 'O'" 242 gdb_test "p ctable1\[80\]" " = 80 'P'" 243 gdb_test "p ctable1\[81\]" " = 81 'Q'" 244 gdb_test "p ctable1\[82\]" " = 82 'R'" 245 gdb_test "p ctable1\[83\]" " = 83 'S'" 246 gdb_test "p ctable1\[84\]" " = 84 'T'" 247 gdb_test "p ctable1\[85\]" " = 85 'U'" 248 gdb_test "p ctable1\[86\]" " = 86 'V'" 249 gdb_test "p ctable1\[87\]" " = 87 'W'" 250 gdb_test "p ctable1\[88\]" " = 88 'X'" 251 gdb_test "p ctable1\[89\]" " = 89 'Y'" 252 gdb_test "p ctable1\[90\]" " = 90 'Z'" 253 gdb_test "p ctable1\[91\]" " = 91 '\\\['" 254 gdb_test "p ctable1\[92\]" " = 92 '\\\\\\\\'" 255 gdb_test "p ctable1\[93\]" " = 93 '\\\]'" 256 gdb_test "p ctable1\[94\]" " = 94 '\\^'" 257 gdb_test "p ctable1\[95\]" " = 95 '_'" 258 gdb_test "p ctable1\[96\]" " = 96 '`'" 259 gdb_test "p ctable1\[97\]" " = 97 'a'" 260 gdb_test "p ctable1\[98\]" " = 98 'b'" 261 gdb_test "p ctable1\[99\]" " = 99 'c'" 262 gdb_test "p ctable1\[100\]" " = 100 'd'" 263 gdb_test "p ctable1\[101\]" " = 101 'e'" 264 gdb_test "p ctable1\[102\]" " = 102 'f'" 265 gdb_test "p ctable1\[103\]" " = 103 'g'" 266 gdb_test "p ctable1\[104\]" " = 104 'h'" 267 gdb_test "p ctable1\[105\]" " = 105 'i'" 268 gdb_test "p ctable1\[106\]" " = 106 'j'" 269 gdb_test "p ctable1\[107\]" " = 107 'k'" 270 gdb_test "p ctable1\[108\]" " = 108 'l'" 271 gdb_test "p ctable1\[109\]" " = 109 'm'" 272 gdb_test "p ctable1\[110\]" " = 110 'n'" 273 gdb_test "p ctable1\[111\]" " = 111 'o'" 274 gdb_test "p ctable1\[112\]" " = 112 'p'" 275 gdb_test "p ctable1\[113\]" " = 113 'q'" 276 gdb_test "p ctable1\[114\]" " = 114 'r'" 277 gdb_test "p ctable1\[115\]" " = 115 's'" 278 gdb_test "p ctable1\[116\]" " = 116 't'" 279 gdb_test "p ctable1\[117\]" " = 117 'u'" 280 gdb_test "p ctable1\[118\]" " = 118 'v'" 281 gdb_test "p ctable1\[119\]" " = 119 'w'" 282 gdb_test "p ctable1\[120\]" " = 120 'x'" 283 gdb_test "p ctable1\[121\]" " = 121 'y'" 284 gdb_test "p ctable1\[122\]" " = 122 'z'" 285 gdb_test "p ctable1\[123\]" " = 123 '\[{\]+'" 286 gdb_test "p ctable1\[124\]" " = 124 '\[|\]+'" 287 gdb_test "p ctable1\[125\]" " = 125 '\[}\]+'" 288 gdb_test "p ctable1\[126\]" " = 126 '\[~\]'" 289 gdb_test "p ctable1\[127\]" " = 127 '\\\\177'" 290 gdb_test "p ctable1\[128\]" " = 128 '\\\\200'" 291 gdb_test "p ctable1\[129\]" " = 129 '\\\\201'" 292 gdb_test "p ctable1\[130\]" " = 130 '\\\\202'" 293 gdb_test "p ctable1\[131\]" " = 131 '\\\\203'" 294 gdb_test "p ctable1\[132\]" " = 132 '\\\\204'" 295 gdb_test "p ctable1\[133\]" " = 133 '\\\\205'" 296 gdb_test "p ctable1\[134\]" " = 134 '\\\\206'" 297 gdb_test "p ctable1\[135\]" " = 135 '\\\\207'" 298 gdb_test "p ctable1\[136\]" " = 136 '\\\\210'" 299 gdb_test "p ctable1\[137\]" " = 137 '\\\\211'" 300 gdb_test "p ctable1\[138\]" " = 138 '\\\\212'" 301 gdb_test "p ctable1\[139\]" " = 139 '\\\\213'" 302 gdb_test "p ctable1\[140\]" " = 140 '\\\\214'" 303 gdb_test "p ctable1\[141\]" " = 141 '\\\\215'" 304 gdb_test "p ctable1\[142\]" " = 142 '\\\\216'" 305 gdb_test "p ctable1\[143\]" " = 143 '\\\\217'" 306 gdb_test "p ctable1\[144\]" " = 144 '\\\\220'" 307 gdb_test "p ctable1\[145\]" " = 145 '\\\\221'" 308 gdb_test "p ctable1\[146\]" " = 146 '\\\\222'" 309 gdb_test "p ctable1\[147\]" " = 147 '\\\\223'" 310 gdb_test "p ctable1\[148\]" " = 148 '\\\\224'" 311 gdb_test "p ctable1\[149\]" " = 149 '\\\\225'" 312 gdb_test "p ctable1\[150\]" " = 150 '\\\\226'" 313 gdb_test "p ctable1\[151\]" " = 151 '\\\\227'" 314 gdb_test "p ctable1\[152\]" " = 152 '\\\\230'" 315 gdb_test "p ctable1\[153\]" " = 153 '\\\\231'" 316 gdb_test "p ctable1\[154\]" " = 154 '\\\\232'" 317 gdb_test "p ctable1\[155\]" " = 155 '\\\\233'" 318 gdb_test "p ctable1\[156\]" " = 156 '\\\\234'" 319 gdb_test "p ctable1\[157\]" " = 157 '\\\\235'" 320 gdb_test "p ctable1\[158\]" " = 158 '\\\\236'" 321 gdb_test "p ctable1\[159\]" " = 159 '\\\\237'" 322 gdb_test "p ctable1\[160\]" " = 160 '\\\\240'" 323 gdb_test "p ctable1\[161\]" " = 161 '\\\\241'" 324 gdb_test "p ctable1\[162\]" " = 162 '\\\\242'" 325 gdb_test "p ctable1\[163\]" " = 163 '\\\\243'" 326 gdb_test "p ctable1\[164\]" " = 164 '\\\\244'" 327 gdb_test "p ctable1\[165\]" " = 165 '\\\\245'" 328 gdb_test "p ctable1\[166\]" " = 166 '\\\\246'" 329 gdb_test "p ctable1\[167\]" " = 167 '\\\\247'" 330 gdb_test "p ctable1\[168\]" " = 168 '\\\\250'" 331 gdb_test "p ctable1\[169\]" " = 169 '\\\\251'" 332 gdb_test "p ctable1\[170\]" " = 170 '\\\\252'" 333 gdb_test "p ctable1\[171\]" " = 171 '\\\\253'" 334 gdb_test "p ctable1\[172\]" " = 172 '\\\\254'" 335 gdb_test "p ctable1\[173\]" " = 173 '\\\\255'" 336 gdb_test "p ctable1\[174\]" " = 174 '\\\\256'" 337 gdb_test "p ctable1\[175\]" " = 175 '\\\\257'" 338 gdb_test "p ctable1\[176\]" " = 176 '\\\\260'" 339 gdb_test "p ctable1\[177\]" " = 177 '\\\\261'" 340 gdb_test "p ctable1\[178\]" " = 178 '\\\\262'" 341 gdb_test "p ctable1\[179\]" " = 179 '\\\\263'" 342 gdb_test "p ctable1\[180\]" " = 180 '\\\\264'" 343 gdb_test "p ctable1\[181\]" " = 181 '\\\\265'" 344 gdb_test "p ctable1\[182\]" " = 182 '\\\\266'" 345 gdb_test "p ctable1\[183\]" " = 183 '\\\\267'" 346 gdb_test "p ctable1\[184\]" " = 184 '\\\\270'" 347 gdb_test "p ctable1\[185\]" " = 185 '\\\\271'" 348 gdb_test "p ctable1\[186\]" " = 186 '\\\\272'" 349 gdb_test "p ctable1\[187\]" " = 187 '\\\\273'" 350 gdb_test "p ctable1\[188\]" " = 188 '\\\\274'" 351 gdb_test "p ctable1\[189\]" " = 189 '\\\\275'" 352 gdb_test "p ctable1\[190\]" " = 190 '\\\\276'" 353 gdb_test "p ctable1\[191\]" " = 191 '\\\\277'" 354 gdb_test "p ctable1\[192\]" " = 192 '\\\\300'" 355 gdb_test "p ctable1\[193\]" " = 193 '\\\\301'" 356 gdb_test "p ctable1\[194\]" " = 194 '\\\\302'" 357 gdb_test "p ctable1\[195\]" " = 195 '\\\\303'" 358 gdb_test "p ctable1\[196\]" " = 196 '\\\\304'" 359 gdb_test "p ctable1\[197\]" " = 197 '\\\\305'" 360 gdb_test "p ctable1\[198\]" " = 198 '\\\\306'" 361 gdb_test "p ctable1\[199\]" " = 199 '\\\\307'" 362 gdb_test "p ctable1\[200\]" " = 200 '\\\\310'" 363 gdb_test "p ctable1\[201\]" " = 201 '\\\\311'" 364 gdb_test "p ctable1\[202\]" " = 202 '\\\\312'" 365 gdb_test "p ctable1\[203\]" " = 203 '\\\\313'" 366 gdb_test "p ctable1\[204\]" " = 204 '\\\\314'" 367 gdb_test "p ctable1\[205\]" " = 205 '\\\\315'" 368 gdb_test "p ctable1\[206\]" " = 206 '\\\\316'" 369 gdb_test "p ctable1\[207\]" " = 207 '\\\\317'" 370 gdb_test "p ctable1\[208\]" " = 208 '\\\\320'" 371 gdb_test "p ctable1\[209\]" " = 209 '\\\\321'" 372 gdb_test "p ctable1\[210\]" " = 210 '\\\\322'" 373 gdb_test "p ctable1\[211\]" " = 211 '\\\\323'" 374 gdb_test "p ctable1\[212\]" " = 212 '\\\\324'" 375 gdb_test "p ctable1\[213\]" " = 213 '\\\\325'" 376 gdb_test "p ctable1\[214\]" " = 214 '\\\\326'" 377 gdb_test "p ctable1\[215\]" " = 215 '\\\\327'" 378 gdb_test "p ctable1\[216\]" " = 216 '\\\\330'" 379 gdb_test "p ctable1\[217\]" " = 217 '\\\\331'" 380 gdb_test "p ctable1\[218\]" " = 218 '\\\\332'" 381 gdb_test "p ctable1\[219\]" " = 219 '\\\\333'" 382 gdb_test "p ctable1\[220\]" " = 220 '\\\\334'" 383 gdb_test "p ctable1\[221\]" " = 221 '\\\\335'" 384 gdb_test "p ctable1\[222\]" " = 222 '\\\\336'" 385 gdb_test "p ctable1\[223\]" " = 223 '\\\\337'" 386 gdb_test "p ctable1\[224\]" " = 224 '\\\\340'" 387 gdb_test "p ctable1\[225\]" " = 225 '\\\\341'" 388 gdb_test "p ctable1\[226\]" " = 226 '\\\\342'" 389 gdb_test "p ctable1\[227\]" " = 227 '\\\\343'" 390 gdb_test "p ctable1\[228\]" " = 228 '\\\\344'" 391 gdb_test "p ctable1\[229\]" " = 229 '\\\\345'" 392 gdb_test "p ctable1\[230\]" " = 230 '\\\\346'" 393 gdb_test "p ctable1\[231\]" " = 231 '\\\\347'" 394 gdb_test "p ctable1\[232\]" " = 232 '\\\\350'" 395 gdb_test "p ctable1\[233\]" " = 233 '\\\\351'" 396 gdb_test "p ctable1\[234\]" " = 234 '\\\\352'" 397 gdb_test "p ctable1\[235\]" " = 235 '\\\\353'" 398 gdb_test "p ctable1\[236\]" " = 236 '\\\\354'" 399 gdb_test "p ctable1\[237\]" " = 237 '\\\\355'" 400 gdb_test "p ctable1\[238\]" " = 238 '\\\\356'" 401 gdb_test "p ctable1\[239\]" " = 239 '\\\\357'" 402 gdb_test "p ctable1\[240\]" " = 240 '\\\\360'" 403 gdb_test "p ctable1\[241\]" " = 241 '\\\\361'" 404 gdb_test "p ctable1\[242\]" " = 242 '\\\\362'" 405 gdb_test "p ctable1\[243\]" " = 243 '\\\\363'" 406 gdb_test "p ctable1\[244\]" " = 244 '\\\\364'" 407 gdb_test "p ctable1\[245\]" " = 245 '\\\\365'" 408 gdb_test "p ctable1\[246\]" " = 246 '\\\\366'" 409 gdb_test "p ctable1\[247\]" " = 247 '\\\\367'" 410 gdb_test "p ctable1\[248\]" " = 248 '\\\\370'" 411 gdb_test "p ctable1\[249\]" " = 249 '\\\\371'" 412 gdb_test "p ctable1\[250\]" " = 250 '\\\\372'" 413 gdb_test "p ctable1\[251\]" " = 251 '\\\\373'" 414 gdb_test "p ctable1\[252\]" " = 252 '\\\\374'" 415 gdb_test "p ctable1\[253\]" " = 253 '\\\\375'" 416 gdb_test "p ctable1\[254\]" " = 254 '\\\\376'" 417 gdb_test "p ctable1\[255\]" " = 255 '\\\\377'" 418} 419 420# Test interaction of the number of print elements to print and the 421# repeat count, set to the default of 10. 422 423proc test_print_repeats_10 {} { 424 global gdb_prompt decimal 425 426 for { set x 1 } { $x <= 16 } { incr x } { 427 gdb_test_no_output "set print elements $x" 428 for { set e 1 } { $e <= 16 } {incr e } { 429 set v [expr $e - 1]; 430 set command "p &ctable2\[${v}*16\]" 431 if { $x < $e } { 432 set aval $x; 433 } else { 434 set aval $e; 435 } 436 set xval [expr $x - $e]; 437 if { $xval < 0 } { 438 set xval 0; 439 } 440 if { $aval > 10 } { 441 set a "'a' <repeats $aval times>"; 442 if { $xval > 0 } { 443 set a "${a}, \\\""; 444 } 445 } else { 446 set a "\\\"[string range "aaaaaaaaaaaaaaaa" 1 $aval]"; 447 if { $xval > 10 } { 448 set a "$a\\\", "; 449 } 450 } 451 set xstr ""; 452 if { $xval > 10 } { 453 set xstr "'X' <repeats $xval times>"; 454 } else { 455 if { $xval > 0 } { 456 set xstr "[string range "XXXXXXXXXXXXXXXX" 1 $xval]\\\""; 457 } else { 458 if { $aval <= 10 } { 459 set xstr "\\\""; 460 } 461 } 462 } 463 if { $aval < 16 } { 464 set xstr "${xstr}\[.\]\[.\]\[.\]" 465 } 466 set string " = \[(\]unsigned char \[*\]\[)\] <ctable2(\\+$decimal)?> ${a}${xstr}"; 467 gdb_test "$command" "$string" "$command with print elements set to $x"; 468 } 469 } 470} 471 472# This tests whether GDB uses the correct element content offsets 473# (relative to the complete `some_struct' value) when counting value 474# repetitions. 475 476proc test_print_repeats_embedded_array {} { 477 global gdb_prompt 478 479 gdb_test_escape_braces "p/x some_struct" \ 480 "= {a = 0x12345678, b = 0x87654321, array = {0xaa <repeats 20 times>}}" \ 481 "correct element repeats in array embedded at offset > 0" 482} 483 484proc test_print_strings {} { 485 global gdb_prompt decimal 486 487 # We accept "(unsigned char *) " before the string. char vs. unsigned char 488 # is already tested elsewhere. 489 490 # Test that setting print elements unlimited doesn't completely suppress 491 # printing; this was a bug in older gdb's. 492 gdb_test_no_output "set print elements 0" 493 gdb_test "p teststring" \ 494 " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 0" 495 gdb_test_no_output "set print elements 1" 496 gdb_test "p teststring" \ 497 " = (.unsigned char .. )?\"t\"\\.\\.\\." "p teststring with elements set to 1" 498 gdb_test_no_output "set print elements 5" 499 gdb_test "p teststring" \ 500 " = (.unsigned char .. )?\"tests\"\\.\\.\\." "p teststring with elements set to 5" 501 gdb_test_no_output "set print elements 19" 502 gdb_test "p teststring" \ 503 " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 19" 504 gdb_test_no_output "set print elements 20" 505 gdb_test "p teststring" \ 506 " = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 20" 507 508 gdb_test_no_output "set print elements 8" 509 510 gdb_test "p &ctable1\[0\]" \ 511 " = \\(unsigned char \\*\\) <ctable1> \"\"" 512 gdb_test "p &ctable1\[1\]" \ 513 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..." 514 gdb_test "p &ctable1\[1*8\]" \ 515 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..." 516 gdb_test "p &ctable1\[2*8\]" \ 517 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..." 518 gdb_test "p &ctable1\[3*8\]" \ 519 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..." 520 gdb_test "p &ctable1\[4*8\]" \ 521 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \" !\\\\\"#\\\$%&'\"..." 522 gdb_test "p &ctable1\[5*8\]" \ 523 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\(\\)\\*\\+,-./\"..." 524 gdb_test "p &ctable1\[6*8\]" \ 525 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"01234567\"..." 526 gdb_test "p &ctable1\[7*8\]" \ 527 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"89:;<=>\\?\"..." 528 gdb_test "p &ctable1\[8*8\]" \ 529 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"@ABCDEFG\"..." 530 gdb_test "p &ctable1\[9*8\]" \ 531 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"HIJKLMNO\"..." 532 gdb_test "p &ctable1\[10*8\]" \ 533 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"PQRSTUVW\"..." 534 gdb_test "p &ctable1\[11*8\]" \ 535 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"XYZ\\\[\\\\\\\\\\\]\\^_\"..." 536 gdb_test "p &ctable1\[12*8\]" \ 537 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"`abcdefg\"..." 538 gdb_test "p &ctable1\[13*8\]" \ 539 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"hijklmno\"..." 540 gdb_test "p &ctable1\[14*8\]" \ 541 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"pqrstuvw\"..." 542 gdb_test "p &ctable1\[15*8\]" \ 543 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"xyz\[{|}\]+\\~\\\\177\"..." 544 gdb_test "p &ctable1\[16*8\]" \ 545 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\200\\\\201\\\\202\\\\203\\\\204\\\\205\\\\206\\\\207\"..." 546 gdb_test "p &ctable1\[17*8\]" \ 547 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\210\\\\211\\\\212\\\\213\\\\214\\\\215\\\\216\\\\217\"..." 548 gdb_test "p &ctable1\[18*8\]" \ 549 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\220\\\\221\\\\222\\\\223\\\\224\\\\225\\\\226\\\\227\"..." 550 gdb_test "p &ctable1\[19*8\]" \ 551 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\230\\\\231\\\\232\\\\233\\\\234\\\\235\\\\236\\\\237\"..." 552 gdb_test "p &ctable1\[20*8\]" \ 553 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\240\\\\241\\\\242\\\\243\\\\244\\\\245\\\\246\\\\247\"..." 554 gdb_test "p &ctable1\[21*8\]" \ 555 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\250\\\\251\\\\252\\\\253\\\\254\\\\255\\\\256\\\\257\"..." 556 gdb_test "p &ctable1\[22*8\]" \ 557 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\260\\\\261\\\\262\\\\263\\\\264\\\\265\\\\266\\\\267\"..." 558 gdb_test "p &ctable1\[23*8\]" \ 559 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\270\\\\271\\\\272\\\\273\\\\274\\\\275\\\\276\\\\277\"..." 560 gdb_test "p &ctable1\[24*8\]" \ 561 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\300\\\\301\\\\302\\\\303\\\\304\\\\305\\\\306\\\\307\"..." 562 gdb_test "p &ctable1\[25*8\]" \ 563 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\310\\\\311\\\\312\\\\313\\\\314\\\\315\\\\316\\\\317\"..." 564 gdb_test "p &ctable1\[26*8\]" \ 565 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\320\\\\321\\\\322\\\\323\\\\324\\\\325\\\\326\\\\327\"..." 566 gdb_test "p &ctable1\[27*8\]" \ 567 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\330\\\\331\\\\332\\\\333\\\\334\\\\335\\\\336\\\\337\"..." 568 gdb_test "p &ctable1\[28*8\]" \ 569 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\340\\\\341\\\\342\\\\343\\\\344\\\\345\\\\346\\\\347\"..." 570 gdb_test "p &ctable1\[29*8\]" \ 571 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\350\\\\351\\\\352\\\\353\\\\354\\\\355\\\\356\\\\357\"..." 572 gdb_test "p &ctable1\[30*8\]" \ 573 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\360\\\\361\\\\362\\\\363\\\\364\\\\365\\\\366\\\\367\"..." 574 gdb_test "p &ctable1\[31*8\]" \ 575 " = \\(unsigned char \\*\\) <ctable1\\+$decimal> \"\\\\370\\\\371\\\\372\\\\373\\\\374\\\\375\\\\376\\\\377\"..." 576} 577 578proc test_print_int_arrays {} { 579 global gdb_prompt 580 581 gdb_test_no_output "set print elements 24" 582 583 gdb_test_escape_braces "p int1dim" \ 584 " = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}" 585 gdb_test_escape_braces "p int2dim" \ 586 " = {{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}}" 587 gdb_test_escape_braces "p int3dim" \ 588 " = {{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}" 589 gdb_test_escape_braces "p int4dim" \ 590 " = {{{{0, 1}, {2, 3}, {4, 5}}, {{6, 7}, {8, 9}, {10, 11}}}}" 591} 592 593proc test_print_typedef_arrays {} { 594 global gdb_prompt 595 596 gdb_test_no_output "set print elements 24" 597 598 gdb_test_escape_braces "p a1" \ 599 " = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}" 600 gdb_test "p a1\[0\]" " = 2" 601 gdb_test "p a1\[9\]" " = 20" 602 603 gdb_test "p a2" \ 604 " = \"abcd\"" 605 gdb_test "p a2\[0\]" " = 97 'a'" 606 gdb_test "p a2\[3\]" " = 100 'd'" 607 608 # Regression test of null-stop; PR 11049. 609 gdb_test_no_output "set print null-stop on" 610 gdb_test "p a2" " = \"abcd\"" "print a2 with null-stop on" 611 gdb_test_no_output "set print null-stop off" 612} 613 614proc test_artificial_arrays {} { 615 # Send \026@ instead of just @ in case the kill character is @. 616 gdb_test_escape_braces "p int1dim\[0\]\026@2" " = {0, 1}" {p int1dim[0]@2} 617 gdb_test_escape_braces "p int1dim\[0\]\026@2\026@3" \ 618 "({{0, 1}, {2, 3}, {4, 5}}|\[Cc\]annot.*)" \ 619 {p int1dim[0]@2@3} 620 gdb_test_escape_braces {p/x (short [])0x12345678} \ 621 " = ({0x1234, 0x5678}|{0x5678, 0x1234})" 622} 623 624proc test_print_char_arrays {} { 625 global gdb_prompt 626 global hex decimal 627 628 gdb_test_no_output "set print elements 24" 629 gdb_test_no_output "set print address on" 630 631 gdb_test "p arrays" \ 632 " = {array1 = \"abc\", array2 = \"d\", array3 = \"e\", array4 = \"fg\", array5 = \"hij\"}" 633 634 gdb_test "p parrays" " = \\(struct some_arrays \\*\\) $hex <arrays>" 635 gdb_test "p parrays->array1" " = \"abc\"" 636 gdb_test "p &parrays->array1" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex <arrays>" 637 gdb_test "p parrays->array2" " = \"d\"" 638 gdb_test "p &parrays->array2" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex <arrays\\+$decimal>" 639 gdb_test "p parrays->array3" " = \"e\"" 640 gdb_test "p &parrays->array3" " = \\(unsigned char \\(\\*\\)\\\[1\\\]\\) $hex <arrays\\+$decimal>" 641 gdb_test "p parrays->array4" " = \"fg\"" 642 gdb_test "p &parrays->array4" " = \\(unsigned char \\(\\*\\)\\\[2\\\]\\) $hex <arrays\\+$decimal>" 643 gdb_test "p parrays->array5" " = \"hij\"" 644 gdb_test "p &parrays->array5" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex <arrays\\+$decimal>" 645 646 gdb_test_no_output "set print address off" 647} 648 649proc test_print_string_constants {} { 650 global gdb_prompt 651 652 gdb_test_no_output "set print elements 50" 653 654 if [target_info exists gdb,cannot_call_functions] { 655 setup_xfail "*-*-*" 2416 656 fail "This target can not call functions" 657 return 658 } 659 660 # We need to up this because this can be really slow on some boards. 661 # (Test may involve inferior malloc() calls). 662 set timeout 60; 663 664 gdb_test "p \"a string\"" " = \"a string\"" 665 gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\"" 666 gdb_test "p \"abcd\"\[2\]" " = 99 'c'" 667 gdb_test "p sizeof (\"abcdef\")" " = 7" 668 gdb_test "ptype \"foo\"" " = char \\\[4\\\]" 669 gdb_test "p *\"foo\"" " = 102 'f'" 670 gdb_test "ptype *\"foo\"" " = char" 671 gdb_test "p &*\"foo\"" " = \"foo\"" 672 gdb_test "ptype &*\"foo\"" "type = char \\*" 673 gdb_test "p (char *)\"foo\"" " = \"foo\"" 674} 675 676proc test_print_array_constants {} { 677 678 if [target_info exists gdb,cannot_call_functions] { 679 setup_xfail "*-*-*" 2416 680 fail "This target can not call functions" 681 return 682 } 683 684 # We need to up this because this can be really slow on some boards. 685 # (Test may involve inferior malloc() calls). 686 set timeout 60; 687 688 gdb_test "print {'a','b','c'}" " = \"abc\"" 689 gdb_test_escape_braces "print {0,1,2}" " = {0, 1, 2}" 690 gdb_test_escape_braces "print {(long)0,(long)1,(long)2}" " = {0, 1, 2}" 691 gdb_test_escape_braces "print {{0,1,2},{3,4,5}}" " = {{0, 1, 2}, {3, 4, 5}}" 692 gdb_test "print {4,5,6}\[2\]" " = 6" 693 gdb_test "print *&{4,5,6}\[1\]" "Attempt to take address of value not located in memory." 694} 695 696proc test_print_enums {} { 697 # Regression test for PR11827. 698 gdb_test "print some_volatile_enum" "enumvolval1" 699 700 gdb_test "print three" " = \\\(ONE \\| TWO\\\)" 701} 702 703proc test_printf {} { 704 gdb_test "printf \"x=%d,y=%d,z=%d\\n\", 5, 6, 7" "x=5,y=6,z=7" 705 gdb_test "printf \"string=%.4sxx\\n\", teststring" "string=testxx" 706 gdb_test "printf \"string=%sxx\\n\", teststring" \ 707 "string=teststring contentsxx" 708 709 gdb_test "printf \"%f is fun\\n\", 1.0" "1\.0+ is fun" 710 711 # Test mixing args of different sizes. 712 gdb_test "printf \"x=%d,y=%f,z=%d\\n\", 5, 6.0, 7" "x=5,y=6\.0+,z=7" 713 gdb_test "printf \"%x %f, %c %x, %x, %f\\n\", 0xbad, -99.541, 'z',\ 7140xfeedface, 0xdeadbeef, 5.0" "bad -99.54\[0-9\]+, z feedface, deadbeef, 5.0+" 715 716 # Regression test for C lexer bug. 717 gdb_test "printf \"%c\\n\", \"x\"\[1,0\]" "x" 718 719 # Regression test for "%% at end of format string. 720 # See http://sourceware.org/bugzilla/show_bug.cgi?id=11345 721 gdb_test "printf \"%%%d%%\\n\", 5" "%5%" 722} 723 724#Test printing DFP values with printf 725proc test_printf_with_dfp {} { 726 727 # Test various dfp values, covering 32-bit, 64-bit and 128-bit ones 728 729 # _Decimal32 constants, which can support up to 7 digits 730 gdb_test "printf \"%Hf\\n\",1.2df" "1.2" 731 gdb_test "printf \"%Hf\\n\",-1.2df" "-1.2" 732 gdb_test "printf \"%Hf\\n\",1.234567df" "1.234567" 733 gdb_test "printf \"%Hf\\n\",-1.234567df" "-1.234567" 734 gdb_test "printf \"%Hf\\n\",1234567.df" "1234567" 735 gdb_test "printf \"%Hf\\n\",-1234567.df" "-1234567" 736 737 gdb_test "printf \"%Hf\\n\",1.2E1df" "12" 738 gdb_test "printf \"%Hf\\n\",1.2E10df" "1.2E\\+10" 739 gdb_test "printf \"%Hf\\n\",1.2E-10df" "1.2E-10" 740 741 # The largest exponent for 32-bit dfp value is 96. 742 gdb_test "printf \"%Hf\\n\",1.2E96df" "1.200000E\\+96" 743 744 # _Decimal64 constants, which can support up to 16 digits 745 gdb_test "printf \"%Df\\n\",1.2dd" "1.2" 746 gdb_test "printf \"%Df\\n\",-1.2dd" "-1.2" 747 gdb_test "printf \"%Df\\n\",1.234567890123456dd" "1.234567890123456" 748 gdb_test "printf \"%Df\\n\",-1.234567890123456dd" "-1.234567890123456" 749 gdb_test "printf \"%Df\\n\",1234567890123456.dd" "1234567890123456" 750 gdb_test "printf \"%Df\\n\",-1234567890123456.dd" "-1234567890123456" 751 752 gdb_test "printf \"%Df\\n\",1.2E1dd" "12" 753 gdb_test "printf \"%Df\\n\",1.2E10dd" "1.2E\\+10" 754 gdb_test "printf \"%Df\\n\",1.2E-10dd" "1.2E-10" 755 756 # The largest exponent for 64-bit dfp value is 384. 757 gdb_test "printf \"%Df\\n\",1.2E384dd" "1.200000000000000E\\+384" 758 759 # _Decimal128 constants, which can support up to 34 digits 760 gdb_test "printf \"%DDf\\n\",1.2dl" "1.2" 761 gdb_test "printf \"%DDf\\n\",-1.2dl" "-1.2" 762 gdb_test "printf \"%DDf\\n\",1.234567890123456789012345678901234dl" "1.234567890123456789012345678901234" 763 gdb_test "printf \"%DDf\\n\",-1.234567890123456789012345678901234dl" "-1.234567890123456789012345678901234" 764 gdb_test "printf \"%DDf\\n\",1234567890123456789012345678901234.dl" "1234567890123456789012345678901234" 765 gdb_test "printf \"%DDf\\n\",-1234567890123456789012345678901234.dl" "-1234567890123456789012345678901234" 766 767 gdb_test "printf \"%DDf\\n\",1.2E1dl" "12" 768 gdb_test "printf \"%DDf\\n\",1.2E10dl" "1.2E\\+10" 769 gdb_test "printf \"%DDf\\n\",1.2E-10dl" "1.2E-10" 770 771 # The largest exponent for 128-bit dfp value is 6144. 772 gdb_test "printf \"%DDf\\n\",1.2E6144dl" "1.200000000000000000000000000000000E\\+6144" 773 774 # GDB used to get this wrong. 775 gdb_test "printf \"%Hf %Hf\\n\",1.2df,1.3df" "1.2 1.3" 776} 777 778proc test_print_symbol {} { 779 gdb_test_no_output "set print symbol on" 780 781 gdb_test "print &three" " = .* <three>" 782 gdb_test "print parrays" " = .* <arrays>" 783 784 # In case somebody adds tests after this. 785 gdb_test_no_output "set print symbol off" 786} 787 788# Escape a left curly brace to prevent it from being interpreted as 789# the beginning of a bound 790proc gdb_test_escape_braces { args } { 791 792 set pattern [lindex $args 1] 793 regsub -all {\{[0-9]} $pattern {\\&} esc_pattern 794 gdb_test [lindex $args 0] $esc_pattern [lindex $args 2] 795} 796 797proc test_repeat_bytes {} { 798 set start(E) {} 799 set start(S) {a} 800 set start(L) {abaabbaaabbb} 801 set start(R) {'a' <repeats 20 times>} 802 set end(E) {} 803 set end(S) {c} 804 set end(L) {cdccddcccddd} 805 set end(R) {'c' <repeats 20 times>} 806 set invalid(S) {\\240} 807 set invalid(L) {\\240\\240\\240\\240} 808 set invalid(R) {'\\240' <repeats 20 times>} 809 810 set fmt(SSS) "\"%s%s%s\"" 811 set fmt(SSR) "\"%s%s\", %s" 812 set fmt(SRS) "\"%s\", %s, \"%s\"" 813 set fmt(RSS) "%s, \"%s%s\"" 814 set fmt(RSR) "%s, \"%s\", %s" 815 set fmt(SRR) "\"%s\", %s, %s" 816 set fmt(RRS) "%s, %s, \"%s\"" 817 set fmt(RRR) "%s, %s, %s" 818 819 set fmt(RS) "%s, \"%s\"" 820 set fmt(RR) "%s, %s" 821 set fmt(SR) "\"%s\", %s" 822 set fmt(SS) "\"%s%s\"" 823 824 # Test the various permutations of invalid characters 825 foreach i [array names invalid] { 826 set I $i 827 828 if {$i == "L"} { 829 set i "S" 830 } 831 832 foreach s [array names start] { 833 set S $s 834 835 if {$s == "L"} { 836 set s "S" 837 } 838 839 840 foreach e [array names end] { 841 set E $e 842 843 if {$e == "L"} { 844 set e "S" 845 } 846 847 # Skip E*E. 848 if {$s == "E" && $e == "E"} { continue } 849 850 # Special cases... 851 if {$s == "E"} { 852 set result [format $fmt($i$e) $invalid($I) $end($E)] 853 } elseif {$e == "E"} { 854 set result [format $fmt($s$i) $start($S) $invalid($I)] 855 } else { 856 set result [format $fmt($s$i$e) \ 857 $start($S) $invalid($I) $end($E)] 858 } 859 860 send_log "expecting: = $result\n" 861 gdb_test "print invalid_$S$I$E" "= $result" 862 } 863 } 864 } 865} 866 867# Start with a fresh gdb. 868 869gdb_exit 870gdb_start 871gdb_reinitialize_dir $srcdir/$subdir 872 873gdb_test "print \$pc" "No registers\\." 874 875# Some simple operations on strings should work even without a target 876# (and therefore without calling malloc). 877gdb_test "print \"abc\"" " = \"abc\"" 878gdb_test "print sizeof (\"abc\")" " = 4" 879gdb_test "ptype \"abc\"" " = char \\\[4\\\]" 880gdb_test "print \$cvar = \"abc\"" " = \"abc\"" 881gdb_test "print sizeof (\$cvar)" " = 4" 882 883gdb_file_cmd ${binfile} 884 885gdb_test "print \$pc" "No registers\\." "print \$pc (with file)" 886 887gdb_test_no_output "set print sevenbit-strings" 888gdb_test_no_output "set print address off" 889gdb_test_no_output "set width 0" 890 891if { [test_compiler_info "armcc-*"] } { 892 # ARM RealView compresses large arrays in the data segment. 893 # Before the program starts, we can not read them. There is 894 # nothing in the file to indicate that data is compressed. 895 setup_xfail "arm*-*-eabi" 896} 897gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1" 898 899gdb_load ${binfile} 900 901if ![runto_main] then { 902 fail "Can't run to main" 903 return 0 904} 905 906test_integer_literals_accepted 907test_integer_literals_rejected 908test_float_accepted 909test_float_rejected 910test_character_literals_accepted 911test_print_all_chars 912test_print_repeats_10 913test_print_repeats_embedded_array 914test_print_strings 915test_print_int_arrays 916test_print_typedef_arrays 917test_artificial_arrays 918test_print_char_arrays 919# We used to do the runto main here. 920test_print_string_constants 921test_print_array_constants 922test_print_enums 923test_printf 924test_printf_with_dfp 925test_print_symbol 926test_repeat_bytes 927