2017-12-10 22:00:49 +00:00
|
|
|
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
2017-12-04 19:24:00 +00:00
|
|
|
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
|
Subject: gdb-6.6-bz229517-gcore-without-terminal.patch
|
|
|
|
|
|
|
|
FileName: gdb-6.6-bz229517-gcore-without-terminal.patch
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
;; Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517).
|
|
|
|
;;=fedoratest
|
2017-12-04 19:24:00 +00:00
|
|
|
|
2010-11-18 04:11:13 +00:00
|
|
|
2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
|
|
|
* gdb_gcore.sh: Redirect GDB from `</dev/null'.
|
|
|
|
|
|
|
|
2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
|
|
|
|
|
* gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files.
|
2017-12-08 04:31:26 +00:00
|
|
|
---
|
|
|
|
gdb/testsuite/gdb.base/gcorebg.c | 49 ++++++++++++++++
|
|
|
|
gdb/testsuite/gdb.base/gcorebg.exp | 113 +++++++++++++++++++++++++++++++++++++
|
|
|
|
2 files changed, 162 insertions(+)
|
|
|
|
create mode 100644 gdb/testsuite/gdb.base/gcorebg.c
|
|
|
|
create mode 100644 gdb/testsuite/gdb.base/gcorebg.exp
|
2010-11-18 04:11:13 +00:00
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000..427ebe9b4f
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.base/gcorebg.c
|
2016-02-16 09:54:56 +00:00
|
|
|
@@ -0,0 +1,49 @@
|
2010-11-18 04:11:13 +00:00
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <signal.h>
|
2016-02-16 09:54:56 +00:00
|
|
|
+#include <string.h>
|
|
|
|
+#include <assert.h>
|
2010-11-18 04:11:13 +00:00
|
|
|
+
|
|
|
|
+int main (int argc, char **argv)
|
|
|
|
+{
|
|
|
|
+ pid_t pid = 0;
|
|
|
|
+ pid_t ppid;
|
2016-02-16 09:54:56 +00:00
|
|
|
+ char buf[1024*2 + 500];
|
|
|
|
+ int gotint;
|
2010-11-18 04:11:13 +00:00
|
|
|
+
|
|
|
|
+ if (argc != 4)
|
|
|
|
+ {
|
|
|
|
+ fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
|
|
|
|
+ argv[0]);
|
|
|
|
+ exit (1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pid = fork ();
|
|
|
|
+
|
|
|
|
+ switch (pid)
|
|
|
|
+ {
|
|
|
|
+ case 0:
|
|
|
|
+ if (strcmp (argv[1], "detached") == 0)
|
|
|
|
+ setpgrp ();
|
|
|
|
+ ppid = getppid ();
|
2016-02-16 09:54:56 +00:00
|
|
|
+ gotint = snprintf (buf, sizeof (buf), "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
|
|
|
|
+ assert (gotint < sizeof (buf));
|
2010-11-18 04:11:13 +00:00
|
|
|
+ system (buf);
|
2016-02-16 09:54:56 +00:00
|
|
|
+ fprintf (stderr, "Killing parent PID %d\n", ppid);
|
2010-11-18 04:11:13 +00:00
|
|
|
+ kill (ppid, SIGTERM);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case -1:
|
|
|
|
+ perror ("fork err\n");
|
|
|
|
+ exit (1);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
2016-02-16 09:54:56 +00:00
|
|
|
+ fprintf (stderr,"Sleeping as PID %d\n", getpid ());
|
2010-11-18 04:11:13 +00:00
|
|
|
+ sleep (60);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
2017-12-08 04:31:26 +00:00
|
|
|
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000000..a5471ba5df
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
|
2010-11-18 04:11:13 +00:00
|
|
|
@@ -0,0 +1,113 @@
|
|
|
|
+# 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
|
|
|
|
+
|
|
|
|
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
|
|
|
+# This is a test for `gdb_gcore.sh' functionality.
|
|
|
|
+# It also tests a regression with `gdb_gcore.sh' being run without its
|
|
|
|
+# accessible terminal.
|
|
|
|
+
|
|
|
|
+if ![info exists GCORE] {
|
2016-02-16 09:54:56 +00:00
|
|
|
+ set GCORE "[standard_output_file ../../../../gcore]"
|
2010-11-18 04:11:13 +00:00
|
|
|
+}
|
|
|
|
+verbose "using GCORE = $GCORE" 2
|
|
|
|
+
|
|
|
|
+set testfile "gcorebg"
|
|
|
|
+set srcfile ${testfile}.c
|
2016-02-16 09:54:56 +00:00
|
|
|
+set binfile [standard_output_file ${testfile}]
|
|
|
|
+set corefile [standard_output_file ${testfile}.test]
|
2010-11-18 04:11:13 +00:00
|
|
|
+
|
|
|
|
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
|
|
|
+ untested gcorebg.exp
|
|
|
|
+ return -1
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# Cleanup.
|
|
|
|
+
|
|
|
|
+proc core_clean {} {
|
|
|
|
+ global corefile
|
|
|
|
+
|
|
|
|
+ foreach file [glob -nocomplain [join [list $corefile *] ""]] {
|
|
|
|
+ verbose "Delete file $file" 1
|
|
|
|
+ remote_file target delete $file
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+core_clean
|
|
|
|
+remote_file target delete "./gdb"
|
|
|
|
+
|
|
|
|
+# Generate the core file.
|
|
|
|
+
|
|
|
|
+# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
|
|
|
|
+# Setup also `$PATH' appropriately.
|
|
|
|
+# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
|
|
|
|
+if {$GDB != "gdb"} {
|
|
|
|
+ file link ./gdb $GDB
|
|
|
|
+}
|
|
|
|
+global env
|
|
|
|
+set oldpath $env(PATH)
|
|
|
|
+set env(PATH) [join [list . $env(PATH)] ":"]
|
|
|
|
+verbose "PATH = $env(PATH)" 2
|
|
|
|
+
|
|
|
|
+# Test file body.
|
|
|
|
+# $detached == "standard" || $detached == "detached"
|
|
|
|
+
|
|
|
|
+proc test_body { detached } {
|
|
|
|
+ global binfile
|
|
|
|
+ global GCORE
|
|
|
|
+ global corefile
|
|
|
|
+
|
|
|
|
+ set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
|
|
|
|
+ if { $res < 0 || $res == "" } {
|
|
|
|
+ fail "Spawning $detached gcore"
|
|
|
|
+ return 1
|
|
|
|
+ }
|
|
|
|
+ pass "Spawning $detached gcore"
|
|
|
|
+ remote_expect target 20 {
|
|
|
|
+ timeout {
|
2016-02-16 09:54:56 +00:00
|
|
|
+ fail "Spawned $detached gcore finished (timeout)"
|
2010-11-18 04:11:13 +00:00
|
|
|
+ remote_exec target "kill -9 -[exp_pid -i $res]"
|
|
|
|
+ return 1
|
|
|
|
+ }
|
2016-02-16 09:54:56 +00:00
|
|
|
+ "Saved corefile .*\r\nKilling parent PID " {
|
2010-11-18 04:11:13 +00:00
|
|
|
+ pass "Spawned $detached gcore finished"
|
|
|
|
+ remote_wait target 20
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
|
|
|
|
+ pass "Core file generated by $detached gcore"
|
|
|
|
+ } else {
|
|
|
|
+ fail "Core file generated by $detached gcore"
|
|
|
|
+ }
|
|
|
|
+ core_clean
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
|
|
|
|
+
|
|
|
|
+test_body standard
|
|
|
|
+
|
|
|
|
+# And now `gdb_gcore.sh' spawn without its controlling terminal available.
|
|
|
|
+# It is spawned through `gcorebg.c' using setpgrp ().
|
|
|
|
+
|
|
|
|
+test_body detached
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# Cleanup.
|
|
|
|
+
|
|
|
|
+set env(PATH) $oldpath
|
|
|
|
+remote_file target delete "./gdb"
|
2017-12-08 04:31:26 +00:00
|
|
|
--
|
|
|
|
2.14.3
|
|
|
|
|