aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2016-02-04 15:46:37 +0000
committerYao Qi <yao.qi@linaro.org>2016-02-04 15:46:37 +0000
commit31d913c7e4e84edf88b4324c3a9a8fb31c8206ec (patch)
tree8392dee4304d43954d85d3285c4003a23e4f4d38 /gdb/testsuite/gdb.base
parente42e5352d1d1e8a262178f606a5df3d0d988f78a (diff)
downloadgdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.zip
gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.tar.gz
gdb-31d913c7e4e84edf88b4324c3a9a8fb31c8206ec.tar.bz2
[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.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/foll-exec-mode.c13
-rw-r--r--gdb/testsuite/gdb.base/foll-exec-mode.exp2
-rw-r--r--gdb/testsuite/gdb.base/foll-exec.c26
-rw-r--r--gdb/testsuite/gdb.base/foll-exec.exp24
-rw-r--r--gdb/testsuite/gdb.base/foll-vfork-exit.c5
-rw-r--r--gdb/testsuite/gdb.base/foll-vfork.c22
-rw-r--r--gdb/testsuite/gdb.base/foll-vfork.exp8
7 files changed, 72 insertions, 28 deletions
diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.c b/gdb/testsuite/gdb.base/foll-exec-mode.c
index 1a482a5..67686d7 100644
--- a/gdb/testsuite/gdb.base/foll-exec-mode.c
+++ b/gdb/testsuite/gdb.base/foll-exec-mode.c
@@ -19,17 +19,26 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <limits.h>
int global_i = 100;
-int main (void)
+int main (int argc, char ** argv)
{
int local_j = global_i + 1;
int local_k = local_j + 1;
+ char prog[PATH_MAX];
+ int len;
+
+ strcpy (prog, argv[0]);
+ len = strlen (prog);
+ /* Replace "foll-exec-mode" with "execd-prog". */
+ memcpy (prog + len - 14, "execd-prog", 10);
+ prog[len - 4] = 0;
printf ("foll-exec is about to execlp(execd-prog)...\n");
- execlp (BASEDIR "/execd-prog", /* Set breakpoint here. */
+ execlp (prog, /* Set breakpoint here. */
"/execd-prog",
"execlp arg1 from foll-exec",
(char *) 0);
diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp
index 41d788b..aa7b4143 100644
--- a/gdb/testsuite/gdb.base/foll-exec-mode.exp
+++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp
@@ -46,8 +46,6 @@ set srcfile2 ${testfile2}.c
set binfile2 [standard_output_file ${testfile2}]
set compile_options debug
-set dirname [relative_filename [pwd] [file dirname $binfile]]
-lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
# build the first test case
if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } {
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c
index 639698c..1ae171f 100644
--- a/gdb/testsuite/gdb.base/foll-exec.c
+++ b/gdb/testsuite/gdb.base/foll-exec.c
@@ -20,36 +20,48 @@
#include <unistd.h>
#include <string.h>
+#include <limits.h>
+
int global_i = 100;
-int main (void)
+int main (int argc, char ** argv)
{
int local_j = global_i + 1;
int local_k = local_j + 1;
+ char prog[PATH_MAX];
+ int len;
printf ("foll-exec is about to execlp(execd-prog)...\n");
- execlp (BASEDIR "/execd-prog",
- BASEDIR "/execd-prog",
+ strcpy (prog, argv[0]);
+ len = strlen (prog);
+ /* Replace "foll-exec" with "execd-prog". */
+ memcpy (prog + len - 9, "execd-prog", 10);
+ prog[len + 1] = 0;
+
+ execlp (prog, /* tbreak-execlp */
+ prog,
"execlp arg1 from foll-exec",
(char *) 0);
printf ("foll-exec is about to execl(execd-prog)...\n");
- execl (BASEDIR "/execd-prog", /* tbreak-execl */
- BASEDIR "/execd-prog",
+ execl (prog, /* tbreak-execl */
+ prog,
"execl arg1 from foll-exec",
"execl arg2 from foll-exec",
(char *) 0);
{
static char * argv[] = {
- (char *) BASEDIR "/execd-prog",
+ (char *) "",
(char *) "execv arg1 from foll-exec",
(char *) 0};
+ argv[0] = prog;
+
printf ("foll-exec is about to execv(execd-prog)...\n");
- execv (BASEDIR "/execd-prog", argv); /* tbreak-execv */
+ execv (prog, argv); /* tbreak-execv */
}
}
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 7d86d01..8859f9f 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -29,8 +29,6 @@ set srcfile2 ${testfile2}.c
set binfile2 [standard_output_file ${testfile2}]
set compile_options debug
-set dirname [relative_filename [pwd] [file dirname $binfile]]
-lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
# build the first test case
if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } {
@@ -80,19 +78,17 @@ proc do_exec_tests {} {
fail "Couldn't run ${testfile}"
return
}
+ # Execute the code setting up variable PROG.
+ set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile]
+ gdb_test "tbreak ${tbreak_line}"
+ gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*"
# Verify that we can see various global and local variables
# in this program, and that they have expected values. Some
# of these variables are also declared in the program we'll
# exec in a moment.
#
- send_gdb "next 3\n"
- gdb_expect {
- -re "execlp \\(.*$gdb_prompt $"\
- {pass "step to exec call"}
- -re "$gdb_prompt $" {fail "step to exec call"}
- timeout {fail "(timeout) step to exec call"}
- }
+
send_gdb "print global_i\n"
gdb_expect {
-re ".* = 100.*$gdb_prompt $"\
@@ -238,11 +234,15 @@ proc do_exec_tests {} {
fail "Couldn't run ${testfile} (3rd try)"
return
}
+ # Execute the code setting up variable PROG.
+ set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile]
+ gdb_test "tbreak ${tbreak_line}"
+ gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*"
# Verify that we can follow through follow an execl()
# call. (We must jump around earlier exec* calls.)
#
- set tbreak_line [gdb_get_line_number "tbreak-execl" $srcfile]
+ set tbreak_line [gdb_get_line_number " tbreak-execl " $srcfile]
send_gdb "tbreak ${tbreak_line}\n"
gdb_expect {
-re "Temporary breakpoint .*file .*${srcfile}, line ${tbreak_line}.*$gdb_prompt $"\
@@ -299,6 +299,10 @@ proc do_exec_tests {} {
fail "Couldn't run ${testfile} (4th try)"
return
}
+ # Execute the code setting up variable PROG.
+ set tbreak_line [gdb_get_line_number " tbreak-execlp " $srcfile]
+ gdb_test "tbreak ${tbreak_line}"
+ gdb_continue_to_breakpoint "line tbreak-execlp" ".*execlp \\(.*"
# Verify that we can follow through follow an execv()
# call. (We must jump around earlier exec* calls.)
diff --git a/gdb/testsuite/gdb.base/foll-vfork-exit.c b/gdb/testsuite/gdb.base/foll-vfork-exit.c
index 6f168e2..c431ded 100644
--- a/gdb/testsuite/gdb.base/foll-vfork-exit.c
+++ b/gdb/testsuite/gdb.base/foll-vfork-exit.c
@@ -23,7 +23,10 @@ main ()
{
int pid;
- pid = vfork ();
+ /* A statement before vfork to make sure a breakpoint on main isn't
+ set on vfork below. */
+ pid = 1;
+ pid = vfork (); /* VFORK */
if (pid == 0)
{
printf ("I'm the child!\n");
diff --git a/gdb/testsuite/gdb.base/foll-vfork.c b/gdb/testsuite/gdb.base/foll-vfork.c
index 24b2a53..5949d45 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.c
+++ b/gdb/testsuite/gdb.base/foll-vfork.c
@@ -18,14 +18,30 @@
#include <stdio.h>
#include <unistd.h>
-int main (void)
+#include <limits.h>
+#include <string.h>
+
+int
+main (int argc, char ** argv)
{
int pid;
- pid = vfork ();
+ /* A statement before vfork to make sure a breakpoint on main isn't
+ set on vfork below. */
+ pid = 1 + argc;
+ pid = vfork (); /* VFORK */
if (pid == 0) {
+ char prog[PATH_MAX];
+ int len;
+
+ strcpy (prog, argv[0]);
+ len = strlen (prog);
+ /* Replace "foll-vfork" with "vforked-prog". */
+ memcpy (prog + len - 10, "vforked-prog", 12);
+ prog[len + 2] = 0;
+
printf ("I'm the child!\n");
- execlp (BASEDIR "/vforked-prog", BASEDIR "/vforked-prog", (char *)0);
+ execlp (prog, prog, (char *) 0);
perror ("exec failed");
_exit (1);
}
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index bf9b893..481dcb7 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -28,8 +28,6 @@ if {![istarget "*-linux*"]} then {
standard_testfile
set compile_options debug
-set dirname [relative_filename [pwd] [file dirname $binfile]]
-lappend compile_options "additional_flags=-DBASEDIR=\"$dirname\""
if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
untested "failed to compile $testfile"
@@ -53,7 +51,7 @@ set timeout [expr "$timeout + 10"]
# error, behave as "return", so we don't try to continue testing with
# a borked session.
proc setup_gdb {} {
- global testfile
+ global testfile srcfile
clean_restart $testfile
@@ -64,6 +62,10 @@ proc setup_gdb {} {
if ![runto_main] {
return -code return
}
+
+ set tbreak_line [gdb_get_line_number " VFORK " $srcfile]
+ gdb_test "tbreak ${tbreak_line}"
+ gdb_continue_to_breakpoint ".*"
}
proc check_vfork_catchpoints {} {