Make gdb.base/jit.exp binaries unique
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / jit.exp
CommitLineData
618f726f 1# Copyright 2011-2016 Free Software Foundation, Inc.
d3f0f853
PP
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
d3f0f853
PP
16if {[skip_shlib_tests]} {
17 untested jit.exp
18 return -1
19}
20
4c93b1db 21if {[get_compiler_info]} {
d3f0f853
PP
22 warning "Could not get compiler info"
23 untested jit.exp
24 return 1
25}
26
40dea8cb
PA
27# Compile the testcase program and library. BINSUFFIX is the suffix
28# to append to the program and library filenames, to make them unique
29# between invocations. OPTIONS is passed to gdb_compile when
30# compiling the program.
d3f0f853 31
40dea8cb 32proc compile_jit_test {testname binsuffix options} {
f25c0135
TT
33 global testfile srcfile binfile srcdir subdir
34 global solib_testfile solib_srcfile solib_binfile solib_binfile_test_msg
35 global solib_binfile_target
36
37 set testfile jit-main
38 set srcfile ${testfile}.c
40dea8cb 39 set binfile [standard_output_file $testfile$binsuffix]
f25c0135
TT
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
41 executable [concat debug $options]] != "" } {
42 untested $testname
43 return -1
44 }
d3f0f853 45
f25c0135
TT
46 set solib_testfile "jit-solib"
47 set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
40dea8cb
PA
48 set solib_binfile [standard_output_file ${solib_testfile}$binsuffix.so]
49 set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}$binsuffix.so"
f25c0135
TT
50
51 # Note: compiling without debug info: the library goes through
52 # symbol renaming by munging on its symbol table, and that
53 # wouldn't work for .debug sections. Also, output for "info
54 # function" changes when debug info is present.
55 if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {-fPIC}] != "" } {
56 untested $testname
57 return -1
58 }
d3f0f853 59
08b3fe69
TT
60 if {[is_remote target]} {
61 set solib_binfile_target [gdb_download ${solib_binfile}]
62 } else {
63 set solib_binfile_target $solib_binfile
64 }
d3f0f853 65
f25c0135
TT
66 return 0
67}
724f4f80 68
0a251e08
YQ
69proc one_jit_test {count match_str} {
70 with_test_prefix "one_jit_test-$count" {
71 global verbose testfile solib_binfile_target solib_binfile_test_msg
72
73 clean_restart $testfile
74
75 # This is just to help debugging when things fail
76 if {$verbose > 0} {
77 gdb_test "set debug jit 1"
78 }
79
80 if { ![runto_main] } {
81 fail "Can't run to main"
82 return
83 }
84
85 gdb_breakpoint [gdb_get_line_number "break here 0"]
86 gdb_continue_to_breakpoint "break here 0"
87
88 # Poke desired values directly into inferior instead of using "set args"
89 # because "set args" does not work under gdbserver.
90 gdb_test_no_output "set var argc = 2"
91 gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
92 gdb_test_no_output "set var count = $count"
93
94 gdb_breakpoint [gdb_get_line_number "break here 1"]
95 gdb_continue_to_breakpoint "break here 1"
96
d9a47287 97 gdb_test "info function ^jit_function" "$match_str"
0a251e08
YQ
98
99 # This is just to help debugging when things fail
100 if {$verbose > 0} {
101 gdb_test "maintenance print objfiles"
102 gdb_test "maintenance info break"
103 }
104
105 gdb_breakpoint [gdb_get_line_number "break here 2"]
106 gdb_continue_to_breakpoint "break here 2"
107 # All jit librares must have been unregistered
108 gdb_test "info function jit_function" \
109 "All functions matching regular expression \"jit_function\":"
d3f0f853 110 }
0a251e08 111}
d3f0f853 112
40dea8cb 113if {[compile_jit_test jit.exp "" {}] < 0} {
f25c0135
TT
114 return
115}
d3f0f853
PP
116one_jit_test 1 "${hex} jit_function_0000"
117one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
f25c0135
TT
118
119with_test_prefix PIE {
120 if {[compile_jit_test "jit.exp PIE tests" \
40dea8cb 121 "-pie" {additional_flags=-fPIE ldflags=-pie}] < 0} {
f25c0135
TT
122 return
123 }
124
125 one_jit_test 1 "${hex} jit_function_0000"
126}
This page took 0.617221 seconds and 4 git commands to generate.