1 # Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>.
20 if {[skip_shlib_tests]} {
25 if {[get_compiler_info not-used]} {
26 warning "Could not get compiler info"
32 # test running programs
36 set srcfile ${testfile}.c
37 set binfile ${objdir}/${subdir}/${testfile}
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
43 set solib_testfile "jit-solib"
44 set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
45 set solib_binfile "${objdir}/${subdir}/${solib_testfile}.so"
46 set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
48 # Note: compiling without debug info: the library goes through symbol
49 # renaming by munging on its symbol table, and that wouldn't work for .debug
50 # sections. Also, output for "info function" changes when debug info is resent.
51 if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {-fPIC}] != "" } {
56 set solib_binfile_target [gdb_download ${solib_binfile}]
58 proc one_jit_test {count match_str} {
59 global verbose testfile solib_binfile_target solib_binfile_test_msg pf_prefix
61 set old_pf_prefix $pf_prefix
62 set pf_prefix "one_jit_test-$count"
64 clean_restart $testfile
66 # This is just to help debugging when things fail
68 gdb_test "set debug jit 1"
71 if { ![runto_main] } {
72 fail "Can't run to main"
76 gdb_breakpoint [gdb_get_line_number "break here 0"]
77 gdb_continue_to_breakpoint "break here 0"
79 # Poke desired values directly into inferior instead of using "set args"
80 # because "set args" does not work under gdbserver.
81 gdb_test_no_output "set var argc = 2"
82 gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
83 gdb_test_no_output "set var count = $count"
85 gdb_breakpoint [gdb_get_line_number "break here 1"]
86 gdb_continue_to_breakpoint "break here 1"
88 gdb_test "info function jit_function" "$match_str"
90 # This is just to help debugging when things fail
92 gdb_test "maintenance print objfiles"
93 gdb_test "maintenance info break"
96 gdb_breakpoint [gdb_get_line_number "break here 2"]
97 gdb_continue_to_breakpoint "break here 2"
98 # All jit librares must have been unregistered
99 gdb_test "info function jit_function" \
100 "All functions matching regular expression \"jit_function\":" \
101 set pf_prefix $old_pf_prefix
104 one_jit_test 1 "${hex} jit_function_0000"
105 one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"