diff options
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec.c | 44 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-exec.exp | 65 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/foll-vfork.exp | 29 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/pie-execl.exp | 24 |
4 files changed, 80 insertions, 82 deletions
diff --git a/gdb/testsuite/gdb.base/foll-exec.c b/gdb/testsuite/gdb.base/foll-exec.c index 6e302bb..77287a4 100644 --- a/gdb/testsuite/gdb.base/foll-exec.c +++ b/gdb/testsuite/gdb.base/foll-exec.c @@ -1,36 +1,52 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 1997-2015 Free Software Foundation, Inc. + + 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/>. */ + #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> - -int global_i = 100; +int global_i = 100; int main (void) { - int local_j = global_i+1; - int local_k = local_j+1; + int local_j = global_i + 1; + int local_k = local_j + 1; printf ("foll-exec is about to execlp(execd-prog)...\n"); execlp (BASEDIR "/execd-prog", - BASEDIR "/execd-prog", - "execlp arg1 from foll-exec", - (char *)0); + BASEDIR "/execd-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 arg1 from foll-exec", - "execl arg2 from foll-exec", - (char *)0); + BASEDIR "/execd-prog", + "execl arg1 from foll-exec", + "execl arg2 from foll-exec", + (char *) 0); { static char * argv[] = { - (char *)BASEDIR "/execd-prog", - (char *)"execv arg1 from foll-exec", - (char *)0}; + (char *) BASEDIR "/execd-prog", + (char *) "execv arg1 from foll-exec", + (char *) 0}; printf ("foll-exec is about to execv(execd-prog)...\n"); diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp index 5bea3ba..0a6347c 100644 --- a/gdb/testsuite/gdb.base/foll-exec.exp +++ b/gdb/testsuite/gdb.base/foll-exec.exp @@ -13,6 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +# This is a test of gdb's ability to follow a process through a +# Unix exec() system call. + if { [is_remote target] || ![isnative] } then { continue } @@ -44,44 +47,14 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $com return -1 } -proc zap_session {} { - global gdb_prompt - global binfile - - send_gdb "kill\n" - gdb_expect { - -re ".*Kill the program being debugged.*y or n. $" { - gdb_test_no_output "y" "" - send_gdb "file $binfile\n" - gdb_expect { - -re ".*Load new symbol table from.*y or n. $" { - send_gdb "y\n" - gdb_expect { - -re "Reading symbols from.*$gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*gdb_prompt $" {} - timeout { fail "loading symbols (timeout)"; return } - } - } - -re ".*$gdb_prompt $" {} - timeout { fail "killing inferior (timeout)" ; return } - } -} - proc do_exec_tests {} { + global binfile srcfile srcfile2 testfile testfile2 global gdb_prompt - global binfile - global srcfile - global srcfile2 - global testfile - global testfile2 # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile}" + fail "Couldn't run ${testfile}" return } @@ -103,12 +76,12 @@ proc do_exec_tests {} { return } - zap_session + clean_restart $binfile # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile}" + fail "Couldn't run ${testfile}" return } @@ -192,12 +165,12 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - zap_session + clean_restart $binfile # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile} (2nd try)" + fail "Couldn't run ${testfile} (2nd try)" return } @@ -265,12 +238,12 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - zap_session + clean_restart $binfile # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile} (3rd try)" + fail "Couldn't run ${testfile} (3rd try)" return } @@ -326,12 +299,12 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - zap_session + clean_restart $binfile # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile} (4th try)" + fail "Couldn't run ${testfile} (4th try)" return } @@ -381,12 +354,12 @@ proc do_exec_tests {} { # Explicitly kill this program, or a subsequent rerun actually runs # the exec'd program, not the original program... - zap_session + clean_restart $binfile # Start the program running, and stop at main. # if ![runto_main] then { - perror "Couldn't run ${testfile} (5th try)" + fail "Couldn't run ${testfile} (5th try)" return } @@ -406,14 +379,8 @@ proc do_exec_tests {} { # Start with a fresh gdb gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} - +clean_restart $binfile -# This is a test of gdb's ability to follow a process through a -# Unix exec() system call. -# do_exec_tests return 0 diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index b94b7ea..78c5cc8 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -524,23 +524,18 @@ with_test_prefix "check vfork support" { check_vfork_catchpoints } -# There is no support for exec events in the RSP yet. -if { ![gdb_is_target_remote] } { - # Follow parent and follow child vfork tests with a child that execs. - with_test_prefix "exec" { - # These are tests of gdb's ability to follow the parent of a Unix - # vfork system call. The child will subsequently call a variant - # of the Unix exec system call. - do_vfork_and_follow_parent_tests - - # These are tests of gdb's ability to follow the child of a Unix - # vfork system call. The child will subsequently call a variant - # of a Unix exec system call. - # - do_vfork_and_follow_child_tests_exec - } -} else { - unsupported "vfork with exec: exec events not supported for remote" +# Follow parent and follow child vfork tests with a child that execs. +with_test_prefix "exec" { + # These are tests of gdb's ability to follow the parent of a Unix + # vfork system call. The child will subsequently call a variant + # of the Unix exec system call. + do_vfork_and_follow_parent_tests + + # These are tests of gdb's ability to follow the child of a Unix + # vfork system call. The child will subsequently call a variant + # of a Unix exec system call. + # + do_vfork_and_follow_child_tests_exec } # Switch to test the case of the child exiting. We can't use diff --git a/gdb/testsuite/gdb.base/pie-execl.exp b/gdb/testsuite/gdb.base/pie-execl.exp index 182f96f..51edc82 100644 --- a/gdb/testsuite/gdb.base/pie-execl.exp +++ b/gdb/testsuite/gdb.base/pie-execl.exp @@ -16,6 +16,9 @@ # The problem was due to amd64_skip_prologue attempting to access inferior # memory before the PIE (Position Independent Executable) gets relocated. +global inferior_spawn_id +global gdb_spawn_id + if ![istarget *-linux*] { continue } @@ -67,6 +70,7 @@ gdb_test_multiple "p/x &pie_execl_marker" $test { verbose -log "addr1 is $addr1" set test "continue" +set matches_found 0 gdb_test_multiple $test $test { -re "Error in re-setting breakpoint" { fail $test @@ -74,8 +78,24 @@ gdb_test_multiple $test $test { -re "Cannot access memory" { fail $test } - -re "pie-execl: re-exec.*executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" { - pass $test + -i "$inferior_spawn_id" -re "pie-execl: re-exec" { + # output from inferior + incr matches_found + if { $matches_found == 2 } { + pass $test + } else { + exp_continue + } + } + -i "$gdb_spawn_id" + -re "executing new program.*\r\nBreakpoint \[0-9\]+,\[^\r\n\]* pie_execl_marker .*\r\n$gdb_prompt $" { + # output from gdb + incr matches_found + if { $matches_found == 2 } { + pass $test + } else { + exp_continue + } } } |