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