1 |
227 |
jeremybenn |
# Copyright 2004, 2006, 2007, 2008, 2009, 2010 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 .
|
15 |
|
|
|
16 |
|
|
# This file was written by Jeff Johnston. (jjohnstn@redhat.com)
|
17 |
|
|
#
|
18 |
|
|
|
19 |
|
|
if $tracelevel then {
|
20 |
|
|
strace $tracelevel
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
load_lib "java.exp"
|
24 |
|
|
|
25 |
|
|
if { [skip_java_tests] } { continue }
|
26 |
|
|
|
27 |
|
|
set testfile "jprint"
|
28 |
|
|
set srcfile ${srcdir}/$subdir/${testfile}.java
|
29 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
30 |
|
|
if {[compile_java_from_source ${srcfile} ${binfile} "-g"] != ""} {
|
31 |
|
|
continue
|
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 |
|
|
|
37 |
|
|
proc set_lang_java {} {
|
38 |
|
|
global gdb_prompt
|
39 |
|
|
global binfile objdir subdir
|
40 |
|
|
|
41 |
|
|
verbose "loading file '$binfile'"
|
42 |
|
|
gdb_load $binfile
|
43 |
|
|
|
44 |
|
|
send_gdb "set language java\n"
|
45 |
|
|
gdb_expect {
|
46 |
|
|
-re ".*$gdb_prompt $" {}
|
47 |
|
|
timeout { fail "set language java (timeout)" ; return 0 }
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
return [gdb_test "show language" ".* source language is \"java\".*" \
|
51 |
|
|
"set language to \"java\""]
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
set prms_id 0
|
55 |
|
|
set bug_id 0
|
56 |
|
|
|
57 |
|
|
# Start with a fresh gdb.
|
58 |
|
|
|
59 |
|
|
gdb_exit
|
60 |
|
|
gdb_start
|
61 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
62 |
|
|
|
63 |
|
|
gdb_test "set print sevenbit-strings" ".*"
|
64 |
|
|
|
65 |
|
|
if ![set_lang_java] then {
|
66 |
|
|
# Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
|
67 |
|
|
# As of 2004-02-24 it wasn't working and is being tested separatly.
|
68 |
|
|
# Before GCJ 4.1 (approximately) the demangled name did not include
|
69 |
|
|
# a method signature; after that point it does include a trailing
|
70 |
|
|
# signature.
|
71 |
|
|
runto_main
|
72 |
|
|
set function "${testfile}.main(java.lang.String\[\])"
|
73 |
|
|
gdb_breakpoint "\'$function\'" { allow-pending }
|
74 |
|
|
gdb_breakpoint "\'${function}void\'" { allow-pending }
|
75 |
|
|
gdb_continue_to_breakpoint $function
|
76 |
|
|
|
77 |
|
|
gdb_test "p jvclass.addprint(4,5,6)" "sum is 15\r\n.*" "unambiguous static call"
|
78 |
|
|
|
79 |
|
|
gdb_test "next" ""
|
80 |
|
|
gdb_test "next" ""
|
81 |
|
|
|
82 |
|
|
gdb_test "p x.print(44)" "x is 44\r\n.*" "single argument print call"
|
83 |
|
|
gdb_test "p x.print(22,33)" "y is 33\r\n.*" "double argument print call"
|
84 |
|
|
gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
|
85 |
|
|
gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
|
86 |
|
|
gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
|
87 |
|
|
|
88 |
|
|
# Regression test for a crasher.
|
89 |
|
|
gdb_test "print *jprint.props" " = .*" "print a java.util.Properties"
|
90 |
|
|
}
|