9fadd868a4061811e23c3aaffd2aff0f3497bd57
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jit-so.exp
1 # Copyright 2011-2016 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 # The same tests as in jit.exp, but loading JITer itself from a shared
17 # library.
18
19 if {[skip_shlib_tests]} {
20 untested jit-so.exp
21 return -1
22 }
23
24 if {[get_compiler_info]} {
25 warning "Could not get compiler info"
26 untested jit-so.exp
27 return 1
28 }
29
30 #
31 # test running programs
32 #
33
34 set testfile jit-dlmain
35 set srcfile ${testfile}.c
36 set binfile [standard_output_file ${testfile}]
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
38 untested jit-so.exp
39 return -1
40 }
41
42 set testfile2 jit-main
43 set srcfile2 ${testfile2}.c
44 set binfile2 [standard_output_file ${testfile2}.so]
45 set binfile2_dlopen [shlib_target_file ${testfile2}.so]
46 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
47 untested jit.exp
48 return -1
49 }
50
51 set solib_testfile "jit-solib"
52 set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
53 set solib_binfile [standard_output_file ${solib_testfile}.so]
54 set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
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.
59 if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
60 untested jit-so.exp
61 return -1
62 }
63
64 set solib_binfile_target [gdb_remote_download target ${solib_binfile}]
65
66 proc one_jit_test {count match_str} {
67 with_test_prefix "one_jit_test-$count" {
68 global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg
69
70 clean_restart $testfile
71 gdb_load_shlib $binfile2
72
73 # This is just to help debugging when things fail
74 if {$verbose > 0} {
75 gdb_test "set debug jit 1"
76 }
77
78 if { ![runto_main] } {
79 fail "Can't run to main"
80 return
81 }
82
83 gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ]
84 gdb_continue_to_breakpoint "break here before-dlopen"
85 # Poke desired values directly into inferior instead of using "set args"
86 # because "set args" does not work under gdbserver.
87 gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\""
88
89 gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ]
90 gdb_continue_to_breakpoint "break here after-dlopen"
91
92 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]"
93 gdb_continue_to_breakpoint "break here 0"
94
95 gdb_test_no_output "set var argc = 2"
96 gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
97 gdb_test_no_output "set var count = $count"
98
99 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]"
100 gdb_continue_to_breakpoint "break here 1"
101
102 gdb_test "info function jit_function" "$match_str"
103
104 # This is just to help debugging when things fail
105 if {$verbose > 0} {
106 gdb_test "maintenance print objfiles"
107 gdb_test "maintenance info break"
108 }
109
110 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]"
111 gdb_continue_to_breakpoint "break here 2"
112 # All jit librares must have been unregistered
113 gdb_test "info function jit_function" \
114 "All functions matching regular expression \"jit_function\":"
115 }
116 }
117
118 one_jit_test 1 "${hex} jit_function_0000"
119 one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
120
121 # We don't intend to load the .so as a JIT debuginfo reader, but we
122 # need some handy file name for a completion test.
123 gdb_test \
124 "complete jit-reader-load [standard_output_file ${solib_testfile}.s]" \
125 "jit-reader-load $solib_binfile" \
126 "test jit-reader-load filename completion"
This page took 0.032109 seconds and 3 git commands to generate.