1 # This test code is part of GDB, the GNU debugger.
3 # Copyright 1998-2013 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 load_lib "libgloss.exp"
20 # GCJ_UNDER_TEST is the compiler under test.
24 if ![info exists tmpdir] {
28 set java_initialized 0
31 # Build the status wrapper library as needed.
33 proc java_init { args } {
35 global wrap_compile_flags;
36 global java_initialized
38 global TOOL_EXECUTABLE
41 if { $java_initialized == 1 } { return; }
43 if ![info exists GCJ_UNDER_TEST] {
44 if [info exists TOOL_EXECUTABLE] {
45 set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
47 if { [info exists env(GCJ)] && $env(GCJ) != "" } {
48 set GCJ_UNDER_TEST $env(GCJ)
53 if ![is_remote host] {
54 set file [lookfor_file $tool_root_dir gcj];
56 set file [lookfor_file $tool_root_dir gcc/gcj];
59 set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
61 set CC [transform gcj];
64 set CC [transform gcj]
66 set GCJ_UNDER_TEST $CC
72 set wrap_compile_flags "";
73 if [target_info exists needs_status_wrapper] {
74 set result [build_wrapper "testglue.o"];
75 if { $result != "" } {
76 set wrapper_file [lindex $result 0];
77 set wrap_compile_flags [lindex $result 1];
79 warning "Status wrapper failed to build."
83 set java_initialized 1
87 # Run the test specified by srcfile and resultfile. compile_args and
88 # exec_args are options telling this proc how to work.
90 proc compile_java_from_source { srcfile binfile compile_args } {
92 global java_initialized
94 if { $java_initialized != 1 } { java_init }
96 set args [list "compiler=$GCJ_UNDER_TEST"]
97 lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
98 if { $compile_args != "" } {
99 lappend args "additional_flags=$compile_args"
102 set result [target_compile $srcfile ${binfile} executable $args]
103 gdb_compile_test $srcfile $result
107 # Auxiliary function to set the language to java.
108 # The result is 1 (true) for success, 0 (false) for failure.
110 proc set_lang_java {} {
111 if [gdb_test_no_output "set language java"] {
114 if [gdb_test "show language" ".* source language is \"java\"." \
115 "set language to \"java\""] {