]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.6-bz229517-gcore-without-terminal.patch
- typo
[packages/gdb.git] / gdb-6.6-bz229517-gcore-without-terminal.patch
1 2007-04-22  Jan Kratochvil <jan.kratochvil@redhat.com>
2
3         * gdb_gcore.sh: Redirect GDB from `</dev/null'.
4
5 2007-04-22  Jan Kratochvil <jan.kratochvil@redhat.com>
6
7         * gdb.base/gcorebg.exp, gdb.base/gcorebg.c: New files.
8
9
10 --- /dev/null   1 Jan 1970 00:00:00 -0000
11 +++ ./gdb/testsuite/gdb.base/gcorebg.c  25 Feb 2007 12:21:20 -0000
12 @@ -0,0 +1,43 @@
13 +#include <stdio.h>
14 +#include <sys/types.h>
15 +#include <unistd.h>
16 +#include <stdlib.h>
17 +#include <signal.h>
18 +
19 +int main (int argc, char **argv)
20 +{
21 +  pid_t pid = 0;
22 +  pid_t ppid;
23 +  char buf[256];
24 +
25 +  if (argc != 4)
26 +    {
27 +      fprintf (stderr, "Syntax: %s {standard|detached} <gcore command> <core output file>\n",
28 +              argv[0]);
29 +      exit (1);
30 +    }
31 +
32 +  pid = fork ();
33 +
34 +  switch (pid)
35 +    {
36 +      case 0:
37 +        if (strcmp (argv[1], "detached") == 0)
38 +         setpgrp ();
39 +       ppid = getppid ();
40 +       sprintf (buf, "sh %s -o %s %d", argv[2], argv[3], (int) ppid);
41 +       system (buf);
42 +       kill (ppid, SIGTERM);
43 +       break;
44 +
45 +      case -1:
46 +       perror ("fork err\n");
47 +       exit (1);
48 +       break;
49 +
50 +      default:
51 +       sleep (60);
52 +    }
53 +
54 +  return 0;
55 +}
56 --- /dev/null   1 Jan 1970 00:00:00 -0000
57 +++ ./gdb/testsuite/gdb.base/gcorebg.exp        25 Feb 2007 12:21:20 -0000
58 @@ -0,0 +1,113 @@
59 +# Copyright 2007 Free Software Foundation, Inc.
60 +
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.
65 +# 
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.
70 +# 
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.  
74 +
75 +# Please email any bugs, comments, and/or additions to this file to:
76 +# bug-gdb@prep.ai.mit.edu
77 +
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.
82 +
83 +if ![info exists GCORE] {
84 +    set GCORE "${srcdir}/../gdb_gcore.sh"
85 +}
86 +verbose "using GCORE = $GCORE" 2
87 +
88 +set testfile "gcorebg"
89 +set srcfile  ${testfile}.c
90 +set binfile  ${objdir}/${subdir}/${testfile}
91 +set corefile ${objdir}/${subdir}/${testfile}.test
92 +
93 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
94 +     untested gcorebg.exp
95 +     return -1
96 +}
97 +
98 +# Cleanup.
99 +
100 +proc core_clean {} {
101 +    global corefile
102 +
103 +    foreach file [glob -nocomplain [join [list $corefile *] ""]] {
104 +       verbose "Delete file $file" 1
105 +       remote_file target delete $file
106 +    }
107 +}
108 +core_clean
109 +remote_file target delete "./gdb"
110 +
111 +# Generate the core file.
112 +
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
118 +}
119 +global env
120 +set oldpath $env(PATH)
121 +set env(PATH) [join [list . $env(PATH)] ":"]
122 +verbose "PATH = $env(PATH)" 2
123 +
124 +# Test file body.
125 +# $detached == "standard" || $detached == "detached"
126 +
127 +proc test_body { detached } {
128 +    global binfile
129 +    global GCORE
130 +    global corefile
131 +
132 +    set res [remote_spawn target "$binfile $detached $GCORE $corefile"]
133 +    if { $res < 0 || $res == "" } {
134 +       fail "Spawning $detached gcore"
135 +       return 1
136 +    }
137 +    pass "Spawning $detached gcore"
138 +    remote_expect target 20 {
139 +       timeout {
140 +           fail "Spawned $detached gcore finished"
141 +           remote_exec target "kill -9 -[exp_pid -i $res]"
142 +           return 1
143 +       }
144 +       eof {
145 +           pass "Spawned $detached gcore finished"
146 +           remote_wait target 20
147 +       }
148 +    }
149 +
150 +    if {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]} {
151 +       pass "Core file generated by $detached gcore"
152 +    } else {
153 +       fail "Core file generated by $detached gcore"
154 +    }
155 +    core_clean
156 +}
157 +
158 +# First a general `gdb_gcore.sh' spawn with its controlling terminal available.
159 +
160 +test_body standard
161 +
162 +# And now `gdb_gcore.sh' spawn without its controlling terminal available.
163 +# It is spawned through `gcorebg.c' using setpgrp ().
164 +
165 +test_body detached
166 +
167 +
168 +# Cleanup.
169 +
170 +set env(PATH) $oldpath
171 +remote_file target delete "./gdb"
This page took 0.044669 seconds and 3 git commands to generate.