binutils-gdb/gdb/testsuite/gdb.base/foll-vfork.exp

502 lines
15 KiB
Plaintext
Raw Normal View History

# Copyright 1997-2018 Free Software Foundation, Inc.
1999-06-29 01:04:32 +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
1999-06-29 01:04:32 +02:00
# (at your option) any later version.
#
1999-06-29 01:04:32 +02:00
# 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.
#
1999-06-29 01:04:32 +02:00
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1999-06-29 01:04:32 +02:00
# Various tests of gdb's ability to follow the parent or child of a
# Unix vfork system call. A vfork parent is blocked until the child
# either execs or exits --- since those events take somewhat different
# code paths in GDB, both variants are exercised.
# Until "set follow-fork-mode" and "catch vfork" are implemented on
# other targets...
#
Remove HP-UX references fom testsuite This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-21 18:51:54 +01:00
if {![istarget "*-linux*"]} then {
continue
}
standard_testfile
1999-06-29 01:04:32 +02:00
set compile_options debug
if {[build_executable $testfile.exp $testfile $srcfile $compile_options] == -1} {
Fixup testcases outputting own name as a test name and standardize failed compilation messages Changes in v3: - Adjusted some testcases where the message "failed to compile" was not unique. Changes in v2: - Addressed comments from reviewers. - Fixed spurious whitespaces. - Changed compilation failure messages that included source/binary paths to ones that are short and deterministic. --- Another bit of cleanup to the testsuite. We have a number of tests that are not honoring the rule of not outputting their own name as a test name. I fixed up all the offenders i could find with the following regular expression: "(xfail|kfail|kpass|fail|pass|unsupported|untested) ([A-Za-z0-9]+|\\\$(.)*testfile(.)*)\.exp$" gdb/testsuite/ChangeLog: 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names and standardize compilation error messages throughout the following files: * gdb.ada/start.exp * gdb.arch/alpha-step.exp * gdb.arch/e500-prologue.exp * gdb.arch/ftrace-insn-reloc.exp * gdb.arch/gdb1291.exp * gdb.arch/gdb1431.exp * gdb.arch/gdb1558.exp * gdb.arch/i386-dr3-watch.exp * gdb.arch/i386-sse-stack-align.exp * gdb.arch/ia64-breakpoint-shadow.exp * gdb.arch/pa-nullify.exp * gdb.arch/powerpc-aix-prologue.exp * gdb.arch/thumb-bx-pc.exp * gdb.base/annota1.exp * gdb.base/annota3.exp * gdb.base/arrayidx.exp * gdb.base/assign.exp * gdb.base/attach.exp * gdb.base/auxv.exp * gdb.base/bang.exp * gdb.base/bfp-test.exp * gdb.base/bigcore.exp * gdb.base/bitfields2.exp * gdb.base/break-fun-addr.exp * gdb.base/break-probes.exp * gdb.base/call-rt-st.exp * gdb.base/callexit.exp * gdb.base/catch-fork-kill.exp * gdb.base/charset.exp * gdb.base/checkpoint.exp * gdb.base/comprdebug.exp * gdb.base/constvars.exp * gdb.base/coredump-filter.exp * gdb.base/cursal.exp * gdb.base/cvexpr.exp * gdb.base/detach.exp * gdb.base/display.exp * gdb.base/dmsym.exp * gdb.base/dprintf-pending.exp * gdb.base/dso2dso.exp * gdb.base/dtrace-probe.exp * gdb.base/dump.exp * gdb.base/enum_cond.exp * gdb.base/exe-lock.exp * gdb.base/exec-invalid-sysroot.exp * gdb.base/execl-update-breakpoints.exp * gdb.base/exprs.exp * gdb.base/fileio.exp * gdb.base/find.exp * gdb.base/finish.exp * gdb.base/fixsection.exp * gdb.base/foll-vfork.exp * gdb.base/frame-args.exp * gdb.base/gcore.exp * gdb.base/gdb1250.exp * gdb.base/global-var-nested-by-dso.exp * gdb.base/gnu-ifunc.exp * gdb.base/hashline1.exp * gdb.base/hashline2.exp * gdb.base/hashline3.exp * gdb.base/hbreak-in-shr-unsupported.exp * gdb.base/huge.exp * gdb.base/infcall-input.exp * gdb.base/info-fun.exp * gdb.base/info-shared.exp * gdb.base/jit-simple.exp * gdb.base/jit-so.exp * gdb.base/jit.exp * gdb.base/jump.exp * gdb.base/label.exp * gdb.base/lineinc.exp * gdb.base/logical.exp * gdb.base/longjmp.exp * gdb.base/macscp.exp * gdb.base/miscexprs.exp * gdb.base/new-ui-echo.exp * gdb.base/new-ui-pending-input.exp * gdb.base/new-ui.exp * gdb.base/nodebug.exp * gdb.base/nofield.exp * gdb.base/offsets.exp * gdb.base/overlays.exp * gdb.base/pending.exp * gdb.base/pointers.exp * gdb.base/pr11022.exp * gdb.base/printcmds.exp * gdb.base/prologue.exp * gdb.base/ptr-typedef.exp * gdb.base/realname-expand.exp * gdb.base/relativedebug.exp * gdb.base/relocate.exp * gdb.base/remote.exp * gdb.base/reread.exp * gdb.base/return2.exp * gdb.base/savedregs.exp * gdb.base/sep.exp * gdb.base/sepdebug.exp * gdb.base/sepsymtab.exp * gdb.base/set-inferior-tty.exp * gdb.base/setshow.exp * gdb.base/shlib-call.exp * gdb.base/sigaltstack.exp * gdb.base/siginfo-addr.exp * gdb.base/signals.exp * gdb.base/signull.exp * gdb.base/sigrepeat.exp * gdb.base/so-impl-ld.exp * gdb.base/solib-display.exp * gdb.base/solib-overlap.exp * gdb.base/solib-search.exp * gdb.base/solib-symbol.exp * gdb.base/structs.exp * gdb.base/structs2.exp * gdb.base/symtab-search-order.exp * gdb.base/twice.exp * gdb.base/unload.exp * gdb.base/varargs.exp * gdb.base/watchpoint-solib.exp * gdb.base/watchpoint.exp * gdb.base/whatis.exp * gdb.base/wrong_frame_bt_full.exp * gdb.btrace/dlopen.exp * gdb.cell/ea-standalone.exp * gdb.cell/ea-test.exp * gdb.cp/dispcxx.exp * gdb.cp/gdb2384.exp * gdb.cp/method2.exp * gdb.cp/nextoverthrow.exp * gdb.cp/pr10728.exp * gdb.disasm/am33.exp * gdb.disasm/h8300s.exp * gdb.disasm/mn10300.exp * gdb.disasm/sh3.exp * gdb.dwarf2/dw2-dir-file-name.exp * gdb.fortran/complex.exp * gdb.fortran/library-module.exp * gdb.guile/scm-pretty-print.exp * gdb.guile/scm-symbol.exp * gdb.guile/scm-type.exp * gdb.guile/scm-value.exp * gdb.linespec/linespec.exp * gdb.mi/gdb701.exp * gdb.mi/gdb792.exp * gdb.mi/mi-breakpoint-changed.exp * gdb.mi/mi-dprintf-pending.exp * gdb.mi/mi-dprintf.exp * gdb.mi/mi-exit-code.exp * gdb.mi/mi-pending.exp * gdb.mi/mi-solib.exp * gdb.mi/new-ui-mi-sync.exp * gdb.mi/pr11022.exp * gdb.mi/user-selected-context-sync.exp * gdb.opt/solib-intra-step.exp * gdb.python/py-events.exp * gdb.python/py-finish-breakpoint.exp * gdb.python/py-mi.exp * gdb.python/py-prettyprint.exp * gdb.python/py-shared.exp * gdb.python/py-symbol.exp * gdb.python/py-template.exp * gdb.python/py-type.exp * gdb.python/py-value.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/solib-reverse.exp * gdb.server/solib-list.exp * gdb.stabs/weird.exp * gdb.threads/reconnect-signal.exp * gdb.threads/stepi-random-signal.exp * gdb.trace/actions.exp * gdb.trace/ax.exp * gdb.trace/backtrace.exp * gdb.trace/change-loc.exp * gdb.trace/deltrace.exp * gdb.trace/ftrace-lock.exp * gdb.trace/ftrace.exp * gdb.trace/infotrace.exp * gdb.trace/mi-tracepoint-changed.exp * gdb.trace/packetlen.exp * gdb.trace/passcount.exp * gdb.trace/pending.exp * gdb.trace/range-stepping.exp * gdb.trace/report.exp * gdb.trace/stap-trace.exp * gdb.trace/tfind.exp * gdb.trace/trace-break.exp * gdb.trace/trace-condition.exp * gdb.trace/trace-enable-disable.exp * gdb.trace/trace-mt.exp * gdb.trace/tracecmd.exp * gdb.trace/tspeed.exp * gdb.trace/tsv.exp * lib/perftest.exp
2016-12-01 21:47:50 +01:00
untested "failed to compile main testcase"
return -1
1999-06-29 01:04:32 +02:00
}
set testfile2 "vforked-prog"
set srcfile2 ${testfile2}.c
if {[build_executable $testfile.exp $testfile2 $srcfile2 $compile_options] == -1} {
Fixup testcases outputting own name as a test name and standardize failed compilation messages Changes in v3: - Adjusted some testcases where the message "failed to compile" was not unique. Changes in v2: - Addressed comments from reviewers. - Fixed spurious whitespaces. - Changed compilation failure messages that included source/binary paths to ones that are short and deterministic. --- Another bit of cleanup to the testsuite. We have a number of tests that are not honoring the rule of not outputting their own name as a test name. I fixed up all the offenders i could find with the following regular expression: "(xfail|kfail|kpass|fail|pass|unsupported|untested) ([A-Za-z0-9]+|\\\$(.)*testfile(.)*)\.exp$" gdb/testsuite/ChangeLog: 2016-12-01 Luis Machado <lgustavo@codesourcery.com> Fix test names and standardize compilation error messages throughout the following files: * gdb.ada/start.exp * gdb.arch/alpha-step.exp * gdb.arch/e500-prologue.exp * gdb.arch/ftrace-insn-reloc.exp * gdb.arch/gdb1291.exp * gdb.arch/gdb1431.exp * gdb.arch/gdb1558.exp * gdb.arch/i386-dr3-watch.exp * gdb.arch/i386-sse-stack-align.exp * gdb.arch/ia64-breakpoint-shadow.exp * gdb.arch/pa-nullify.exp * gdb.arch/powerpc-aix-prologue.exp * gdb.arch/thumb-bx-pc.exp * gdb.base/annota1.exp * gdb.base/annota3.exp * gdb.base/arrayidx.exp * gdb.base/assign.exp * gdb.base/attach.exp * gdb.base/auxv.exp * gdb.base/bang.exp * gdb.base/bfp-test.exp * gdb.base/bigcore.exp * gdb.base/bitfields2.exp * gdb.base/break-fun-addr.exp * gdb.base/break-probes.exp * gdb.base/call-rt-st.exp * gdb.base/callexit.exp * gdb.base/catch-fork-kill.exp * gdb.base/charset.exp * gdb.base/checkpoint.exp * gdb.base/comprdebug.exp * gdb.base/constvars.exp * gdb.base/coredump-filter.exp * gdb.base/cursal.exp * gdb.base/cvexpr.exp * gdb.base/detach.exp * gdb.base/display.exp * gdb.base/dmsym.exp * gdb.base/dprintf-pending.exp * gdb.base/dso2dso.exp * gdb.base/dtrace-probe.exp * gdb.base/dump.exp * gdb.base/enum_cond.exp * gdb.base/exe-lock.exp * gdb.base/exec-invalid-sysroot.exp * gdb.base/execl-update-breakpoints.exp * gdb.base/exprs.exp * gdb.base/fileio.exp * gdb.base/find.exp * gdb.base/finish.exp * gdb.base/fixsection.exp * gdb.base/foll-vfork.exp * gdb.base/frame-args.exp * gdb.base/gcore.exp * gdb.base/gdb1250.exp * gdb.base/global-var-nested-by-dso.exp * gdb.base/gnu-ifunc.exp * gdb.base/hashline1.exp * gdb.base/hashline2.exp * gdb.base/hashline3.exp * gdb.base/hbreak-in-shr-unsupported.exp * gdb.base/huge.exp * gdb.base/infcall-input.exp * gdb.base/info-fun.exp * gdb.base/info-shared.exp * gdb.base/jit-simple.exp * gdb.base/jit-so.exp * gdb.base/jit.exp * gdb.base/jump.exp * gdb.base/label.exp * gdb.base/lineinc.exp * gdb.base/logical.exp * gdb.base/longjmp.exp * gdb.base/macscp.exp * gdb.base/miscexprs.exp * gdb.base/new-ui-echo.exp * gdb.base/new-ui-pending-input.exp * gdb.base/new-ui.exp * gdb.base/nodebug.exp * gdb.base/nofield.exp * gdb.base/offsets.exp * gdb.base/overlays.exp * gdb.base/pending.exp * gdb.base/pointers.exp * gdb.base/pr11022.exp * gdb.base/printcmds.exp * gdb.base/prologue.exp * gdb.base/ptr-typedef.exp * gdb.base/realname-expand.exp * gdb.base/relativedebug.exp * gdb.base/relocate.exp * gdb.base/remote.exp * gdb.base/reread.exp * gdb.base/return2.exp * gdb.base/savedregs.exp * gdb.base/sep.exp * gdb.base/sepdebug.exp * gdb.base/sepsymtab.exp * gdb.base/set-inferior-tty.exp * gdb.base/setshow.exp * gdb.base/shlib-call.exp * gdb.base/sigaltstack.exp * gdb.base/siginfo-addr.exp * gdb.base/signals.exp * gdb.base/signull.exp * gdb.base/sigrepeat.exp * gdb.base/so-impl-ld.exp * gdb.base/solib-display.exp * gdb.base/solib-overlap.exp * gdb.base/solib-search.exp * gdb.base/solib-symbol.exp * gdb.base/structs.exp * gdb.base/structs2.exp * gdb.base/symtab-search-order.exp * gdb.base/twice.exp * gdb.base/unload.exp * gdb.base/varargs.exp * gdb.base/watchpoint-solib.exp * gdb.base/watchpoint.exp * gdb.base/whatis.exp * gdb.base/wrong_frame_bt_full.exp * gdb.btrace/dlopen.exp * gdb.cell/ea-standalone.exp * gdb.cell/ea-test.exp * gdb.cp/dispcxx.exp * gdb.cp/gdb2384.exp * gdb.cp/method2.exp * gdb.cp/nextoverthrow.exp * gdb.cp/pr10728.exp * gdb.disasm/am33.exp * gdb.disasm/h8300s.exp * gdb.disasm/mn10300.exp * gdb.disasm/sh3.exp * gdb.dwarf2/dw2-dir-file-name.exp * gdb.fortran/complex.exp * gdb.fortran/library-module.exp * gdb.guile/scm-pretty-print.exp * gdb.guile/scm-symbol.exp * gdb.guile/scm-type.exp * gdb.guile/scm-value.exp * gdb.linespec/linespec.exp * gdb.mi/gdb701.exp * gdb.mi/gdb792.exp * gdb.mi/mi-breakpoint-changed.exp * gdb.mi/mi-dprintf-pending.exp * gdb.mi/mi-dprintf.exp * gdb.mi/mi-exit-code.exp * gdb.mi/mi-pending.exp * gdb.mi/mi-solib.exp * gdb.mi/new-ui-mi-sync.exp * gdb.mi/pr11022.exp * gdb.mi/user-selected-context-sync.exp * gdb.opt/solib-intra-step.exp * gdb.python/py-events.exp * gdb.python/py-finish-breakpoint.exp * gdb.python/py-mi.exp * gdb.python/py-prettyprint.exp * gdb.python/py-shared.exp * gdb.python/py-symbol.exp * gdb.python/py-template.exp * gdb.python/py-type.exp * gdb.python/py-value.exp * gdb.reverse/solib-precsave.exp * gdb.reverse/solib-reverse.exp * gdb.server/solib-list.exp * gdb.stabs/weird.exp * gdb.threads/reconnect-signal.exp * gdb.threads/stepi-random-signal.exp * gdb.trace/actions.exp * gdb.trace/ax.exp * gdb.trace/backtrace.exp * gdb.trace/change-loc.exp * gdb.trace/deltrace.exp * gdb.trace/ftrace-lock.exp * gdb.trace/ftrace.exp * gdb.trace/infotrace.exp * gdb.trace/mi-tracepoint-changed.exp * gdb.trace/packetlen.exp * gdb.trace/passcount.exp * gdb.trace/pending.exp * gdb.trace/range-stepping.exp * gdb.trace/report.exp * gdb.trace/stap-trace.exp * gdb.trace/tfind.exp * gdb.trace/trace-break.exp * gdb.trace/trace-condition.exp * gdb.trace/trace-enable-disable.exp * gdb.trace/trace-mt.exp * gdb.trace/tracecmd.exp * gdb.trace/tspeed.exp * gdb.trace/tsv.exp * lib/perftest.exp
2016-12-01 21:47:50 +01:00
untested "failed to compile secondary testcase"
return -1
1999-06-29 01:04:32 +02:00
}
# A few of these tests require a little more time than the standard
# timeout allows.
set oldtimeout $timeout
set timeout [expr "$timeout + 10"]
# Start with a fresh GDB, with verbosity enabled, and run to main. On
# error, behave as "return", so we don't try to continue testing with
# a borked session.
proc setup_gdb {} {
[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 16:46:37 +01:00
global testfile srcfile
clean_restart $testfile
if ![runto_main] {
return -code return
}
[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 16:46:37 +01:00
set tbreak_line [gdb_get_line_number " VFORK " $srcfile]
gdb_test "tbreak ${tbreak_line}"
gdb_continue_to_breakpoint ".*"
}
proc check_vfork_catchpoints {} {
global gdb_prompt
global has_vfork_catchpoints
setup_gdb
# Verify that the system supports "catch vfork".
gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint"
set has_vfork_catchpoints 0
gdb_test_multiple "continue" "continue to first vfork catchpoint" {
2010-01-11 Thiago Jung Bauermann <bauerman@br.ibm.com> Convert hardware watchpoints to use breakpoint_ops. gdb/ * breakpoint.h (breakpoint_ops) <insert>: Rename to... <insert_location>: ... this. Return int instead of void. Accept pointer to struct bp_location instead of pointer to struct breakpoint. Adapt all implementations. (breakpoint_ops) <remove>: Rename to... <remove_location>: ... this. Accept pointer to struct bp_location instead of pointer to struct breakpoint. Adapt all implementations. * breakpoint.c (insert_catchpoint): Delete function. (insert_bp_location): Call the watchpoint or catchpoint's breakpoint_ops.insert method. (remove_breakpoint_1): Call the watchpoint or catchpoint's breakpoint_ops.remove method. (insert_watchpoint, remove_watchpoint): New functions. (watchpoint_breakpoint_ops): New structure. (watch_command_1): Initialize the OPS field. * inf-child.c (inf_child_insert_fork_catchpoint) (inf_child_remove_fork_catchpoint, inf_child_insert_vfork_catchpoint) (inf_child_remove_vfork_catchpoint, inf_child_insert_exec_catchpoint) (inf_child_remove_exec_catchpoint, inf_child_set_syscall_catchpoint): Delete functions. (inf_child_target): Remove initialization of to_insert_fork_catchpoint, to_remove_fork_catchpoint, to_insert_vfork_catchpoint, to_remove_vfork_catchpoint, to_insert_exec_catchpoint, to_remove_exec_catchpoint and to_set_syscall_catchpoint. * target.c (update_current_target): Change default implementation of to_insert_fork_catchpoint, to_remove_fork_catchpoint, to_insert_vfork_catchpoint, to_remove_vfork_catchpoint, to_insert_exec_catchpoint, to_remove_exec_catchpoint and to_set_syscall_catchpoint to return_one. (debug_to_insert_fork_catchpoint, debug_to_insert_vfork_catchpoint) (debug_to_insert_exec_catchpoint): Report return value. * target.h (to_insert_fork_catchpoint, to_insert_vfork_catchpoint) (to_insert_exec_catchpoint): Change declaration to return int instead of void. gdb/testsuite/ * gdb.base/foll-exec.exp: Adapt to new error string when the catchpoint type is not supported. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise.
2011-01-11 20:16:23 +01:00
-re ".*Your system does not support this type\r\nof catchpoint.*$gdb_prompt $" {
unsupported "continue to first vfork catchpoint"
}
-re ".*Catchpoint.*$gdb_prompt $" {
set has_vfork_catchpoints 1
pass "continue to first vfork catchpoint"
}
}
if {$has_vfork_catchpoints == 0} {
unsupported "vfork catchpoints"
return -code return
}
}
1999-06-29 01:04:32 +02:00
proc vfork_parent_follow_through_step {} {
with_test_prefix "vfork parent follow, through step" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
setup_gdb
gdb_test_no_output "set follow-fork parent"
set test "step"
gdb_test_multiple "next" $test {
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re "\\\[Detaching after vfork from.*if \\(pid == 0\\).*$gdb_prompt " {
pass $test
}
1999-06-29 01:04:32 +02:00
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc vfork_parent_follow_to_bp {} {
with_test_prefix "vfork parent follow, to bp" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile
1999-06-29 01:04:32 +02:00
setup_gdb
gdb_test_no_output "set follow-fork parent"
set bp_location [gdb_get_line_number "printf (\"I'm the proud parent of child"]
gdb_test "break ${srcfile}:${bp_location}" ".*" "break, vfork to bp"
set test "continue to bp"
gdb_test_multiple "continue" $test {
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re ".*\\\[Detaching after vfork from child process.*Breakpoint.*${bp_location}.*$gdb_prompt " {
pass $test
}
1999-06-29 01:04:32 +02:00
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc vfork_child_follow_to_exit {} {
with_test_prefix "vfork child follow, to exit" {
global gdb_prompt
setup_gdb
gdb_test_no_output "set follow-fork child"
set test "continue to child exit"
gdb_test_multiple "continue" $test {
-re "Couldn't get registers.*$gdb_prompt " {
# PR gdb/14766
fail "$test"
}
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent .* after child exit.*$gdb_prompt " {
pass $test
}
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc vfork_and_exec_child_follow_to_main_bp {} {
with_test_prefix "vfork and exec child follow, to main bp" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile2
1999-06-29 01:04:32 +02:00
setup_gdb
gdb_test_no_output "set follow-fork child"
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
set test "continue to bp"
gdb_test_multiple "continue" $test {
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re "\\\[Attaching after.* vfork to.*\\\[Detaching vfork parent.*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
pass $test
}
1999-06-29 01:04:32 +02:00
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any gdb_expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc vfork_and_exec_child_follow_through_step {} {
with_test_prefix "vfork and exec child follow, through step" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile2
1999-06-29 01:04:32 +02:00
setup_gdb
gdb_test_no_output "set follow-fork child"
set test "step over vfork"
Remove HP-UX references fom testsuite This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-21 18:51:54 +01:00
# The ideal support is to be able to debug the child even
# before it execs. Thus, "next" lands on the next line after
# the vfork.
gdb_test_multiple "next" $test {
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
Remove HP-UX references fom testsuite This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-21 18:51:54 +01:00
pass "$test"
}
1999-06-29 01:04:32 +02:00
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
testsuite: Regression for foll-vfork.exp fe33faff35a8ee19db823149e764e3373e603bb9 is the first bad commit commit fe33faff35a8ee19db823149e764e3373e603bb9 Author: Simon Marchi <simon.marchi@ericsson.com> Date: Tue Dec 22 10:52:31 2015 -0500 Remove HP-UX reference in foll-vfork.exp FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork child follow, finish after tcatch vfork: continue to vfork It happens for plain gdb.base/foll-vfork.exp runtest on Fedora 23 x86_64. -Temporary catchpoint 2 (vforked process 24562), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25345), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork -Temporary catchpoint 2 (vforked process 24629), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25411), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork So I have reverted it and just simplified the comment. The third case is not necessary during testing but I have changed back all the 3 cases. Pedro Alves: I know it was that way before, but would you mind moving this to a helper proc. gdb/testsuite/ChangeLog 2016-01-11 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/foll-vfork.exp (tcatch_vfork_then_parent_follow) (tcatch_vfork_then_child_follow_exec) (tcatch_vfork_then_child_follow_exit): Revert back DWARF vfork identification.
2016-01-11 22:20:16 +01:00
proc continue_to_vfork {} {
global gdb_prompt
# A vfork catchpoint may stop in either "vfork" or "_vfork".
set test "continue to vfork"
gdb_test_multiple "continue" $test {
-re "vfork \\(\\) at .*$gdb_prompt $" {
pass $test
}
-re "0x\[0-9a-fA-F\]*.*(vfork|__kernel_v?syscall).*$gdb_prompt " {
pass $test
}
}
}
1999-06-29 01:04:32 +02:00
proc tcatch_vfork_then_parent_follow {} {
with_test_prefix "vfork parent follow, finish after tcatch vfork" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile
setup_gdb
gdb_test_no_output "set follow-fork parent"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
testsuite: Regression for foll-vfork.exp fe33faff35a8ee19db823149e764e3373e603bb9 is the first bad commit commit fe33faff35a8ee19db823149e764e3373e603bb9 Author: Simon Marchi <simon.marchi@ericsson.com> Date: Tue Dec 22 10:52:31 2015 -0500 Remove HP-UX reference in foll-vfork.exp FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork child follow, finish after tcatch vfork: continue to vfork It happens for plain gdb.base/foll-vfork.exp runtest on Fedora 23 x86_64. -Temporary catchpoint 2 (vforked process 24562), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25345), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork -Temporary catchpoint 2 (vforked process 24629), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25411), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork So I have reverted it and just simplified the comment. The third case is not necessary during testing but I have changed back all the 3 cases. Pedro Alves: I know it was that way before, but would you mind moving this to a helper proc. gdb/testsuite/ChangeLog 2016-01-11 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/foll-vfork.exp (tcatch_vfork_then_parent_follow) (tcatch_vfork_then_child_follow_exec) (tcatch_vfork_then_child_follow_exit): Revert back DWARF vfork identification.
2016-01-11 22:20:16 +01:00
continue_to_vfork
set linenum [gdb_get_line_number "pid = vfork ();"]
set test "finish"
gdb_test_multiple "finish" $test {
-re "Run till exit from.*vfork.*0x\[0-9a-fA-F\]* in main .* at .*${srcfile}:${linenum}.*$gdb_prompt " {
pass $test
}
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
send_gdb "finish\n"
exp_continue
}
1999-06-29 01:04:32 +02:00
}
# The child has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc tcatch_vfork_then_child_follow_exec {} {
with_test_prefix "vfork child follow, finish after tcatch vfork" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile
1999-06-29 01:04:32 +02:00
global srcfile2
setup_gdb
gdb_test_no_output "set follow-fork child"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
testsuite: Regression for foll-vfork.exp fe33faff35a8ee19db823149e764e3373e603bb9 is the first bad commit commit fe33faff35a8ee19db823149e764e3373e603bb9 Author: Simon Marchi <simon.marchi@ericsson.com> Date: Tue Dec 22 10:52:31 2015 -0500 Remove HP-UX reference in foll-vfork.exp FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork child follow, finish after tcatch vfork: continue to vfork It happens for plain gdb.base/foll-vfork.exp runtest on Fedora 23 x86_64. -Temporary catchpoint 2 (vforked process 24562), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25345), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork -Temporary catchpoint 2 (vforked process 24629), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25411), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork So I have reverted it and just simplified the comment. The third case is not necessary during testing but I have changed back all the 3 cases. Pedro Alves: I know it was that way before, but would you mind moving this to a helper proc. gdb/testsuite/ChangeLog 2016-01-11 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/foll-vfork.exp (tcatch_vfork_then_parent_follow) (tcatch_vfork_then_child_follow_exec) (tcatch_vfork_then_child_follow_exit): Revert back DWARF vfork identification.
2016-01-11 22:20:16 +01:00
continue_to_vfork
set linenum1 [gdb_get_line_number "pid = vfork ();"]
set linenum2 [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
set test "finish"
gdb_test_multiple "finish" $test {
-re "Run till exit from.*vfork.*${srcfile}:${linenum1}.*$gdb_prompt " {
pass $test
}
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
send_gdb "finish\n"
exp_continue
}
-re "Run till exit from.*vfork.*${srcfile2}:${linenum2}.*$gdb_prompt " {
pass "$test (followed exec)"
}
1999-06-29 01:04:32 +02:00
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc tcatch_vfork_then_child_follow_exit {} {
with_test_prefix "vfork child follow, finish after tcatch vfork" {
1999-06-29 01:04:32 +02:00
global gdb_prompt
global srcfile
setup_gdb
gdb_test_no_output "set follow-fork child"
gdb_test "tcatch vfork" "Catchpoint .*(vfork).*"
testsuite: Regression for foll-vfork.exp fe33faff35a8ee19db823149e764e3373e603bb9 is the first bad commit commit fe33faff35a8ee19db823149e764e3373e603bb9 Author: Simon Marchi <simon.marchi@ericsson.com> Date: Tue Dec 22 10:52:31 2015 -0500 Remove HP-UX reference in foll-vfork.exp FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork parent follow, finish after tcatch vfork: continue to vfork FAIL: gdb.base/foll-vfork.exp: exit: vfork child follow, finish after tcatch vfork: continue to vfork It happens for plain gdb.base/foll-vfork.exp runtest on Fedora 23 x86_64. -Temporary catchpoint 2 (vforked process 24562), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25345), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork -Temporary catchpoint 2 (vforked process 24629), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M +Temporary catchpoint 2 (vforked process 25411), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M 52 pushq %rdi^M Current language: auto^M The current source language is "auto; currently asm".^M -(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork +(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork So I have reverted it and just simplified the comment. The third case is not necessary during testing but I have changed back all the 3 cases. Pedro Alves: I know it was that way before, but would you mind moving this to a helper proc. gdb/testsuite/ChangeLog 2016-01-11 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/foll-vfork.exp (tcatch_vfork_then_parent_follow) (tcatch_vfork_then_child_follow_exec) (tcatch_vfork_then_child_follow_exit): Revert back DWARF vfork identification.
2016-01-11 22:20:16 +01:00
continue_to_vfork
set test "finish"
gdb_test_multiple "finish" $test {
-re "Run till exit from.*vfork.*exited normally.*$gdb_prompt " {
setup_kfail "gdb/14762" *-*-*
fail $test
}
-re "Run till exit from.*vfork.*pid = vfork \\(\\).*$gdb_prompt " {
pass $test
}
-re "Run till exit from.*__kernel_v?syscall.*0x\[0-9a-fA-F\]* in vfork .*$gdb_prompt " {
send_gdb "finish\n"
exp_continue
}
}
# The parent has been detached; allow time for any output it might
# generate to arrive, so that output doesn't get confused with
# any expected debugger output from a subsequent testpoint.
#
exec sleep 1
}}
1999-06-29 01:04:32 +02:00
proc vfork_relations_in_info_inferiors { variant } {
with_test_prefix "vfork relations in info inferiors" {
global gdb_prompt
setup_gdb
gdb_test_no_output "set follow-fork child"
set test "step over vfork"
gdb_test_multiple "next" $test {
Enable 'set print inferior-events' and improve detach/fork/kill/exit messages This patch aims to turn 'set print inferior-events' always on, and do some cleanup on the messages printed by GDB when various inferior events happen (attach, detach, fork, kill, exit). To make sure that the patch is correct, I've tested it with a handful of combinations of 'set follow-fork-mode', 'set detach-on-fork' and 'set print inferior-events'. In the end, I decided to make my hand-made test into an official testcase. More on that below. Using the following program as an example: #include <unistd.h> int main () { fork (); return 0; } We see the following outputs from the patched GDB: - With 'set print inferior-events on': (gdb) r Starting program: a.out [Detaching after fork from child process 27749] [Inferior 1 (process 27745) exited normally] (gdb) - With 'set print inferior-events off': (gdb) r Starting program: a.out [Inferior 1 (process 27823) exited normally] (gdb) Comparing this against an unpatched GDB: - With 'set print inferior-events off' and 'set follow-fork-mode child': (gdb) r Starting program: a.out [Inferior 2 (process 5993) exited normally] (gdb) Compare this against an unpatched GDB: (unpatched-gdb) r Starting program: a.out [New process 5702] [Inferior 2 (process 5702) exited normally] (unpatched-gdb) It is possible to notice that, in this scenario, the patched GDB will lose the '[New process %d]' message. - With 'set print inferior-events on', 'set follow-fork-mode child' and 'set detach-on-fork on': (gdb) r Starting program: a.out [Attaching after process 27905 fork to child process 27909] [New inferior 2 (process 27909)] [Detaching after fork from parent process 27905] [Inferior 1 (process 27905) detached] [Inferior 2 (process 27909) exited normally] (gdb) Compare this output with an unpatched GDB, using the same settings: (unpatched-gdb) r Starting program: a.out [New inferior 28033] [Inferior 28029 detached] [New process 28033] [Inferior 2 (process 28033) exited normally] [Inferior 28033 exited] (unpatched-gdb) As can be seen above, I've also made a few modifications to messages that are printed when 'set print inferior-events' is on. For example, a few of the messages did not contain the '[' and ']' as prefix/suffix, which led to a few inconsistencies like: Attaching after process 22995 fork to child process 22999. [New inferior 22999] Detaching after fork from child process 22999. [Inferior 22995 detached] [Inferior 2 (process 22999) exited normally] So I took the opportunity and included the square brackets where applicable. I have also made the existing messages more uniform, by always printing "Inferior %d (process %d)..." where applicable. This makes it easier to identify the inferior number and the PID number from the messages. As suggested by Pedro, the "[Inferior %d exited]" message from 'exit_inferior' has been removed, because it got duplicated when 'inferior-events' is on. I'm also using the 'add_{thread,inferior}_silent' versions (instead of their verbose counterparts) on some locations, also to avoid duplicated messages. For example, a patched GDB with 'set print inferior-events on', 'set detach-on-fork on' and 'set follow-fork-mode child', but using 'add_thread', would print: (gdb) run Starting program: a.out [Attaching after process 25088 fork to child process 25092.] [New inferior 25092] <--- duplicated [Detaching after fork from child process 25092.] [Inferior 25088 detached] [New process 25092] <--- duplicated [Inferior 2 (process 25092) exited normally] But if we use 'add_thread_silent' (with the same configuration as before): (gdb) run Starting program: a.out [Attaching after process 31606 fork to child process 31610] [New inferior 2 (process 31610)] [Detaching after fork from parent process 31606] [Inferior 1 (process 31606) detached] [Inferior 2 (process 31610) exited normally] As for the tests, the configuration options being exercised are: - follow-fork-mode: child/parent - detach-on-fork: on/off - print inferior-events: on/off It was also necessary to perform adjustments on several testcases, because the expected messages changed considerably. Built and regtested on BuildBot, without regressions. gdb/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * infcmd.c (kill_command): Print message when inferior has been killed. * inferior.c (print_inferior_events): Remove 'static'. Set as '1'. (add_inferior): Improve message printed when 'print_inferior_events' is on. (exit_inferior): Remove message printed when 'print_inferior_events' is on. (detach_inferior): Improve message printed when 'print_inferior_events' is on. (initialize_inferiors): Use 'add_inferior_silent' to set 'current_inferior_'. * inferior.h (print_inferior_events): Declare here as 'extern'. * infrun.c (follow_fork_inferior): Print '[Attaching...]' or '[Detaching...]' messages when 'print_inferior_events' is on. Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']' as prefix/suffix for messages. Remove periods. Fix erroneous 'Detaching after fork from child...', replace it by '... from parent...'. (handle_vfork_child_exec_or_exit): Add '[' and ']' as prefix/suffix when printing 'Detaching...' messages. Print them when 'print_inferior_events' is on. * remote.c (remote_detach_1): Print message when detaching from inferior and '!is_fork_parent'. gdb/testsuite/ChangeLog: 2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.base/attach.exp: Likewise. * gdb.base/catch-syscall.exp (check_for_program_end): Adjust "gdb_continue_to_end". (test_catch_syscall_with_wrong_args): Likewise. * gdb.base/foll-fork.exp: Adjust regexps to match '[' and ']'. Don't set 'verbose' on. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/fork-print-inferior-events.c: New file. * gdb.base/fork-print-inferior-events.exp: New file. * gdb.base/hook-stop.exp: Adjust regexps to expect for new '[Inferior ... has been killed]' message. * gdb.base/kill-after-signal.exp: Likewise. * gdb.base/solib-overlap.exp: Adjust regexps to expect for new detach message. * gdb.threads/kill.exp: Adjust regexps to expect for new kill message. * gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...' regexps to expect for '[Inferior ... detached]' as well. * gdb.threads/process-dies-while-detaching.exp: Likewise.
2018-01-31 01:09:42 +01:00
-re "\\\[Attaching after .* vfork to child.*if \\(pid == 0\\).*$gdb_prompt " {
pass "$test"
}
}
gdb_test "info inferiors" \
Reapply: List inferiors/threads/pspaces in ascending order [This reapplies a change that was accidentally reverted with c0ecb95f3d.] Before: (gdb) info threads Id Target Id Frame 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 After: (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 gdb/doc/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.texinfo (Inferiors and Programs): Adjust "maint info program-spaces" example to ascending order listing. (Threads): Adjust "info threads" example to ascending order listing. (Forks): Adjust "info inferiors" example to ascending order listing. gdb/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * inferior.c (add_inferior_silent): Append the new inferior to the end of the list. * progspace.c (add_program_space): Append the new pspace to the end of the list. * thread.c (new_thread): Append the new thread to the end of the list. gdb/testsuite/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and threads in ascending order. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.multi/base.exp: Likewise. * gdb.multi/multi-arch.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.threads/break-while-running.exp: Likewise. * gdb.threads/execl.exp: Likewise. * gdb.threads/gcore-thread.exp: Likewise. * gdb.threads/info-threads-cur-sal.exp: Likewise. * gdb.threads/kill.exp: Likewise. * gdb.threads/linux-dp.exp: Likewise. * gdb.threads/multiple-step-overs.exp: Likewise. * gdb.threads/next-bp-other-thread.exp: Likewise. * gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise. * gdb.threads/step-over-lands-on-breakpoint.exp: Likewise. * gdb.threads/step-over-trips-on-watchpoint.exp: Likewise. * gdb.threads/thread-find.exp: Likewise. * gdb.threads/tls.exp: Likewise. * lib/mi-support.exp (mi_reverse_list): Delete. (mi_check_thread_states): No longer reverse list.
2016-01-12 02:12:38 +01:00
".*is vfork parent of inferior 2.*is vfork child of inferior 1" \
"info inferiors shows vfork parent/child relation"
if { $variant == "exec" } {
global srcfile2
set linenum [gdb_get_line_number "printf(\"Hello from vforked-prog" ${srcfile2}]
set test "continue to bp"
gdb_test_multiple "continue" $test {
-re ".*xecuting new program.*Breakpoint.*vforked-prog.c:${linenum}.*$gdb_prompt " {
pass $test
}
}
} else {
set test "continue to child exit"
gdb_test_multiple "continue" $test {
-re "exited normally.*$gdb_prompt " {
pass $test
}
}
}
set test "vfork relation no longer appears in info inferiors"
gdb_test_multiple "info inferiors" $test {
-re "is vfork child of inferior 1.*$gdb_prompt $" {
fail $test
}
-re "is vfork parent of inferior 2.*$gdb_prompt $" {
fail $test
}
-re "$gdb_prompt $" {
pass $test
}
}
}}
proc do_vfork_and_follow_parent_tests {} {
global gdb_prompt
1999-06-29 01:04:32 +02:00
# Try following the parent process by stepping through a call to
# vfork. Do this without catchpoints.
vfork_parent_follow_through_step
1999-06-29 01:04:32 +02:00
# Try following the parent process by setting a breakpoint on the
# other side of a vfork, and running to that point. Do this
# without catchpoints.
vfork_parent_follow_to_bp
1999-06-29 01:04:32 +02:00
# Try catching a vfork, and stepping out to the parent.
#
tcatch_vfork_then_parent_follow
}
proc do_vfork_and_follow_child_tests_exec {} {
1999-06-29 01:04:32 +02:00
# Try following the child process by just continuing through the
# vfork, and letting the parent's breakpoint on "main" be auto-
# magically reset in the child.
#
vfork_and_exec_child_follow_to_main_bp
1999-06-29 01:04:32 +02:00
# Try following the child process by stepping through a call to
# vfork. The child also executes an exec. Since the child cannot
# be debugged until after it has exec'd, and since there's a bp on
# "main" in the parent, and since the bp's for the parent are
# recomputed in the exec'd child, the step through a vfork should
# land us in the "main" for the exec'd child, too.
#
vfork_and_exec_child_follow_through_step
1999-06-29 01:04:32 +02:00
# Try catching a vfork, and stepping out to the child.
#
tcatch_vfork_then_child_follow_exec
1999-06-29 01:04:32 +02:00
# Test the ability to follow both child and parent of a vfork. Do
# this without catchpoints.
# ??rehrauer: NYI. Will add testpoints here when implemented.
#
# Test the ability to have the debugger ask the user at vfork-time
# whether to follow the parent, child or both. Do this without
# catchpoints.
# ??rehrauer: NYI. Will add testpoints here when implemented.
#
# Step over a vfork in the child, do "info inferiors" and check the
# parent/child relation is displayed. Run the child over the exec,
# and confirm the relation is no longer displayed in "info
# inferiors".
#
vfork_relations_in_info_inferiors "exec"
1999-06-29 01:04:32 +02:00
}
proc do_vfork_and_follow_child_tests_exit {} {
# Try following the child process by just continuing through the
# vfork, and letting the child exit.
#
vfork_child_follow_to_exit
# Try catching a vfork, and stepping out to the child.
#
tcatch_vfork_then_child_follow_exit
# Step over a vfork in the child, do "info inferiors" and check the
# parent/child relation is displayed. Run the child to completion,
# and confirm the relation is no longer displayed in "info
# inferiors".
#
vfork_relations_in_info_inferiors "exit"
}
with_test_prefix "check vfork support" {
# Check that vfork catchpoints are supported, as an indicator for
# whether vfork-following is supported.
check_vfork_catchpoints
}
Extended-remote exec test This patch updates several exec-related tests and some of the library functions in order to get them running with extended-remote. There were three changes that were required, as follows: In gdb.base/foll-exec.exp, use 'clean_start' in place of proc 'zap_session' to reset the state of the debugger between tests. This sets 'remote exec-file' to execute the correct binary file in each subsequent test. In gdb.base/pie-execl.exp, there is an expect statement with an expression that is used to match output from both gdb and the program under debug. For the remote target, this had to be split into two expressions, using $inferior_spawn_id to match the output from the program. Because I had encountered problems with extended-remote exec events in non-stop mode in my manual testing, I added non-stop testing to the non-ldr-exc-[1234].exp tests. In order to set non-stop mode for remote targets, it is necessary to 'set non-stop on' after gdb has started, but before it connects to gdbserver. This is done using 'save_vars' to set non-stop mode in GDBFLAGS, so GDB sets non-stop mode on startup. gdb/testsuite/ChangeLog: * gdb.base/foll-exec.c: Add copyright header. Fix formatting issues. * gdb.base/foll-exec.exp (zap_session): Delete proc. (do_exec_tests): Use clean_restart in place of zap_session, and for test initialization. Fix formatting issues. Use fail in place of perror. * gdb.base/pie-execl.exp (main): Use 'inferior_spawn_id' in an expect statement to match an expression with output from the program under debug. * gdb.threads/non-ldr-exc-1.exp (do_test, main): Add non-stop tests and pass stop mode argument to clean_restart. Use save_vars to enable non-stop in GDBFLAGS. * gdb.threads/non-ldr-exc-2.exp: Likewise. * gdb.threads/non-ldr-exc-3.exp: Likewise. * gdb.threads/non-ldr-exc-4.exp: Likewise.
2015-09-11 20:06:02 +02:00
# 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
# standard_testfile here because we don't want to overwrite the binary
# of the previous tests.
set testfile "foll-vfork-exit"
set srcfile ${testfile}.c
set binfile [standard_output_file ${testfile}]
if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
untested "failed to build $testfile"
return
}
# Follow parent and follow child vfork tests with a child that exits.
with_test_prefix "exit" {
# These are tests of gdb's ability to follow the parent of a Unix
# vfork system call. The child will subsequently exit.
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 exit.
#
do_vfork_and_follow_child_tests_exit
}
1999-06-29 01:04:32 +02:00
set timeout $oldtimeout
return 0