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