Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 2000, 2004, 2006, 2007, 2008 Free Software Foundation, Inc. |
9d273ca3 AG |
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 |
9d273ca3 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
9d273ca3 AG |
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 | # |
9d273ca3 | 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/>. |
9d273ca3 | 15 | |
9d273ca3 AG |
16 | # This file was written by Anthony Green. (green@redhat.com) |
17 | # | |
18 | ||
19 | if $tracelevel then { | |
20 | strace $tracelevel | |
21 | } | |
22 | ||
23 | load_lib "java.exp" | |
24 | ||
25 | set testfile "jmisc" | |
26 | set srcfile ${srcdir}/$subdir/${testfile}.java | |
27 | set binfile ${objdir}/${subdir}/${testfile} | |
81d2cbae NS |
28 | if { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } { |
29 | untested "Couldn't compile ${srcfile}" | |
30 | return -1 | |
9d273ca3 AG |
31 | } |
32 | ||
33 | # Set the current language to java. This counts as a test. If it | |
34 | # fails, then we skip the other tests. | |
35 | ||
36 | proc set_lang_java {} { | |
37 | global gdb_prompt | |
38 | global binfile objdir subdir | |
39 | ||
40 | verbose "loading file '$binfile'" | |
41 | gdb_load $binfile | |
42 | ||
43 | send_gdb "set language java\n" | |
44 | gdb_expect { | |
45 | -re ".*$gdb_prompt $" {} | |
46 | timeout { fail "set language java (timeout)" ; return 0 } | |
47 | } | |
48 | ||
49 | return [gdb_test "show language" ".* source language is \"java\".*" \ | |
50 | "set language to \"java\""] | |
51 | } | |
52 | ||
53 | set prms_id 0 | |
54 | set bug_id 0 | |
55 | ||
56 | # Start with a fresh gdb. | |
57 | ||
58 | gdb_exit | |
59 | gdb_start | |
60 | gdb_reinitialize_dir $srcdir/$subdir | |
61 | ||
62 | gdb_test "set print sevenbit-strings" ".*" | |
63 | ||
64 | if ![set_lang_java] then { | |
b8a56647 AC |
65 | # Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main". |
66 | # As of 2004-02-24 it wasn't working and is being tested separatly. | |
2fa63963 DJ |
67 | # Before GCJ 4.1 (approximately) the demangled name did not include |
68 | # a method signature; after that point it does include a trailing | |
69 | # signature. | |
70 | runto_main | |
71 | set function "${testfile}.main(java.lang.String\[\])" | |
72 | gdb_breakpoint "\'$function\'" { allow-pending } | |
73 | gdb_breakpoint "\'${function}void\'" { allow-pending } | |
74 | gdb_continue_to_breakpoint $function | |
9d273ca3 AG |
75 | |
76 | send_gdb "ptype jmisc\n" | |
77 | gdb_expect { | |
2fa63963 DJ |
78 | -re "type = class jmisc extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" |
79 | { pass "ptype jmisc" } | |
80 | -re "type = class jmisc extends java.lang.Object \{\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\)void;\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" { | |
81 | # Just because GCC includes the signature doesn't mean we | |
82 | # should print it here. We already show the return type. | |
83 | kfail "ptype jmisc" gdb/2215 | |
84 | } | |
9d273ca3 AG |
85 | -re ".*$gdb_prompt $" { fail "ptype jmisc" } |
86 | timeout { fail "ptype jmisc (timeout)" ; return } | |
87 | } | |
88 | ||
89 | send_gdb "p args\n" | |
90 | gdb_expect { | |
91 | -re "\\\$1 = java\.lang\.String\\\[]@\[a-f0-9]+\[\r\n\ \t]+$gdb_prompt $" { pass "p args" } | |
92 | -re ".*$gdb_prompt $" { fail "p args" } | |
93 | timeout { fail "p args (timeout)" ; return } | |
94 | } | |
95 | ||
96 | send_gdb "p *args\n" | |
97 | gdb_expect { | |
98 | -re "\\\$2 = \{length: 0\}\[\r\n\ \t]+$gdb_prompt $" { pass "p *args" } | |
2fa63963 DJ |
99 | -re "\\\$2 = cannot find java.lang.Object.*$gdb_prompt $" { |
100 | # Sometimes GCC 4.x does not emit the necessary information | |
101 | # about java.lang.Object. | |
102 | kfail "p *args" gdb/2214 | |
103 | } | |
9d273ca3 AG |
104 | -re ".*$gdb_prompt $" { fail "p *args" } |
105 | timeout { fail "p *args (timeout)" ; return } | |
106 | } | |
2fa63963 DJ |
107 | |
108 | # The idea of running to 'exit' is that 'exit' is in a different | |
109 | # objfile from the rest of the program (provided that program is | |
110 | # linked normally with a shared libc). That causes gdb to examine | |
111 | # fresh objfiles. There is nothing important about 'exit' | |
112 | # semantics; it could be any symbol that is in a shared library. | |
113 | # -- chastain 2003-08-06 | |
114 | ||
115 | if [gdb_breakpoint exit] { | |
116 | pass "break exit" | |
117 | } | |
118 | gdb_test_multiple "continue" "continue to exit" { | |
119 | -re ".*Breakpoint $decimal, .*exit.*$gdb_prompt $" { | |
120 | pass "continue to exit" | |
121 | } | |
122 | -re ".*internal-error: sect_index_text not initialized.*\\(y or n\\) " { | |
123 | # gdb choked on the "anonymous objfile" (probably). | |
124 | kfail "gdb/1322" "continue to exit" | |
125 | # get back to the gdb prompt | |
126 | gdb_test_multiple "no" "internal sync 1" { | |
127 | -re ".*\\(y or n\\) " { | |
128 | gdb_test_multiple "no" "internal sync 2" { | |
129 | -re ".*$gdb_prompt $" { ; } | |
130 | } | |
131 | } | |
132 | } | |
133 | } | |
134 | } | |
9d273ca3 | 135 | } |