2016-01-01 04:33:14 +00:00
|
|
|
# Copyright 2009-2016 Free Software Foundation, Inc.
|
2012-11-09 12:20:24 +00: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/>.
|
|
|
|
|
|
|
|
# Test multi-exec / multi-process features that work for all configurations,
|
|
|
|
# even ones that cannot run multiple processes simultaneously.
|
|
|
|
|
|
|
|
set testfile "multi-arch-exec"
|
|
|
|
|
|
|
|
# The plain remote target can't do multiple inferiors.
|
|
|
|
if [target_info exists use_gdb_stub] {
|
|
|
|
return
|
2012-12-13 20:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# The 64-bit compile may succeed for i386-linux, but gdb won't be able
|
|
|
|
# to load the file.
|
|
|
|
if [istarget "i?86-*linux*"] {
|
|
|
|
return
|
2012-11-09 12:20:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Can't use standard_testfile, we want executables with specialized
|
|
|
|
# names.
|
|
|
|
set exec1 "multi-arch-exec"
|
|
|
|
set srcfile1 multi-arch-exec.c
|
|
|
|
set binfile1 [standard_output_file ${exec1}]
|
|
|
|
|
|
|
|
set exec2 "multi-arch-exec-hello"
|
|
|
|
set srcfile2 hello.c
|
|
|
|
set binfile2 [standard_output_file ${exec2}]
|
|
|
|
|
|
|
|
# Build two executables, one for each arch.
|
|
|
|
|
|
|
|
if [istarget "s390*-*-*"] {
|
|
|
|
set march1 "-m64"
|
|
|
|
set march2 "-m31"
|
2015-07-07 15:58:19 +00:00
|
|
|
} elseif { [istarget "aarch64*-*-*"] } {
|
|
|
|
set march1 ""
|
|
|
|
set march2 ""
|
2012-11-09 12:20:24 +00:00
|
|
|
} else {
|
|
|
|
set march1 "-m64"
|
|
|
|
set march2 "-m32"
|
|
|
|
}
|
|
|
|
|
|
|
|
if { [prepare_for_testing ${testfile}.exp ${exec1} "${srcfile1}" \
|
2015-12-10 16:21:06 +00:00
|
|
|
[list debug \
|
[testsuite] Remove BASEDIR
BASEDIR was added by https://sourceware.org/ml/gdb-patches/2013-10/msg00587.html
in order to handle the different directory layout in serial testing
and parallel testing. BASEDIR is "gdb.base" in serial testing and is
"outputs/gdb.base/TESTNAME" in parallel testing. However, it doesn't
work if the GDBserver is in remote target, like this,
$ make check RUNTESTFLAGS='--target_board=remote-gdbserver-on-localhost foll-vfork.exp foll-exec.exp'
FAIL: gdb.base/foll-exec.exp: continue to first exec catchpoint (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork and exec child follow, to main bp: continue to bp (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: finish (the program exited)
FAIL: gdb.base/foll-vfork.exp: exec: vfork relations in info inferiors: continue to bp (the program exited)
these tests fail because the executable can't be found. With target
board native-gdbserver, the program is spawned this way,
spawn ../gdbserver/gdbserver --once :2347 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/foll-vfork
so BASEDIR is correct. However, with target board
remote-gdbserver-on-localhost, the program is spawned
spawn /usr/bin/ssh -l yao localhost /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/../gdbserver/gdbserver --once :2346 /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/gdb.base/foll-vfork
so BASEDIR (either "gdb.base" or "outputs/gdb.base/TESTNAME") makes no
sense.
I had a fix that pass absolute directory to BASEDIR, but it assumes
that directory structure is the same on build and target, and it
doesn't work in remote host case. The current fix in this patch is
to get the directory from argv[0]. In any case, the program to be
exec'ed is at the same directory with the main program.
Note that these tests do "next N" to let program stop at the desired
line, but it is fragile, because GDB for different targets may skip
function prologue slightly differently, so I replace some of them by
"tbreak on LINE NUMBER and continue".
gdb/testsuite:
2016-02-04 Yao Qi <yao.qi@linaro.org>
* gdb.base/foll-exec-mode.c: Include limits.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.base/foll-exec-mode.exp: Don't pass -DBASEDIR in
compilation.
* gdb.base/foll-exec.c: Include limits.h.
(main): Add parameters argc and argv.
Get directory from argv[0].
* gdb.base/foll-exec.exp: Don't pass -DBASEDIR in compilation.
Adjust tests on the number of lines as source code changed.
* gdb.base/foll-vfork-exit.c: Include limits.h.
(main): Add one line of statement before vfork.
* gdb.base/foll-vfork.c: Include limits.h and string.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.base/foll-vfork.exp: Don't pass -DBASEDIR in compilation.
(setup_gdb): Set tbreak to skip some source lines.
* gdb.multi/bkpt-multi-exec.c: Include limits.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.multi/bkpt-multi-exec.exp: Don't pass -DBASEDIR in
compilation.
* gdb.multi/multi-arch-exec.c: Include limits.h and string.h.
(main): Add parameters argc and argv. Get directory from
argv[0].
* gdb.multi/multi-arch-exec.exp: Don't pass -DBASEDIR in
compilation.
2016-02-04 15:46:37 +00:00
|
|
|
additional_flags=${march1}]] } {
|
2012-11-09 12:20:24 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2015-12-10 16:21:06 +00:00
|
|
|
set options [list debug]
|
2015-07-07 15:58:19 +00:00
|
|
|
|
|
|
|
if { [istarget "aarch64*-*-*"] } {
|
|
|
|
if {[info exists ARM_CC_FOR_TARGET]} {
|
|
|
|
lappend options "compiler=${ARM_CC_FOR_TARGET}"
|
|
|
|
} else {
|
|
|
|
unsupported "ARM compiler is not known"
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lappend options "additional_flags=${march2}"
|
|
|
|
}
|
|
|
|
|
2012-11-09 12:20:24 +00:00
|
|
|
if { [prepare_for_testing ${testfile}.exp ${exec2} "${srcfile2}" \
|
2015-07-07 15:58:19 +00:00
|
|
|
$options] } {
|
2012-11-09 12:20:24 +00:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_restart ${exec1}
|
|
|
|
if ![runto_main] then {
|
|
|
|
fail "Couldn't run to main"
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test that GDB updates the target description / arch successfuly
|
|
|
|
# after the exec.
|
|
|
|
gdb_test "continue" "Breakpoint 1, main.*" "continue across exec that changes architecture"
|