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 $tracelevel then {
103 +if ![info exists GCORE] {
104 + set GCORE "${srcdir}/../gdb_gcore.sh"
106 +verbose "using GCORE = $GCORE" 2
108 +set testfile "gcorebg"
109 +set srcfile ${testfile}.c
110 +set binfile ${objdir}/${subdir}/${testfile}
111 +set corefile ${objdir}/${subdir}/${testfile}.test
113 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
114 + untested gcorebg.exp
120 +proc core_clean {} {
123 + foreach file [glob -nocomplain [join [list $corefile *] ""]] {
124 + verbose "Delete file $file" 1
125 + remote_file target delete $file
129 +remote_file target delete "./gdb"
131 +# Generate the core file.
133 +# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
134 +# Setup also `$PATH' appropriately.
135 +# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
136 +if {$GDB != "gdb"} {
137 + file link ./gdb $GDB
140 +set oldpath $env(PATH)
141 +set env(PATH) [join [list . $env(PATH)] ":"]
142 +verbose "PATH = $env(PATH)" 2
145 +# $detached == "standard" || $detached == "detached"
147 +proc test_body { detached } {
152 + set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
153 + if { $res < 0 || $res == "" } {
154 + fail "Spawning $detached gcore"
157 + pass "Spawning $detached gcore"
158 + remote_expect target 20 {
160 + fail "Spawned $detached gcore finished"
161 + remote_exec target "kill -9 -[exp_pid -i $res]"
165 + pass "Spawned $detached gcore finished"
166 + remote_wait target 20
170 + if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
171 + pass "Core file generated by $detached gcore"
173 + fail "Core file generated by $detached gcore"
178 +# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
182 +# And now `gdb_gcore.sh' spawn without its controlling terminal available.
183 +# It is spawned through `gcorebg.c' using setpgrp ().
190 +set env(PATH) $oldpath
191 +remote_file target delete "./gdb"