* gdb.java/jmain.exp: Handle demangled names with and without method
[external/binutils.git] / gdb / testsuite / gdb.java / jmain.exp
1 # Copyright 2000, 2004, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
16
17 # This file was based on jmisc.exp which in turn was written by
18 # Anthony Green. (green@redhat.com)
19
20 if $tracelevel then {
21         strace $tracelevel
22 }
23
24 load_lib "java.exp"
25
26 set testfile "jmain"
27 set srcfile ${srcdir}/$subdir/${testfile}.java
28 set binfile ${objdir}/${subdir}/${testfile}
29 if  { [compile_java_from_source ${srcfile} ${binfile} "-g"] != "" } {
30     untested "Couldn't compile ${srcfile}"
31     return -1
32 }
33
34 set prms_id 0
35 set bug_id 0
36
37 # Start with a fresh gdb.
38
39 gdb_exit
40 gdb_start
41 gdb_reinitialize_dir $srcdir/$subdir
42
43 gdb_test "set print sevenbit-strings" ".*"
44
45 # Check that plain old "main" works.  The load should both set the
46 # language to java and (since --main=jmain), some how set the scope to
47 # jmain's main.
48
49 # Where the breakpoint should always land
50
51 set bpmain "Breakpoint .* file .*jmain.java, line 5\."
52
53 # Where GCC PR 16439 puts the breakpoint.
54 set earlybpmain "Breakpoint .* file .*jmain.java, line 4\."
55
56 gdb_load "${binfile}"
57 setup_kfail *-*-* java/1567
58 gdb_test "break main" "${bpmain}"
59
60 # Check that an unqualified "main" works.
61
62 gdb_load "${binfile}"
63 setup_kfail *-*-* java/1565
64 gdb_test "break jmain.main" "${bpmain}"
65
66 # Check that a fully qualified "main" works.
67 gdb_load "${binfile}"
68 set cmd "break \'${testfile}.main(java.lang.String\[\])\'"
69 set msg $cmd
70 gdb_test_multiple $cmd $msg {
71     -re "${bpmain}\r\n$gdb_prompt $" {
72         pass $msg
73     }
74     -re "${earlybpmain}\r\n$gdb_prompt $" {
75         setup_xfail *-*-* gcc/16439
76         fail $msg
77     }
78     -re "Make breakpoint pending.* \\(y or \\\[n\\\]\\) $" {
79         gdb_test "n" "" ""
80
81         # Check again with a method signature at the end.
82         set cmd "break \'${testfile}.main(java.lang.String\[\])void\'"
83         set msg $cmd
84         gdb_test_multiple $cmd $msg {
85             -re "${bpmain}\r\n$gdb_prompt $" {
86                 pass $msg
87             }
88             -re "${earlybpmain}\r\n$gdb_prompt $" {
89                 setup_xfail *-*-* gcc/16439
90                 fail $msg
91             }
92         }
93     }
94 }
95