gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.java / jv-print.exp
CommitLineData
7b6bb8da 1# Copyright 1999, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
2dcad5ea
JM
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
2dcad5ea 6# (at your option) any later version.
e22f8b7c 7#
2dcad5ea
JM
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.
e22f8b7c 12#
2dcad5ea 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
2dcad5ea 15
2dcad5ea
JM
16if $tracelevel then {
17 strace $tracelevel
18}
19
ec3c07fc
NS
20load_lib "java.exp"
21
22if { [skip_java_tests] } { continue }
23
2dcad5ea
JM
24proc test_integer_literals_accepted {} {
25 global gdb_prompt
26
27 # Test various decimal values.
28
29 gdb_test "p 123" " = 123"
30 gdb_test "p -123" " = -123"
31 gdb_test "p/d 123" " = 123"
32
33 # Test various octal values.
34
35 gdb_test "p 0123" " = 83"
36 gdb_test "p 00123" " = 83"
37 gdb_test "p -0123" " = -83"
38 gdb_test "p/o 0123" " = 0123"
39
40 # Test various hexadecimal values.
41
42 gdb_test "p 0x123" " = 291"
43 gdb_test "p -0x123" " = -291"
44 gdb_test "p 0x0123" " = 291"
45 gdb_test "p -0x0123" " = -291"
46 gdb_test "p 0xABCDEF" " = 11259375"
47 gdb_test "p 0xabcdef" " = 11259375"
48 gdb_test "p 0xAbCdEf" " = 11259375"
49 gdb_test "p/x 0x123" " = 0x123"
50}
51
52proc test_character_literals_accepted {} {
53 global gdb_prompt
54
55 gdb_test "p 'a'" " = 'a'"
56 gdb_test "p/c 'a'" " = 'a'"
57 gdb_test "p/c 70" " = 'F'"
58 gdb_test "p/x 'a'" " = 0x61"
59 gdb_test "p/d 'a'" " = 97"
60 gdb_test "p/t 'a'" " = 1100001"
61 gdb_test "p/x '\\377'" " = 0xff"
62 gdb_test "p '\\''" " = '\\\\''"
63 # Note "p '\\'" => "= 92 '\\'"
64 gdb_test "p '\\\\'" " = '\\\\\\\\'"
65
66 # Test the /c print format.
67}
68
69proc test_integer_literals_rejected {} {
70 global gdb_prompt
71
72 test_print_reject "p 0x"
5415e7c5
MK
73 gdb_test "p ''" "Empty character constant"
74 gdb_test "p '''" "Empty character constant"
2dcad5ea
JM
75 test_print_reject "p '\\'"
76
77 # Note that this turns into "p '\\\'" at gdb's input.
78 test_print_reject "p '\\\\\\'"
79
80 # Test various decimal values.
81
82 test_print_reject "p DEADBEEF"
83
84 test_print_reject "p 123DEADBEEF"
85 test_print_reject "p 123foobar.bazfoo3"
86 test_print_reject "p 123EEEEEEEEEEEEEEEEE33333k333"
87 gdb_test "p 123.4+56.7" "180.(099\[0-9]*|100\[0-9\]*)" "check for floating addition"
88
89 # Test various octal values.
90
91 test_print_reject "p 09"
92 test_print_reject "p 079"
93
94 # Test various hexadecimal values.
95
96 test_print_reject "p 0xG"
97 test_print_reject "p 0xAG"
98}
99
d30f5e1f 100proc test_float_accepted {} {
809df446
JK
101 global gdb_prompt
102
d30f5e1f
DE
103 # Test parsing of fp value with legit text following.
104 gdb_test "p 1234.5+1" " = 1235.5" "check fp + text"
105
106 # Test all the suffixes (including no suffix).
107 gdb_test "p 1." " = 1"
108 gdb_test "p 1.5" " = 1.5"
109 gdb_test "p 1.f" " = 1"
110 gdb_test "p 1.5f" " = 1.5"
111 gdb_test "p 1.d" " = 1"
112 gdb_test "p 1.5d" " = 1.5"
809df446
JK
113
114 # Test hexadecimal floating point.
115 set test "p 0x1.1"
116 gdb_test_multiple $test $test {
117 -re " = 1\\.0625\r\n$gdb_prompt $" {
118 pass $test
119 }
120 -re "Invalid number \"0x1\\.1\"\r\n$gdb_prompt $" {
121 # Older glibc does not support hex float, newer does.
122 xfail $test
123 }
124 }
d30f5e1f
DE
125}
126
127proc test_float_rejected {} {
d30f5e1f
DE
128 # Test bad suffixes.
129 test_print_reject "p 1.1x"
130 test_print_reject "p 1.1ff"
131 test_print_reject "p 1.1dd"
132}
2dcad5ea
JM
133
134
135# Start with a fresh gdb.
136
137gdb_exit
138gdb_start
139gdb_reinitialize_dir $srcdir/$subdir
140
141gdb_test "print \$pc" "No registers\\."
142# FIXME: should also test "print $pc" when there is an execfile but no
143# remote debugging target, process or corefile.
144
145gdb_test "set print sevenbit-strings" ""
146gdb_test "set print address off" "" ""
147gdb_test "set width 0" ""
148
149if [set_lang_java] then {
150 test_integer_literals_accepted
151 test_character_literals_accepted
152 test_integer_literals_rejected
d30f5e1f
DE
153 test_float_accepted
154 test_float_rejected
2dcad5ea 155} else {
f1208f9e 156 warning "Java print command tests suppressed"
2dcad5ea 157}
This page took 1.730054 seconds and 4 git commands to generate.