gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jit.exp
CommitLineData
d3f0f853
PP
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
16if $tracelevel {
17 strace $tracelevel
18}
19
20if {[skip_shlib_tests]} {
21 untested jit.exp
22 return -1
23}
24
25if {[get_compiler_info not-used]} {
26 warning "Could not get compiler info"
27 untested jit.exp
28 return 1
29}
30
31#
32# test running programs
33#
34
35set testfile jit-main
36set srcfile ${testfile}.c
37set binfile ${objdir}/${subdir}/${testfile}
38if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 untested jit.exp
40 return -1
41}
42
43set solib_testfile "jit-solib"
44set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
45set solib_binfile "${objdir}/${subdir}/${solib_testfile}.so"
46
47# Note: compiling without debug info: the library goes through symbol
48# renaming by munging on its symbol table, and that wouldn't work for .debug
49# sections. Also, output for "info function" changes when debug info is resent.
50if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {-fPIC}] != "" } {
51 untested jit.exp
52 return -1
53}
54
55proc one_jit_test {count match_str} {
56 global verbose testfile solib_binfile pf_prefix
57
58 set old_pf_prefix $pf_prefix
59 set pf_prefix "one_jit_test-$count"
60
61 clean_restart $testfile
62
63 # This is just to help debugging when things fail
64 if {$verbose > 0} {
65 gdb_test "set debug jit 1"
66 }
67
68 if { ![runto_main] } {
69 fail "Can't run to main"
70 return
71 }
72
73 gdb_breakpoint [gdb_get_line_number "break here 0"]
74 gdb_continue_to_breakpoint "break here 0"
75
76 # Poke desired values directly into inferior instead of using "set args"
77 # because "set args" does not work under gdbserver.
78 gdb_test "set var argc = 2"
79 gdb_test "set var libname = \"$solib_binfile\""
80 gdb_test "set var count = $count"
81
82 gdb_breakpoint [gdb_get_line_number "break here 1"]
83 gdb_continue_to_breakpoint "break here 1"
84
85 gdb_test "info function jit_function" "$match_str"
86
87 # This is just to help debugging when things fail
88 if {$verbose > 0} {
89 gdb_test "maintenance print objfiles"
90 gdb_test "maintenance info break"
91 }
92
93 gdb_breakpoint [gdb_get_line_number "break here 2"]
94 gdb_continue_to_breakpoint "break here 2"
95 # All jit librares must have been unregistered
96 gdb_test "info function jit_function" \
97 "All functions matching regular expression \"jit_function\":" \
98 set pf_prefix $old_pf_prefix
99}
100
101one_jit_test 1 "${hex} jit_function_0000"
102one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
This page took 0.026194 seconds and 4 git commands to generate.