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