1# Copyright 1999 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 20if $tracelevel then { 21 strace $tracelevel 22} 23 24set prms_id 0 25set bug_id 0 26 27# Set the current language to Java. This counts as a test. If it 28# fails, then we skip the other tests. 29 30proc set_lang_java {} { 31 global gdb_prompt 32 33 if [gdb_test "set language java" "" "set language java"] { 34 return 0 35 } 36 37 if [gdb_test "show language" ".* source language is \"java\".*"] { 38 return 0 39 } 40 return 1; 41} 42 43proc test_integer_literals_accepted {} { 44 global gdb_prompt 45 46 # Test various decimal values. 47 48 gdb_test "p 123" " = 123" 49 gdb_test "p -123" " = -123" 50 gdb_test "p/d 123" " = 123" 51 52 # Test various octal values. 53 54 gdb_test "p 0123" " = 83" 55 gdb_test "p 00123" " = 83" 56 gdb_test "p -0123" " = -83" 57 gdb_test "p/o 0123" " = 0123" 58 59 # Test various hexadecimal values. 60 61 gdb_test "p 0x123" " = 291" 62 gdb_test "p -0x123" " = -291" 63 gdb_test "p 0x0123" " = 291" 64 gdb_test "p -0x0123" " = -291" 65 gdb_test "p 0xABCDEF" " = 11259375" 66 gdb_test "p 0xabcdef" " = 11259375" 67 gdb_test "p 0xAbCdEf" " = 11259375" 68 gdb_test "p/x 0x123" " = 0x123" 69} 70 71proc test_character_literals_accepted {} { 72 global gdb_prompt 73 74 gdb_test "p 'a'" " = 'a'" 75 gdb_test "p/c 'a'" " = 'a'" 76 gdb_test "p/c 70" " = 'F'" 77 gdb_test "p/x 'a'" " = 0x61" 78 gdb_test "p/d 'a'" " = 97" 79 gdb_test "p/t 'a'" " = 1100001" 80 gdb_test "p/x '\\377'" " = 0xff" 81 gdb_test "p '\\''" " = '\\\\''" 82 # Note "p '\\'" => "= 92 '\\'" 83 gdb_test "p '\\\\'" " = '\\\\\\\\'" 84 85 # Test the /c print format. 86} 87 88proc test_integer_literals_rejected {} { 89 global gdb_prompt 90 91 test_print_reject "p 0x" 92 gdb_test "p ''" "Empty character constant" 93 gdb_test "p '''" "Empty character constant" 94 test_print_reject "p '\\'" 95 96 # Note that this turns into "p '\\\'" at gdb's input. 97 test_print_reject "p '\\\\\\'" 98 99 # Test various decimal values. 100 101 test_print_reject "p DEADBEEF" 102 103 test_print_reject "p 123DEADBEEF" 104 test_print_reject "p 123foobar.bazfoo3" 105 test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333" 106 gdb_test "p 123.4+56.7" "180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition" 107 108 # Test various octal values. 109 110 test_print_reject "p 09" 111 test_print_reject "p 079" 112 113 # Test various hexadecimal values. 114 115 test_print_reject "p 0xG" 116 test_print_reject "p 0xAG" 117} 118 119 120 121# Start with a fresh gdb. 122 123gdb_exit 124gdb_start 125gdb_reinitialize_dir $srcdir/$subdir 126 127gdb_test "print \$pc" "No registers\\." 128# FIXME: should also test "print $pc" when there is an execfile but no 129# remote debugging target, process or corefile. 130 131gdb_test "set print sevenbit-strings" "" 132gdb_test "set print address off" "" "" 133gdb_test "set width 0" "" 134 135if [set_lang_java] then { 136 test_integer_literals_accepted 137 test_character_literals_accepted 138 test_integer_literals_rejected 139} else { 140 fail "Java print command tests suppressed" 141} 142