From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.6-bz235197-fork-detach-info.patch FileName: gdb-6.6-bz235197-fork-detach-info.patch ;; Notify user of a child forked process being detached (BZ 235197). ;;=push+jan: This is more about discussion if/what should be printed. 2008-03-01 Jan Kratochvil Port to GDB-6.8pre. Remove the `[' character from the GDB-6.8 default message. --- gdb/infrun.c | 2 +- gdb/testsuite/gdb.base/catch-syscall.exp | 4 +-- gdb/testsuite/gdb.base/fork-detach.c | 57 ++++++++++++++++++++++++++++++++ gdb/testsuite/gdb.base/fork-detach.exp | 36 ++++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.base/fork-detach.c create mode 100644 gdb/testsuite/gdb.base/fork-detach.exp diff --git a/gdb/infrun.c b/gdb/infrun.c index e1d11234e0..23439979b5 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -461,7 +461,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ remove_breakpoints_pid (ptid_get_pid (inferior_ptid)); } - if (info_verbose || debug_infrun) + if (1 /* Fedora Bug 235197 */ || info_verbose || debug_infrun) { /* Ensure that we have a process ptid. */ ptid_t process_ptid = pid_to_ptid (ptid_get_pid (child_ptid)); diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index 2a8bf27e5c..20fa041155 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -179,7 +179,7 @@ proc check_for_program_end {} { # Deleting the catchpoints delete_breakpoints - gdb_continue_to_end + gdb_continue_to_end "" continue 1 } proc test_catch_syscall_without_args {} { @@ -250,7 +250,7 @@ proc test_catch_syscall_with_wrong_args {} { # If it doesn't, everything is right (since we don't have # a syscall named "mlock" in it). Otherwise, this is a failure. set thistest "catch syscall with unused syscall ($syscall_name)" - gdb_continue_to_end $thistest + gdb_continue_to_end $thistest continue 1 } } diff --git a/gdb/testsuite/gdb.base/fork-detach.c b/gdb/testsuite/gdb.base/fork-detach.c new file mode 100644 index 0000000000..0ba8f465f3 --- /dev/null +++ b/gdb/testsuite/gdb.base/fork-detach.c @@ -0,0 +1,57 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include +#include +#include +#include +#include + +static void func (void) +{ +} + +int main (void) +{ + pid_t child; + + child = fork (); + switch (child) + { + case -1: + abort (); + case 0: + func (); + break; + default: + { +/* We do not test the switching to the other fork by GDB `fork 1'. */ +#if 0 + pid_t got; + + got = waitpid (child, NULL, 0); + assert (got == child); +#endif + break; + } + } + return 0; +} diff --git a/gdb/testsuite/gdb.base/fork-detach.exp b/gdb/testsuite/gdb.base/fork-detach.exp new file mode 100644 index 0000000000..1f1fcef6c4 --- /dev/null +++ b/gdb/testsuite/gdb.base/fork-detach.exp @@ -0,0 +1,36 @@ +# Copyright 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile fork-detach +set srcfile ${testfile}.c +set binfile [standard_output_file ${testfile}] +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_run_cmd +# `Starting program: .*' prefix is available since gdb-6.7. +gdb_test "" \ + "Detaching after fork from child process.*\\\[Inferior .* exited normally\\\]" \ + "Info message caught" -- 2.14.3