2010-05-26 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.java / jprint.exp
CommitLineData
4c38e0a4 1# Copyright 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
7213f6d6
JJ
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
7213f6d6 6# (at your option) any later version.
e22f8b7c 7#
7213f6d6
JJ
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#
7213f6d6 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/>.
7213f6d6
JJ
15
16# This file was written by Jeff Johnston. (jjohnstn@redhat.com)
17#
18
19if $tracelevel then {
20 strace $tracelevel
21}
22
23load_lib "java.exp"
24
ec3c07fc
NS
25if { [skip_java_tests] } { continue }
26
7213f6d6
JJ
27set testfile "jprint"
28set srcfile ${srcdir}/$subdir/${testfile}.java
29set binfile ${objdir}/${subdir}/${testfile}
ec3c07fc
NS
30if {[compile_java_from_source ${srcfile} ${binfile} "-g"] != ""} {
31 continue
7213f6d6
JJ
32}
33
34# Set the current language to java. This counts as a test. If it
35# fails, then we skip the other tests.
36
37proc set_lang_java {} {
38 global gdb_prompt
39 global binfile objdir subdir
40
41 verbose "loading file '$binfile'"
42 gdb_load $binfile
43
23de6b34 44 gdb_test_no_output "set language java"
7213f6d6
JJ
45
46 return [gdb_test "show language" ".* source language is \"java\".*" \
47 "set language to \"java\""]
48}
49
7213f6d6
JJ
50
51# Start with a fresh gdb.
52
53gdb_exit
54gdb_start
55gdb_reinitialize_dir $srcdir/$subdir
56
57gdb_test "set print sevenbit-strings" ".*"
58
59if ![set_lang_java] then {
60 # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
61 # As of 2004-02-24 it wasn't working and is being tested separatly.
2fa63963
DJ
62 # Before GCJ 4.1 (approximately) the demangled name did not include
63 # a method signature; after that point it does include a trailing
64 # signature.
65 runto_main
66 set function "${testfile}.main(java.lang.String\[\])"
cec808ec
KS
67 gdb_breakpoint "$function" { allow-pending }
68 gdb_breakpoint "${function}void" { allow-pending }
2fa63963 69 gdb_continue_to_breakpoint $function
7213f6d6
JJ
70
71 gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
72
73 gdb_test "next" ""
74 gdb_test "next" ""
75
76 gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call"
77 gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call"
78 gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
79 gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
80 gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
6f451e5e
TT
81
82 # Regression test for a crasher.
e62b8c7e
KS
83 # GCC does not output location information for static class members,
84 # so GDB will report these as "optimized out". See gcc/43260.
85 setup_xfail *-*-* gcc/43260
6f451e5e 86 gdb_test "print *jprint.props" " = .*" "print a java.util.Properties"
7213f6d6 87}
This page took 0.579545 seconds and 4 git commands to generate.