|
|
132741 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
132741 |
From: Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
132741 |
Date: Fri, 27 Oct 2017 21:07:50 +0200
|
|
|
132741 |
Subject: gdb-6.6-bz229517-gcore-without-terminal.patch
|
|
|
132741 |
|
|
|
132741 |
;; Allow running `/usr/bin/gcore' with provided but inaccessible tty (BZ 229517).
|
|
|
132741 |
;;=fedoratest
|
|
|
132741 |
|
|
|
132741 |
2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
132741 |
|
|
|
132741 |
* gdb_gcore.sh: Redirect GDB from `
|
|
|
132741 |
|
|
|
132741 |
2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
132741 |
|
|
|
132741 |
* gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files.
|
|
|
132741 |
|
|
|
132741 |
diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
|
|
|
132741 |
new file mode 100644
|
|
|
132741 |
--- /dev/null
|
|
|
132741 |
+++ b/gdb/testsuite/gdb.base/gcorebg.c
|
|
|
132741 |
@@ -0,0 +1,49 @@
|
|
|
132741 |
+#include <stdio.h>
|
|
|
132741 |
+#include <sys/types.h>
|
|
|
132741 |
+#include <unistd.h>
|
|
|
132741 |
+#include <stdlib.h>
|
|
|
132741 |
+#include <signal.h>
|
|
|
132741 |
+#include <string.h>
|
|
|
132741 |
+#include <assert.h>
|
|
|
132741 |
+
|
|
|
132741 |
+int main (int argc, char **argv)
|
|
|
132741 |
+{
|
|
|
132741 |
+ pid_t pid = 0;
|
|
|
132741 |
+ pid_t ppid;
|
|
|
132741 |
+ char buf[1024*2 + 500];
|
|
|
132741 |
+ int gotint;
|
|
|
132741 |
+
|
|
|
132741 |
+ if (argc != 4)
|
|
|
132741 |
+ {
|
|
|
132741 |
+ fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
|
|
|
132741 |
+ argv[0]);
|
|
|
132741 |
+ exit (1);
|
|
|
132741 |
+ }
|
|
|
132741 |
+
|
|
|
132741 |
+ pid = fork ();
|
|
|
132741 |
+
|
|
|
132741 |
+ switch (pid)
|
|
|
132741 |
+ {
|
|
|
132741 |
+ case 0:
|
|
|
132741 |
+ if (strcmp (argv[1], "detached") == 0)
|
|
|
132741 |
+ setpgrp ();
|
|
|
132741 |
+ ppid = getppid ();
|
|
|
132741 |
+ gotint = snprintf (buf, sizeof (buf), "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
|
|
|
132741 |
+ assert (gotint < sizeof (buf));
|
|
|
132741 |
+ system (buf);
|
|
|
132741 |
+ fprintf (stderr, "Killing parent PID %d\n", ppid);
|
|
|
132741 |
+ kill (ppid, SIGTERM);
|
|
|
132741 |
+ break;
|
|
|
132741 |
+
|
|
|
132741 |
+ case -1:
|
|
|
132741 |
+ perror ("fork err\n");
|
|
|
132741 |
+ exit (1);
|
|
|
132741 |
+ break;
|
|
|
132741 |
+
|
|
|
132741 |
+ default:
|
|
|
132741 |
+ fprintf (stderr,"Sleeping as PID %d\n", getpid ());
|
|
|
132741 |
+ sleep (60);
|
|
|
132741 |
+ }
|
|
|
132741 |
+
|
|
|
132741 |
+ return 0;
|
|
|
132741 |
+}
|
|
|
132741 |
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
|
|
|
132741 |
new file mode 100644
|
|
|
132741 |
--- /dev/null
|
|
|
132741 |
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
|
|
|
132741 |
@@ -0,0 +1,113 @@
|
|
|
132741 |
+# Copyright 2007 Free Software Foundation, Inc.
|
|
|
132741 |
+
|
|
|
132741 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
132741 |
+# it under the terms of the GNU General Public License as published by
|
|
|
132741 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
132741 |
+# (at your option) any later version.
|
|
|
132741 |
+#
|
|
|
132741 |
+# This program is distributed in the hope that it will be useful,
|
|
|
132741 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
132741 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
132741 |
+# GNU General Public License for more details.
|
|
|
132741 |
+#
|
|
|
132741 |
+# You should have received a copy of the GNU General Public License
|
|
|
132741 |
+# along with this program; if not, write to the Free Software
|
|
|
132741 |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
132741 |
+
|
|
|
132741 |
+# Please email any bugs, comments, and/or additions to this file to:
|
|
|
132741 |
+# bug-gdb@prep.ai.mit.edu
|
|
|
132741 |
+
|
|
|
132741 |
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
|
|
132741 |
+# This is a test for `gdb_gcore.sh' functionality.
|
|
|
132741 |
+# It also tests a regression with `gdb_gcore.sh' being run without its
|
|
|
132741 |
+# accessible terminal.
|
|
|
132741 |
+
|
|
|
132741 |
+if ![info exists GCORE] {
|
|
|
132741 |
+ set GCORE "[standard_output_file ../../../../gcore]"
|
|
|
132741 |
+}
|
|
|
132741 |
+verbose "using GCORE = $GCORE" 2
|
|
|
132741 |
+
|
|
|
132741 |
+set testfile "gcorebg"
|
|
|
132741 |
+set srcfile ${testfile}.c
|
|
|
132741 |
+set binfile [standard_output_file ${testfile}]
|
|
|
132741 |
+set corefile [standard_output_file ${testfile}.test]
|
|
|
132741 |
+
|
|
|
132741 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
|
|
132741 |
+ untested gcorebg.exp
|
|
|
132741 |
+ return -1
|
|
|
132741 |
+}
|
|
|
132741 |
+
|
|
|
132741 |
+# Cleanup.
|
|
|
132741 |
+
|
|
|
132741 |
+proc core_clean {} {
|
|
|
132741 |
+ global corefile
|
|
|
132741 |
+
|
|
|
132741 |
+ foreach file [glob -nocomplain [join [list $corefile *] ""]] {
|
|
|
132741 |
+ verbose "Delete file $file" 1
|
|
|
132741 |
+ remote_file target delete $file
|
|
|
132741 |
+ }
|
|
|
132741 |
+}
|
|
|
132741 |
+core_clean
|
|
|
132741 |
+remote_file target delete "./gdb"
|
|
|
132741 |
+
|
|
|
132741 |
+# Generate the core file.
|
|
|
132741 |
+
|
|
|
132741 |
+# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
|
|
|
132741 |
+# Setup also `$PATH' appropriately.
|
|
|
132741 |
+# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
|
|
|
132741 |
+if {$GDB != "gdb"} {
|
|
|
132741 |
+ file link ./gdb $GDB
|
|
|
132741 |
+}
|
|
|
132741 |
+global env
|
|
|
132741 |
+set oldpath $env(PATH)
|
|
|
132741 |
+set env(PATH) [join [list . $env(PATH)] ":"]
|
|
|
132741 |
+verbose "PATH = $env(PATH)" 2
|
|
|
132741 |
+
|
|
|
132741 |
+# Test file body.
|
|
|
132741 |
+# $detached == "standard" || $detached == "detached"
|
|
|
132741 |
+
|
|
|
132741 |
+proc test_body { detached } {
|
|
|
132741 |
+ global binfile
|
|
|
132741 |
+ global GCORE
|
|
|
132741 |
+ global corefile
|
|
|
132741 |
+
|
|
|
132741 |
+ set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
|
|
|
132741 |
+ if { $res < 0 || $res == "" } {
|
|
|
132741 |
+ fail "Spawning $detached gcore"
|
|
|
132741 |
+ return 1
|
|
|
132741 |
+ }
|
|
|
132741 |
+ pass "Spawning $detached gcore"
|
|
|
132741 |
+ remote_expect target 20 {
|
|
|
132741 |
+ timeout {
|
|
|
132741 |
+ fail "Spawned $detached gcore finished (timeout)"
|
|
|
132741 |
+ remote_exec target "kill -9 -[exp_pid -i $res]"
|
|
|
132741 |
+ return 1
|
|
|
132741 |
+ }
|
|
|
132741 |
+ "Saved corefile .*\r\nKilling parent PID " {
|
|
|
132741 |
+ pass "Spawned $detached gcore finished"
|
|
|
132741 |
+ remote_wait target 20
|
|
|
132741 |
+ }
|
|
|
132741 |
+ }
|
|
|
132741 |
+
|
|
|
132741 |
+ if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
|
|
|
132741 |
+ pass "Core file generated by $detached gcore"
|
|
|
132741 |
+ } else {
|
|
|
132741 |
+ fail "Core file generated by $detached gcore"
|
|
|
132741 |
+ }
|
|
|
132741 |
+ core_clean
|
|
|
132741 |
+}
|
|
|
132741 |
+
|
|
|
132741 |
+# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
|
|
|
132741 |
+
|
|
|
132741 |
+test_body standard
|
|
|
132741 |
+
|
|
|
132741 |
+# And now `gdb_gcore.sh' spawn without its controlling terminal available.
|
|
|
132741 |
+# It is spawned through `gcorebg.c' using setpgrp ().
|
|
|
132741 |
+
|
|
|
132741 |
+test_body detached
|
|
|
132741 |
+
|
|
|
132741 |
+
|
|
|
132741 |
+# Cleanup.
|
|
|
132741 |
+
|
|
|
132741 |
+set env(PATH) $oldpath
|
|
|
132741 |
+remote_file target delete "./gdb"
|