2016-01-01 05:33:14 +01:00
|
|
|
# Copyright 2011-2016 Free Software Foundation, Inc.
|
2011-07-06 23:40:17 +02:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# The same tests as in jit.exp, but loading JITer itself from a shared
|
|
|
|
# library.
|
|
|
|
|
|
|
|
if {[skip_shlib_tests]} {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "skipping shared library tests"
|
2011-07-06 23:40:17 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2012-06-21 22:46:25 +02:00
|
|
|
if {[get_compiler_info]} {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "could not get compiler info"
|
2011-07-06 23:40:17 +02:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# test running programs
|
|
|
|
#
|
|
|
|
|
|
|
|
set testfile jit-dlmain
|
|
|
|
set srcfile ${testfile}.c
|
test suite update - gdb.base/[h-m]
Convert files gdb.base/[h-m]*.exp to use standard_output_file et al.
* hook-stop-continue.exp, hook-stop-frame.exp, huge.exp,
included.exp, inferior-died.exp, infnan.exp, info-fun.exp,
info-macros.exp, info-os.exp, info-proc.exp, info-target.exp,
infoline.exp, interp.exp, interrupt.exp, jit-simple.exp,
jit-so.exp, jump.exp, kill-after-signal.exp, label.exp, langs.exp,
lineinc.exp, list.exp, logical.exp, long_long.exp, longjmp.exp,
macscp.exp, maint.exp, memattr.exp, mips_pro.exp, miscexprs.exp,
morestack.exp, moribund-step.exp, multi-forks.exp: Use
standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 20:51:31 +02:00
|
|
|
set binfile [standard_output_file ${testfile}]
|
2011-07-06 23:40:17 +02:00
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug shlib_load}] != "" } {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "failed to compile"
|
2011-07-06 23:40:17 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set testfile2 jit-main
|
|
|
|
set srcfile2 ${testfile2}.c
|
test suite update - gdb.base/[h-m]
Convert files gdb.base/[h-m]*.exp to use standard_output_file et al.
* hook-stop-continue.exp, hook-stop-frame.exp, huge.exp,
included.exp, inferior-died.exp, infnan.exp, info-fun.exp,
info-macros.exp, info-os.exp, info-proc.exp, info-target.exp,
infoline.exp, interp.exp, interrupt.exp, jit-simple.exp,
jit-so.exp, jump.exp, kill-after-signal.exp, label.exp, langs.exp,
lineinc.exp, list.exp, logical.exp, long_long.exp, longjmp.exp,
macscp.exp, maint.exp, memattr.exp, mips_pro.exp, miscexprs.exp,
morestack.exp, moribund-step.exp, multi-forks.exp: Use
standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 20:51:31 +02:00
|
|
|
set binfile2 [standard_output_file ${testfile2}.so]
|
2011-08-04 13:56:29 +02:00
|
|
|
set binfile2_dlopen [shlib_target_file ${testfile2}.so]
|
2011-07-06 23:40:17 +02:00
|
|
|
if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug additional_flags="-DMAIN=jit_dl_main"}] != "" } {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "failed to compile main shared library"
|
2011-07-06 23:40:17 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
set solib_testfile "jit-solib"
|
|
|
|
set solib_srcfile "${srcdir}/${subdir}/${solib_testfile}.c"
|
test suite update - gdb.base/[h-m]
Convert files gdb.base/[h-m]*.exp to use standard_output_file et al.
* hook-stop-continue.exp, hook-stop-frame.exp, huge.exp,
included.exp, inferior-died.exp, infnan.exp, info-fun.exp,
info-macros.exp, info-os.exp, info-proc.exp, info-target.exp,
infoline.exp, interp.exp, interrupt.exp, jit-simple.exp,
jit-so.exp, jump.exp, kill-after-signal.exp, label.exp, langs.exp,
lineinc.exp, list.exp, logical.exp, long_long.exp, longjmp.exp,
macscp.exp, maint.exp, memattr.exp, mips_pro.exp, miscexprs.exp,
morestack.exp, moribund-step.exp, multi-forks.exp: Use
standard_testfile, standard_output_file, prepare_for_testing,
clean_restart.
2013-06-27 20:51:31 +02:00
|
|
|
set solib_binfile [standard_output_file ${solib_testfile}.so]
|
2011-08-04 13:56:29 +02:00
|
|
|
set solib_binfile_test_msg "SHLIBDIR/${solib_testfile}.so"
|
2011-07-06 23:40:17 +02:00
|
|
|
|
|
|
|
# Note: compiling without debug info: the library goes through symbol
|
|
|
|
# renaming by munging on its symbol table, and that wouldn't work for .debug
|
|
|
|
# sections. Also, output for "info function" changes when debug info is resent.
|
|
|
|
if { [gdb_compile_shlib ${solib_srcfile} ${solib_binfile} {}] != "" } {
|
2016-12-01 21:47:50 +01:00
|
|
|
untested "failed to compile jit shared library"
|
2011-07-06 23:40:17 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
Improve gdb_remote_download, remove gdb_download
This patch removes gdb_download in favor of gdb_remote_download, since
they are very close in functionality. Also, in preparation for the
following patch about shared library handling during tests, it improves
gdb_remote_download so that it uses standard_output_file for any
destination board that is local, not only host.
If the destination board is remote, gdb_remote_download will use the
standard remote_download from DejaGnu, resulting in the file being
transferred on the remote system.
If the destination is local, gdb_remote_download will copy the file to
the standard test directory (found using standard_output_file). Tcl's
file copy seems to handle gracefully cases where the source file is the
same as the destination, so I don't think it's necessary to check for
that case ourselves, as a previous version of the patch did.
I'd prefer to keep the name gdb_download instead of gdb_remote_download,
since I don't like the fact that gdb_remote_download implies that the
destination is remote, when it's not always the case. However,
gdb_remote_download is used at many more places than gdb_download, so
it's easier to reuse that. Also, since it's a wrapper around DejaGnu's
remote_download, it might be better to keep that name. I don't know.
I ran the testsuite native, with native-gdbserver and with a
remote gdbserver, and didn't see any related failure.
gdb/testsuite/ChangeLog:
* gdb.base/jit-so.exp: Use gdb_remote_download instead of
gdb_download. Use it even if the target is not remote.
* gdb.base/jit.exp (compile_jit_test): Likewise.
* lib/gdb.exp (gdb_remote_download): Copy files to the standard
output directory if the destination board is local, otherwise use
the standard remote_download from DejaGnu.
(gdb_download): Remove.
(gdb_load_shlibs): Use gdb_remote_download instead of
gdb_download.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Use gdb_remote_download instead of gdb_download. Use it even if
the target is not remote.
* lib/mi-support.exp (mi_load_shlibs): Use gdb_remote_download
instead of gdb_download.
2016-04-05 19:59:49 +02:00
|
|
|
set solib_binfile_target [gdb_remote_download target ${solib_binfile}]
|
2011-08-04 13:56:29 +02:00
|
|
|
|
2013-03-15 02:41:29 +01:00
|
|
|
proc one_jit_test {count match_str} {
|
|
|
|
with_test_prefix "one_jit_test-$count" {
|
|
|
|
global verbose testfile srcfile2 binfile2 binfile2_dlopen solib_binfile_target solib_binfile_test_msg
|
|
|
|
|
|
|
|
clean_restart $testfile
|
2016-04-28 00:08:59 +02:00
|
|
|
gdb_load_shlib $binfile2
|
2013-03-15 02:41:29 +01:00
|
|
|
|
|
|
|
# This is just to help debugging when things fail
|
|
|
|
if {$verbose > 0} {
|
|
|
|
gdb_test "set debug jit 1"
|
|
|
|
}
|
|
|
|
|
|
|
|
if { ![runto_main] } {
|
2016-12-01 21:40:05 +01:00
|
|
|
fail "can't run to main"
|
2013-03-15 02:41:29 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_breakpoint [gdb_get_line_number "break here before-dlopen" ]
|
|
|
|
gdb_continue_to_breakpoint "break here before-dlopen"
|
|
|
|
# Poke desired values directly into inferior instead of using "set args"
|
|
|
|
# because "set args" does not work under gdbserver.
|
|
|
|
gdb_test_no_output "set var jit_libname = \"$binfile2_dlopen\""
|
|
|
|
|
|
|
|
gdb_breakpoint [gdb_get_line_number "break here after-dlopen" ]
|
|
|
|
gdb_continue_to_breakpoint "break here after-dlopen"
|
|
|
|
|
|
|
|
gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 0} $srcfile2]"
|
|
|
|
gdb_continue_to_breakpoint "break here 0"
|
|
|
|
|
|
|
|
gdb_test_no_output "set var argc = 2"
|
|
|
|
gdb_test_no_output "set var libname = \"$solib_binfile_target\"" "set var libname = \"$solib_binfile_test_msg\""
|
|
|
|
gdb_test_no_output "set var count = $count"
|
|
|
|
|
|
|
|
gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 1} $srcfile2]"
|
|
|
|
gdb_continue_to_breakpoint "break here 1"
|
|
|
|
|
|
|
|
gdb_test "info function jit_function" "$match_str"
|
|
|
|
|
|
|
|
# This is just to help debugging when things fail
|
|
|
|
if {$verbose > 0} {
|
|
|
|
gdb_test "maintenance print objfiles"
|
|
|
|
gdb_test "maintenance info break"
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_breakpoint "$srcfile2:[gdb_get_line_number {break here 2} $srcfile2]"
|
|
|
|
gdb_continue_to_breakpoint "break here 2"
|
|
|
|
# All jit librares must have been unregistered
|
|
|
|
gdb_test "info function jit_function" \
|
|
|
|
"All functions matching regular expression \"jit_function\":"
|
2011-07-06 23:40:17 +02:00
|
|
|
}
|
2013-03-15 02:41:29 +01:00
|
|
|
}
|
2011-07-06 23:40:17 +02:00
|
|
|
|
|
|
|
one_jit_test 1 "${hex} jit_function_0000"
|
|
|
|
one_jit_test 2 "${hex} jit_function_0000\[\r\n\]+${hex} jit_function_0001"
|
2015-03-02 04:33:00 +01:00
|
|
|
|
|
|
|
# We don't intend to load the .so as a JIT debuginfo reader, but we
|
|
|
|
# need some handy file name for a completion test.
|
|
|
|
gdb_test \
|
|
|
|
"complete jit-reader-load [standard_output_file ${solib_testfile}.s]" \
|
|
|
|
"jit-reader-load $solib_binfile" \
|
|
|
|
"test jit-reader-load filename completion"
|