1 2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
3 * gdb_gcore.sh: Redirect GDB from `</dev/null'.
5 2007-04-22 Jan Kratochvil <jan.kratochvil@redhat.com>
7 * gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files.
10 --- gdb-6.6-orig/gdb/gdb_gcore.sh 2005-12-17 17:33:59.000000000 -0500
11 +++ gdb-6.6/gdb/gdb_gcore.sh 2007-04-22 05:42:50.000000000 -0400
16 - gdb -x $tmpfile -batch
17 + # `</dev/null' to avoid touching interactive terminal if it is
18 + # available but not accessible (SIGTTIN risk)
19 + gdb -x $tmpfile -batch </dev/null
21 if [ -r $name.$pid ] ; then
23 --- /dev/null 1 Jan 1970 00:00:00 -0000
24 +++ ./gdb/testsuite/gdb.base/gcorebg.c 25 Feb 2007 12:21:20 -0000
27 +#include <sys/types.h>
32 +int main (int argc, char **argv)
40 + fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
50 + if (strcmp (argv[1], "detached") == 0)
53 + sprintf (buf, "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
55 + kill (ppid, SIGTERM);
59 + perror ("fork err\n");
69 --- /dev/null 1 Jan 1970 00:00:00 -0000
70 +++ ./gdb/testsuite/gdb.base/gcorebg.exp 25 Feb 2007 12:21:20 -0000
72 +# Copyright 2007 Free Software Foundation, Inc.
74 +# This program is free software; you can redistribute it and/or modify
75 +# it under the terms of the GNU General Public License as published by
76 +# the Free Software Foundation; either version 2 of the License, or
77 +# (at your option) any later version.
79 +# This program is distributed in the hope that it will be useful,
80 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
81 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
82 +# GNU General Public License for more details.
84 +# You should have received a copy of the GNU General Public License
85 +# along with this program; if not, write to the Free Software
86 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
88 +# Please email any bugs, comments, and/or additions to this file to:
89 +# bug-gdb@prep.ai.mit.edu
91 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
92 +# This is a test for `gdb_gcore.sh' functionality.
93 +# It also tests a regression with `gdb_gcore.sh' being run without its
94 +# accessible terminal.
96 +if ![info exists GCORE] {
97 + set GCORE "${srcdir}/../gdb_gcore.sh"
99 +verbose "using GCORE = $GCORE" 2
101 +set testfile "gcorebg"
102 +set srcfile ${testfile}.c
103 +set binfile ${objdir}/${subdir}/${testfile}
104 +set corefile ${objdir}/${subdir}/${testfile}.test
106 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
107 + untested gcorebg.exp
113 +proc core_clean {} {
116 + foreach file [glob -nocomplain [join [list $corefile *] ""]] {
117 + verbose "Delete file $file" 1
118 + remote_file target delete $file
122 +remote_file target delete "./gdb"
124 +# Generate the core file.
126 +# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
127 +# Setup also `$PATH' appropriately.
128 +# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
129 +if {$GDB != "gdb"} {
130 + file link ./gdb $GDB
133 +set oldpath $env(PATH)
134 +set env(PATH) [join [list . $env(PATH)] ":"]
135 +verbose "PATH = $env(PATH)" 2
138 +# $detached == "standard" || $detached == "detached"
140 +proc test_body { detached } {
145 + set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
146 + if { $res < 0 || $res == "" } {
147 + fail "Spawning $detached gcore"
150 + pass "Spawning $detached gcore"
151 + remote_expect target 20 {
153 + fail "Spawned $detached gcore finished"
154 + remote_exec target "kill -9 -[exp_pid -i $res]"
158 + pass "Spawned $detached gcore finished"
159 + remote_wait target 20
163 + if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
164 + pass "Core file generated by $detached gcore"
166 + fail "Core file generated by $detached gcore"
171 +# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
175 +# And now `gdb_gcore.sh' spawn without its controlling terminal available.
176 +# It is spawned through `gcorebg.c' using setpgrp ().
183 +set env(PATH) $oldpath
184 +remote_file target delete "./gdb"