From 4b9424096728a9b3ca0963d1eb6fe60113b3e257 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 22 Apr 2007 20:16:04 +0000 Subject: [PATCH] - Notify user of a child forked process being detached (BZ 235197). - Resolves: rhbz#235197 --- gdb-6.6-bz234468-fork-detach-info.patch | 127 ++++++++++++++++++++++++ gdb.spec | 9 +- 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 gdb-6.6-bz234468-fork-detach-info.patch diff --git a/gdb-6.6-bz234468-fork-detach-info.patch b/gdb-6.6-bz234468-fork-detach-info.patch new file mode 100644 index 0000000..950cce1 --- /dev/null +++ b/gdb-6.6-bz234468-fork-detach-info.patch @@ -0,0 +1,127 @@ +--- ./gdb/linux-nat.c 9 Feb 2007 20:52:16 -0000 1.56 ++++ ./gdb/linux-nat.c 22 Apr 2007 17:20:25 -0000 +@@ -378,9 +378,17 @@ child_follow_fork (struct target_ops *op + /* Detach new forked process? */ + if (detach_fork) + { ++ static int advice_printed = 0; ++ ++ target_terminal_ours (); ++ fprintf_filtered (gdb_stdlog, ++ _("[Detaching after fork from child process %d.%s]\n"), ++ child_pid, (advice_printed ? "" : ++ _(" (Try `set detach-on-fork off'.)"))); ++ advice_printed = 1; ++ + if (debug_linux_nat) + { +- target_terminal_ours (); + fprintf_filtered (gdb_stdlog, + "Detaching after fork from child process %d.\n", + child_pid); +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/fork-detach.c 22 Apr 2007 17:20:25 -0000 +@@ -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; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/fork-detach.exp 22 Apr 2007 17:20:25 -0000 +@@ -0,0 +1,43 @@ ++# 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. ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++set testfile fork-detach ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${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.*Program exited normally\\..*" \ ++ "Info message caught" diff --git a/gdb.spec b/gdb.spec index 36376f9..362dc25 100644 --- a/gdb.spec +++ b/gdb.spec @@ -11,7 +11,7 @@ Name: gdb Version: 6.6 # The release always contains a leading reserved number, start it at 1. -Release: 9%{?dist} +Release: 10%{?dist} License: GPL Group: Development/Debuggers @@ -326,6 +326,9 @@ Patch245: gdb-6.6-bz229517-gcore-without-terminal.patch # Fix testcase for watchpoints in threads (for BZ 237096). Patch246: gdb-6.6-bz237096-watchthreads-testcasefix.patch +# Notify user of a child forked process being detached (BZ 235197). +Patch247: gdb-6.6-bz234468-fork-detach-info.patch + BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext BuildRequires: flex bison sharutils @@ -457,6 +460,7 @@ and printing their data. %patch244 -p1 %patch245 -p1 %patch246 -p1 +%patch247 -p1 # Change the version that gets printed at GDB startup, so it is RedHat # specific. @@ -625,6 +629,9 @@ fi # don't include the files in include, they are part of binutils %changelog +* Sun Apr 22 2007 Jan Kratochvil - 6.6-10 +- Notify user of a child forked process being detached (BZ 235197). + * Sun Apr 22 2007 Jan Kratochvil - 6.6-9 - Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517). - Fix testcase for watchpoints in threads (for BZ 237096).