]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.3-mapping-zero-inode-test.patch
- update to 6.8.91.20090930-1 from fedora
[packages/gdb.git] / gdb-6.3-mapping-zero-inode-test.patch
1 Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp
2 ===================================================================
3 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
4 +++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.exp 2009-06-29 16:24:36.000000000 +0200
5 @@ -0,0 +1,96 @@
6 +# Copyright 2007, 2009 Free Software Foundation, Inc.
7 +
8 +# This program is free software; you can redistribute it and/or modify
9 +# it under the terms of the GNU General Public License as published by
10 +# the Free Software Foundation; either version 2 of the License, or
11 +# (at your option) any later version.
12 +# 
13 +# This program is distributed in the hope that it will be useful,
14 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
15 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 +# GNU General Public License for more details.
17 +# 
18 +# You should have received a copy of the GNU General Public License
19 +# along with this program; if not, write to the Free Software
20 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
21 +
22 +# Test GDB's handling of gcore for mapping with a name but zero inode.
23 +
24 +if { [prepare_for_testing gcore-shmid0.exp gcore-shmid0] } {
25 +    return -1
26 +}
27 +
28 +# Does this gdb support gcore?
29 +set test "help gcore"
30 +gdb_test_multiple $test $test {
31 +    -re "Undefined command: .gcore.*$gdb_prompt $" {
32 +       # gcore command not supported -- nothing to test here.
33 +       unsupported "gdb does not support gcore on this target"
34 +       return -1;
35 +    }
36 +    -re "Save a core file .*$gdb_prompt $" {
37 +       pass $test
38 +    }
39 +}
40 +
41 +if { ! [ runto_main ] } then {
42 +    untested gcore-shmid0.exp
43 +    return -1
44 +}
45 +
46 +gdb_breakpoint "initialized"
47 +gdb_breakpoint "unresolved"
48 +
49 +set test "Continue to initialized."
50 +gdb_test_multiple "continue" $test {
51 +    -re "Breakpoint .*, initialized .* at .*\r\n$gdb_prompt $" {
52 +       pass $test
53 +    }
54 +    -re "Breakpoint .*, unresolved .* at .*\r\n$gdb_prompt $" {
55 +       unsupported $test
56 +       return -1
57 +    }
58 +}
59 +
60 +set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore-shmid0.test]
61 +
62 +set test "save a corefile"
63 +gdb_test_multiple "gcore ${objdir}/${subdir}/gcore-shmid0.test" $test {
64 +    -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" {
65 +       pass $test
66 +    }
67 +    -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" {
68 +       unsupported $test
69 +    }
70 +}
71 +
72 +# Be sure to remove the handle first.
73 +# But it would get removed even on a kill by GDB as the handle is already
74 +# deleted, just it is still attached.
75 +gdb_continue_to_end "finish"
76 +
77 +set test "core-file command"
78 +gdb_test_multiple "core-file $objdir/$subdir/gcore-shmid0.test" $test {
79 +    -re ".* program is being debugged already.*y or n. $" {
80 +       # gdb_load may connect us to a gdbserver.
81 +       send_gdb "y\n"
82 +       exp_continue;
83 +    }
84 +    -re "Core was generated by .*\r\n\#0  .*\\\(\\\).*\r\n$gdb_prompt $" {
85 +       # The filename does not fit there anyway so do not check it.
86 +       pass $test
87 +    }
88 +    -re ".*registers from core file: File in wrong format.* $" {
89 +       fail "core-file command (could not read registers from core file)"
90 +    }
91 +}
92 +
93 +set test "backtrace"
94 +gdb_test_multiple "bt" $test {
95 +    -re "#0 *initialized \\\(\\\) at .*#1 .* main \\\(.*$gdb_prompt $" {
96 +       pass $test
97 +    }
98 +    -re "#0 *initialized \\\(\\\) at .*Cannot access memory at address .*$gdb_prompt $" {
99 +       fail $test
100 +    }
101 +}
102 Index: gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c
103 ===================================================================
104 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
105 +++ gdb-6.8.50.20090302/gdb/testsuite/gdb.base/gcore-shmid0.c   2009-06-29 16:22:49.000000000 +0200
106 @@ -0,0 +1,123 @@
107 +/* Copyright 2007, 2009 Free Software Foundation, Inc.
108 +
109 +   This file is part of GDB.
110 +
111 +   This program is free software; you can redistribute it and/or modify
112 +   it under the terms of the GNU General Public License as published by
113 +   the Free Software Foundation; either version 2 of the License, or (at
114 +   your option) any later version.
115 +
116 +   This program is distributed in the hope that it will be useful, but
117 +   WITHOUT ANY WARRANTY; without even the implied warranty of
118 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
119 +   General Public License for more details.
120 +
121 +   You should have received a copy of the GNU General Public License
122 +   along with this program; if not, write to the Free Software
123 +   Foundation, Inc., 59 Temple Place - Suite 330,
124 +   Boston, MA 02111-1307, USA.  */
125 +
126 +/*
127 + * Test GDB's handling of gcore for mapping with a name but zero inode.
128 + */
129 +
130 +#include <sys/ipc.h>
131 +#include <sys/shm.h>
132 +#include <stdio.h>
133 +#include <errno.h>
134 +#include <stdlib.h>
135 +#include <unistd.h>
136 +#include <assert.h>
137 +
138 +/* The same test running in a parallel testsuite may steal us the zero SID,
139 +   even if we never get any EEXIST.  Just try a while.  */
140 +
141 +#define TIMEOUT_SEC 10
142 +
143 +static void
144 +initialized (void)
145 +{
146 +}
147 +
148 +static void
149 +unresolved (void)
150 +{
151 +}
152 +
153 +int
154 +main (void)
155 +{
156 +  int sid;
157 +  unsigned int *addr = (void *) -1L;
158 +  int attempt, round = 0;
159 +  time_t ts_start, ts;
160 +
161 +  if (time (&ts_start) == (time_t) -1)
162 +    {
163 +      printf ("time (): %m\n");
164 +      exit (1);
165 +    }
166 +
167 +  /* The generated SID will cycle with an increment of 32768, attempt until it
168 +   * wraps to 0.  */
169 +
170 +  for (attempt = 0; addr == (void *) -1L; attempt++)
171 +    {
172 +      /* kernel-2.6.25-8.fc9.x86_64 just never returns the value 0 by
173 +        shmget(2).  shmget returns SID range 0..1<<31 in steps of 32768,
174 +        0x1000 should be enough but wrap the range it to be sure.  */
175 +
176 +      if (attempt > 0x21000)
177 +        {
178 +         if (time (&ts) == (time_t) -1)
179 +           {
180 +             printf ("time (): %m\n");
181 +             exit (1);
182 +           }
183 +
184 +         if (ts >= ts_start && ts < ts_start + TIMEOUT_SEC)
185 +           {
186 +             attempt = 0;
187 +             round++;
188 +             continue;
189 +           }
190 +
191 +         printf ("Problem is not reproducible on this kernel (attempt %d, "
192 +                 "round %d))\n", attempt, round);
193 +         unresolved ();
194 +         exit (1);
195 +       }
196 +
197 +      sid = shmget ((key_t) rand (), 0x1000, IPC_CREAT | IPC_EXCL | 0777);
198 +      if (sid == -1)
199 +       {
200 +         if (errno == EEXIST)
201 +           continue;
202 +
203 +         printf ("shmget (%d, 0x1000, IPC_CREAT): errno %d\n", 0, errno);
204 +         exit (1);
205 +       }
206 +
207 +      /* Use SID only if it is 0, retry it otherwise.  */
208 +
209 +      if (sid == 0)
210 +       {
211 +         addr = shmat (sid, NULL, SHM_RND);
212 +         if (addr == (void *) -1L)
213 +           {
214 +             printf ("shmat (%d, NULL, SHM_RND): errno %d\n", sid,
215 +                     errno);
216 +             exit (1);
217 +           }
218 +       }
219 +      if (shmctl (sid, IPC_RMID, NULL) != 0)
220 +       {
221 +         printf ("shmctl (%d, IPC_RMID, NULL): errno %d\n", sid, errno);
222 +         exit (1);
223 +       }
224 +    }
225 +
226 +  initialized ();
227 +
228 +  return 0;
229 +}
This page took 0.053748 seconds and 3 git commands to generate.