Upload Tizen:Base source
[external/gdb.git] / gdb / testsuite / gdb.java / jmain.exp
1 # Copyright 2000, 2004, 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 <http://www.gnu.org/licenses/>.
15
16 # This file was based on jmisc.exp which in turn was written by
17 # Anthony Green. (green@redhat.com)
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 "jmain"
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
41 gdb_test "set print sevenbit-strings" ".*"
42
43 # Check that plain old "main" works.  The load should both set the
44 # language to java and (since --main=jmain), some how set the scope to
45 # jmain's main.
46
47 # Where the breakpoint should always land
48
49 set bpmain "Breakpoint .* file .*jmain.java, line 5\."
50
51 # Where GCC PR 16439 puts the breakpoint.
52 set earlybpmain "Breakpoint .* file .*jmain.java, line 4\."
53
54 gdb_load "${binfile}"
55 setup_kfail java/1567 *-*-*
56 gdb_test "break main" "${bpmain}"
57
58 # Check that an unqualified "main" works.
59
60 gdb_load "${binfile}"
61 setup_kfail java/1565 *-*-*
62 gdb_test "break jmain.main" "${bpmain}"
63
64 # Check that a fully qualified "main" works.
65 gdb_load "${binfile}"
66 set cmd "break ${testfile}.main(java.lang.String\[\])"
67 set msg $cmd
68 gdb_test_multiple $cmd $msg {
69     -re "${bpmain}\r\n$gdb_prompt $" {
70         pass $msg
71     }
72     -re "${earlybpmain}\r\n$gdb_prompt $" {
73         setup_xfail *-*-* gcc/16439
74         fail $msg
75     }
76     -re "Make breakpoint pending.* \\(y or \\\[n\\\]\\) $" {
77         gdb_test "n" "" ""
78
79         # Check again with a method signature at the end.
80         set cmd "break ${testfile}.main(java.lang.String\[\])void"
81         set msg $cmd
82         gdb_test_multiple $cmd $msg {
83             -re "${bpmain}\r\n$gdb_prompt $" {
84                 pass $msg
85             }
86             -re "${earlybpmain}\r\n$gdb_prompt $" {
87                 setup_xfail *-*-* gcc/16439
88                 fail $msg
89             }
90         }
91     }
92 }
93