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 --- /dev/null 1 Jan 1970 00:00:00 -0000
11 +++ ./gdb/testsuite/gdb.base/gcorebg.c 25 Feb 2007 12:21:20 -0000
14 +#include <sys/types.h>
19 +int main (int argc, char **argv)
27 + fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
37 + if (strcmp (argv[1], "detached") == 0)
40 + sprintf (buf, "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
42 + kill (ppid, SIGTERM);
46 + perror ("fork err\n");
56 --- /dev/null 1 Jan 1970 00:00:00 -0000
57 +++ ./gdb/testsuite/gdb.base/gcorebg.exp 25 Feb 2007 12:21:20 -0000
59 +# Copyright 2007 Free Software Foundation, Inc.
61 +# This program is free software; you can redistribute it and/or modify
62 +# it under the terms of the GNU General Public License as published by
63 +# the Free Software Foundation; either version 2 of the License, or
64 +# (at your option) any later version.
66 +# This program is distributed in the hope that it will be useful,
67 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
68 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 +# GNU General Public License for more details.
71 +# You should have received a copy of the GNU General Public License
72 +# along with this program; if not, write to the Free Software
73 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
75 +# Please email any bugs, comments, and/or additions to this file to:
76 +# bug-gdb@prep.ai.mit.edu
78 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
79 +# This is a test for `gdb_gcore.sh' functionality.
80 +# It also tests a regression with `gdb_gcore.sh' being run without its
81 +# accessible terminal.
83 +if ![info exists GCORE] {
84 + set GCORE "${srcdir}/../gdb_gcore.sh"
86 +verbose "using GCORE = $GCORE" 2
88 +set testfile "gcorebg"
89 +set srcfile ${testfile}.c
90 +set binfile ${objdir}/${subdir}/${testfile}
91 +set corefile ${objdir}/${subdir}/${testfile}.test
93 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
94 + untested gcorebg.exp
100 +proc core_clean {} {
103 + foreach file [glob -nocomplain [join [list $corefile *] ""]] {
104 + verbose "Delete file $file" 1
105 + remote_file target delete $file
109 +remote_file target delete "./gdb"
111 +# Generate the core file.
113 +# Provide `./gdb' for `gdb_gcore.sh' running it as a bare `gdb' command.
114 +# Setup also `$PATH' appropriately.
115 +# If GDB was not found let `gdb_gcore.sh' to find the system GDB by `$PATH'.
116 +if {$GDB != "gdb"} {
117 + file link ./gdb $GDB
120 +set oldpath $env(PATH)
121 +set env(PATH) [join [list . $env(PATH)] ":"]
122 +verbose "PATH = $env(PATH)" 2
125 +# $detached == "standard" || $detached == "detached"
127 +proc test_body { detached } {
132 + set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
133 + if { $res < 0 || $res == "" } {
134 + fail "Spawning $detached gcore"
137 + pass "Spawning $detached gcore"
138 + remote_expect target 20 {
140 + fail "Spawned $detached gcore finished"
141 + remote_exec target "kill -9 -[exp_pid -i $res]"
145 + pass "Spawned $detached gcore finished"
146 + remote_wait target 20
150 + if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
151 + pass "Core file generated by $detached gcore"
153 + fail "Core file generated by $detached gcore"
158 +# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
162 +# And now `gdb_gcore.sh' spawn without its controlling terminal available.
163 +# It is spawned through `gcorebg.c' using setpgrp ().
170 +set env(PATH) $oldpath
171 +remote_file target delete "./gdb"