]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/jit-so.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / jit-so.exp
CommitLineData
ecd75fc8 1# Copyright 2011-2014 Free Software Foundation, Inc.
3b2a0cf2
JB
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# The same tests as in jit.exp, but loading JITer itself from a shared
17# library.
18
3b2a0cf2
JB
19if {[skip_shlib_tests]} {
20 untested jit-so.exp
21 return -1
22}
23
4c93b1db 24if {[get_compiler_info]} {
3b2a0cf2
JB
25 warning "Could not get compiler info"
26 untested jit-so.exp
27 return 1
28}
29
30#
31# test running programs
32#
33
34set testfile jit-dlmain
35set srcfile ${testfile}.c
f8b41b00 36set binfile [standard_output_file ${testfile}]
3b2a0cf2
JB
37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
38 untested jit-so.exp
39 return -1
40}
41
42set testfile2 jit-main
43set srcfile2 ${testfile2}.c
f8b41b00 44set binfile2 [standard_output_file ${testfile2}.so]
724f4f80 45set binfile2_dlopen [shlib_target_file ${testfile2}.so]
3b2a0cf2
JB
46if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
47 untested jit.exp
48 return -1
49}
50
51set solib_testfile "jit-solib"
52set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
f8b41b00 53set solib_binfile [standard_output_file ${solib_testfile}.so]
724f4f80 54set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
3b2a0cf2
JB
55
56# Note: compiling without debug info: the library goes through symbol
57# renaming by munging on its symbol table, and that wouldn't work for .debug
58# sections. Also, output for "info function" changes when debug info is resent.
59if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
60 untested jit-so.exp
61 return -1
62}
63
08b3fe69
TT
64if {[is_remote target]} {
65 set solib_binfile_target [gdb_download ${solib_binfile}]
66} else {
67 set solib_binfile_target $solib_binfile
68}
724f4f80 69
0a251e08
YQ
70proc one_jit_test {count match_str} {
71 with_test_prefix "one_jit_test-$count" {
72 global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg
73
74 clean_restart $testfile
75 gdb_load_shlibs $binfile2
76
77 # This is just to help debugging when things fail
78 if {$verbose > 0} {
79 gdb_test "set debug jit 1"
80 }
81
82 if { ![runto_main] } {
83 fail "Can't run to main"
84 return
85 }
86
87 gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ]
88 gdb_continue_to_breakpoint "break here before-dlopen"
89 # Poke desired values directly into inferior instead of using "set args"
90 # because "set args" does not work under gdbserver.
91 gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\""
92
93 gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ]
94 gdb_continue_to_breakpoint "break here after-dlopen"
95
96 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]"
97 gdb_continue_to_breakpoint "break here 0"
98
99 gdb_test_no_output "set var argc = 2"
100 gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
101 gdb_test_no_output "set var count = $count"
102
103 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]"
104 gdb_continue_to_breakpoint "break here 1"
105
106 gdb_test "info function jit_function" "$match_str"
107
108 # This is just to help debugging when things fail
109 if {$verbose > 0} {
110 gdb_test "maintenance print objfiles"
111 gdb_test "maintenance info break"
112 }
113
114 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]"
115 gdb_continue_to_breakpoint "break here 2"
116 # All jit librares must have been unregistered
117 gdb_test "info function jit_function" \
118 "All functions matching regular expression \"jit_function\":"
3b2a0cf2 119 }
0a251e08 120}
3b2a0cf2
JB
121
122one_jit_test 1 "${hex} jit_function_0000"
123one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"