* gdb.base/jit-so.exp (one_jit_test): Remove spurious backslash.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jit-so.exp
1 # Copyright 2011 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 $tracelevel {
20 strace $tracelevel
21 }
22
23 if {[skip_shlib_tests]} {
24 untested jit-so.exp
25 return -1
26 }
27
28 if {[get_compiler_info not-used]} {
29 warning "Could not get compiler info"
30 untested jit-so.exp
31 return 1
32 }
33
34 #
35 # test running programs
36 #
37
38 set testfile jit-dlmain
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
42 untested jit-so.exp
43 return -1
44 }
45
46 set testfile2 jit-main
47 set srcfile2 ${testfile2}.c
48 set binfile2 ${objdir}/${subdir}/${testfile2}.so
49 set binfile2_dlopen [shlib_target_file ${testfile2}.so]
50 if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
51 untested jit.exp
52 return -1
53 }
54
55 set solib_testfile "jit-solib"
56 set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
57 set solib_binfile "${objdir}/${subdir}/${solib_testfile}.so"
58 set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
59
60 # Note: compiling without debug info: the library goes through symbol
61 # renaming by munging on its symbol table, and that wouldn't work for .debug
62 # sections. Also, output for "info function" changes when debug info is resent.
63 if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
64 untested jit-so.exp
65 return -1
66 }
67
68 set solib_binfile_target [gdb_download ${solib_binfile}]
69
70 proc one_jit_test {count match_str} {
71 global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg pf_prefix
72
73 set old_pf_prefix $pf_prefix
74 set pf_prefix "one_jit_test-$count"
75
76 clean_restart $testfile
77 gdb_load_shlibs $binfile2
78
79 # This is just to help debugging when things fail
80 if {$verbose > 0} {
81 gdb_test "set debug jit 1"
82 }
83
84 if { ![runto_main] } {
85 fail "Can't run to main"
86 return
87 }
88
89 gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ]
90 gdb_continue_to_breakpoint "break here before-dlopen"
91 # Poke desired values directly into inferior instead of using "set args"
92 # because "set args" does not work under gdbserver.
93 gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\""
94
95 gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ]
96 gdb_continue_to_breakpoint "break here after-dlopen"
97
98 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]"
99 gdb_continue_to_breakpoint "break here 0"
100
101 gdb_test_no_output "set var argc = 2"
102 gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
103 gdb_test_no_output "set var count = $count"
104
105 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]"
106 gdb_continue_to_breakpoint "break here 1"
107
108 gdb_test "info function jit_function" "$match_str"
109
110 # This is just to help debugging when things fail
111 if {$verbose > 0} {
112 gdb_test "maintenance print objfiles"
113 gdb_test "maintenance info break"
114 }
115
116 gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]"
117 gdb_continue_to_breakpoint "break here 2"
118 # All jit librares must have been unregistered
119 gdb_test "info function jit_function" \
120 "All functions matching regular expression \"jit_function\":"
121 set pf_prefix $old_pf_prefix
122 }
123
124 one_jit_test 1 "${hex} jit_function_0000"
125 one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
This page took 0.033879 seconds and 5 git commands to generate.