# This testcase is part of GDB, the GNU debugger.
# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2007,
-# 2008 Free Software Foundation, Inc.
+# 2008, 2009, 2010 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
strace $tracelevel
}
-set prms_id 0
-set bug_id 0
set testfile "printcmds"
set srcfile ${testfile}.c
return -1
}
+get_compiler_info ${binfile}
+
# Set the current language to C. This counts as a test. If it
# fails, then we skip the other tests.
proc set_lang_c {} {
global gdb_prompt
- if [gdb_test "set language c" "" "set language c"] {
+ if [gdb_test_no_output "set language c" "set language c"] {
return 0
}
gdb_test "p 0xabcdef" " = 11259375"
gdb_test "p 0xAbCdEf" " = 11259375"
gdb_test "p/x 0x123" " = 0x123"
+
+ # Test various binary values.
+
+ gdb_test "p 0b0" " = 0"
+ gdb_test "p 0b1111" " = 15"
+ gdb_test "p 0B1111" " = 15"
+ gdb_test "p -0b1111" " = -15"
}
proc test_character_literals_accepted {} {
proc test_integer_literals_rejected {} {
global gdb_prompt
- test_print_reject "p 0x"
+ test_print_reject "p 0x"
+ test_print_reject "p 0b"
gdb_test "p ''" "(Empty character constant\\.|A character constant must contain at least one character\\.)"
gdb_test "p '''" "(Empty character constant\\.|A character constant must contain at least one character\\.)"
test_print_reject "p '\\'"
test_print_reject "p 0xG"
test_print_reject "p 0xAG"
+
+ # Test various binary values.
+
+ test_print_reject "p 0b2"
+ test_print_reject "p 0b12"
}
proc test_print_all_chars {} {
global gdb_prompt
- gdb_test "p ctable1\[0\]" " = 0 '\\\\0'"
+ gdb_test "p ctable1\[0\]" " = 0 '\\\\000'"
gdb_test "p ctable1\[1\]" " = 1 '\\\\001'"
gdb_test "p ctable1\[2\]" " = 2 '\\\\002'"
gdb_test "p ctable1\[3\]" " = 3 '\\\\003'"
global gdb_prompt
for { set x 1; } { $x <= 16 } { incr x; } {
- gdb_test "set print elements $x" ""
+ gdb_test_no_output "set print elements $x"
for { set e 1; } { $e <= 16 } {incr e; } {
set v [expr $e - 1];
set command "p &ctable2\[${v}*16\]"
# Test that setting print elements unlimited doesn't completely suppress
# printing; this was a bug in older gdb's.
- gdb_test "set print elements 0" ""
+ gdb_test_no_output "set print elements 0"
gdb_test "p teststring" \
" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 0"
- gdb_test "set print elements 1" ""
+ gdb_test_no_output "set print elements 1"
gdb_test "p teststring" \
" = (.unsigned char .. )?\"t\"\\.\\.\\." "p teststring with elements set to 1"
- gdb_test "set print elements 5" ""
+ gdb_test_no_output "set print elements 5"
gdb_test "p teststring" \
" = (.unsigned char .. )?\"tests\"\\.\\.\\." "p teststring with elements set to 5"
- gdb_test "set print elements 19" ""
+ gdb_test_no_output "set print elements 19"
gdb_test "p teststring" \
" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 19"
- gdb_test "set print elements 20" ""
+ gdb_test_no_output "set print elements 20"
gdb_test "p teststring" \
" = (.unsigned char .. )?\"teststring contents\"" "p teststring with elements set to 20"
- gdb_test "set print elements 8" ""
+ gdb_test_no_output "set print elements 8"
gdb_test "p &ctable1\[0\]" \
" = \\(unsigned char \\*\\) \"\""
proc test_print_int_arrays {} {
global gdb_prompt
- gdb_test "set print elements 24" ""
+ gdb_test_no_output "set print elements 24"
gdb_test_escape_braces "p int1dim" \
" = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
proc test_print_typedef_arrays {} {
global gdb_prompt
- gdb_test "set print elements 24" ""
+ gdb_test_no_output "set print elements 24"
gdb_test_escape_braces "p a1" \
" = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20}"
" = \"abcd\""
gdb_test "p a2\[0\]" " = 97 'a'"
gdb_test "p a2\[3\]" " = 100 'd'"
+
+ # Regression test of null-stop; PR 11049.
+ gdb_test_no_output "set print null-stop on"
+ gdb_test "p a2" " = \"abcd\"" "print a2 with null-stop on"
+ gdb_test_no_output "set print null-stop off"
}
proc test_artificial_arrays {} {
global gdb_prompt
global hex
- gdb_test "set print elements 24" ""
- gdb_test "set print address on" ""
+ gdb_test_no_output "set print elements 24"
+ gdb_test_no_output "set print address on"
gdb_test "p arrays" \
" = {array1 = \"abc\", array2 = \"d\", array3 = \"e\", array4 = \"fg\", array5 = \"hij\"}"
gdb_test "p parrays->array5" " = \"hij\""
gdb_test "p &parrays->array5" " = \\(unsigned char \\(\\*\\)\\\[4\\\]\\) $hex"
- gdb_test "set print address off" ""
+ gdb_test_no_output "set print address off"
}
proc test_print_string_constants {} {
global gdb_prompt
- gdb_test "set print elements 50" ""
+ gdb_test_no_output "set print elements 50"
if [target_info exists gdb,cannot_call_functions] {
setup_xfail "*-*-*" 2416
gdb_test "p *\"foo\"" " = 102 'f'"
gdb_test "ptype *\"foo\"" " = char"
gdb_test "p &*\"foo\"" " = \"foo\""
- setup_kfail "gdb/538" *-*-*
gdb_test "ptype &*\"foo\"" "type = char \\*"
gdb_test "p (char *)\"foo\"" " = \"foo\""
}
gdb_test "printf \"x=%d,y=%f,z=%d\\n\", 5, 6.0, 7" "x=5,y=6\.0+,z=7"
gdb_test "printf \"%x %f, %c %x, %x, %f\\n\", 0xbad, -99.541, 'z',\
0xfeedface, 0xdeadbeef, 5.0" "bad -99.54\[0-9\]+, z feedface, deadbeef, 5.0+"
+
+ # Regression test for C lexer bug.
+ gdb_test "printf \"%c\\n\", \"x\"\[1,0\]" "x"
+
+ # Regression test for "%% at end of format string.
+ # See http://sourceware.org/bugzilla/show_bug.cgi?id=11345
+ gdb_test "printf \"%%%d%%\\n\", 5" "%5%"
}
#Test printing DFP values with printf
gdb_test "print \$cvar = \"abc\"" " = \"abc\""
gdb_test "print sizeof (\$cvar)" " = 4"
-gdb_load ${binfile}
+gdb_file_cmd ${binfile}
gdb_test "print \$pc" "No registers\\." "print \$pc (with file)"
-gdb_test "set print sevenbit-strings" ""
-gdb_test "set print address off" ""
-gdb_test "set width 0" ""
+gdb_test_no_output "set print sevenbit-strings"
+gdb_test_no_output "set print address off"
+gdb_test_no_output "set width 0"
if [set_lang_c] then {
+ if { [test_compiler_info "armcc-*"] } {
+ # ARM RealView compresses large arrays in the data segment.
+ # Before the program starts, we can not read them. There is
+ # nothing in the file to indicate that data is compressed.
+ setup_xfail "arm*-*-eabi"
+ }
gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1"
+ gdb_load ${binfile}
if [runto_main] then {
test_integer_literals_accepted
test_integer_literals_rejected