Copyright year update in most files of the GDB Project.
[external/binutils.git] / gdb / testsuite / gdb.java / jmisc.exp
1 # Copyright 2000, 2004, 2006-2012 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 # 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 if { [skip_java_tests] } { continue }
26
27 set testfile "jmisc"
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
35 # Start with a fresh gdb.
36
37 gdb_exit
38 gdb_start
39 gdb_reinitialize_dir $srcdir/$subdir
40 gdb_load $binfile
41
42 gdb_test "set print sevenbit-strings" ".*"
43
44 if [set_lang_java] then {
45     # Ref PR gdb:java/1565.  Don't use the simpler "break jmisc.main".
46     # As of 2004-02-24 it wasn't working and is being tested separatly.
47     # Before GCJ 4.1 (approximately) the demangled name did not include
48     # a method signature; after that point it does include a trailing
49     # signature.
50     runto_main
51     set function "${testfile}.main(java.lang.String\[\])"
52     gdb_breakpoint "$function" { allow-pending }
53     gdb_breakpoint "${function}void" { allow-pending }
54     gdb_continue_to_breakpoint $function
55
56     gdb_test_multiple "ptype jmisc" "ptype jmisc" {
57         -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 $" {
58             pass "ptype jmisc"
59         }
60         -re "type = class jmisc  extends java.lang.Object \{\[\r\n\ \t]+jmisc\\(\\);\[\r\n\ \t]+void main\\(java\.lang\.String\\\[]\\);\[\r\n\ \t]+\}\[\r\n\ \t]+$gdb_prompt $" {
61             pass "ptype jmisc"
62         }
63     }
64
65     gdb_test "p args" \
66         "\\\$1 = java\.lang\.String\\\[]@\[a-f0-9]+"
67
68     gdb_test_multiple "p *args" "p *args" {
69         -re "\\\$2 = \{length: 0\}\[\r\n\ \t]+$gdb_prompt $" {
70             pass "p *args"
71         }
72         -re "\\\$2 = cannot find java.lang.Object.*$gdb_prompt $" {
73             # Sometimes GCC 4.x does not emit the necessary information
74             # about java.lang.Object.
75             kfail "p *args" gdb/2214
76         }
77     }
78
79     # The idea of running to 'exit' is that 'exit' is in a different
80     # objfile from the rest of the program (provided that program is
81     # linked normally with a shared libc).  That causes gdb to examine
82     # fresh objfiles.  There is nothing important about 'exit'
83     # semantics; it could be any symbol that is in a shared library.
84     # -- chastain 2003-08-06
85
86     if [gdb_breakpoint exit] {
87         pass "break exit"
88     }
89     gdb_test_multiple "continue" "continue to exit" {
90         -re ".*Breakpoint $decimal, .*exit.*$gdb_prompt $" {
91             pass "continue to exit"
92         }
93         -re ".*internal-error: sect_index_text not initialized.*\\(y or n\\) " {
94             # gdb choked on the "anonymous objfile" (probably).
95             kfail "gdb/1322" "continue to exit"
96             # get back to the gdb prompt
97             gdb_test_multiple "no" "internal sync 1" {
98                 -re ".*\\(y or n\\) " {
99                     gdb_test_multiple "no" "internal sync 2" {
100                         -re ".*$gdb_prompt $" { ; }
101                     }
102                 }
103             }
104         }
105     }
106
107     # Test a non-mathing return type really fails the look up.
108     gdb_test_no_output "set breakpoint pending off"
109     gdb_test {break jmisc.main(java.lang.String[])int} {Function "jmisc\.main\(java\.lang\.String\[\]\)int" not defined\.}
110 }