1 http://sourceware.org/ml/gdb-patches/2012-03/msg00169.html
2 Subject: [patch 1/3] attach-fail-reasons: Reshuffle code
6 this patch does not make sense on its own but it contains all the
7 uninteresting code moves / reconfigurations.
15 2012-03-06 Jan Kratochvil <jan.kratochvil@redhat.com>
17 * Makefile.in (linux-ptrace.o): New.
18 * common/linux-procfs.c (linux_proc_pid_is_zombie): New,
20 * common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration.
21 * common/linux-ptrace.c: New file.
22 * config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o.
23 * config/arm/linux.mh: Likewise.
24 * config/i386/linux.mh: Likewise.
25 * config/i386/linux64.mh: Likewise.
26 * config/ia64/linux.mh: Likewise.
27 * config/m32r/linux.mh: Likewise.
28 * config/m68k/linux.mh: Likewise.
29 * config/mips/linux.mh: Likewise.
30 * config/pa/linux.mh: Likewise.
31 * config/powerpc/linux.mh: Likewise.
32 * config/powerpc/ppc64-linux.mh: Likewise.
33 * config/powerpc/spu-linux.mh: Likewise.
34 * config/s390/s390.mh: Likewise.
35 * config/sparc/linux.mh: Likewise.
36 * config/sparc/linux64.mh: Likewise.
37 * config/xtensa/linux.mh: Likewise.
38 * linux-nat.c (linux_lwp_is_zombie): Remove, move it to
39 common/linux-procfs.c.
40 (wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie.
43 2012-03-06 Jan Kratochvil <jan.kratochvil@redhat.com>
45 * Makefile.in (linux-ptrace.o): New.
46 * configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*)
47 (cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
48 (m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*)
49 (s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux)
50 (x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ
52 * linux-low.c (linux_attach_lwp_1): Remove redundent else clause.
54 Index: gdb-7.4.50.20120120/gdb/Makefile.in
55 ===================================================================
56 --- gdb-7.4.50.20120120.orig/gdb/Makefile.in 2012-03-06 07:39:41.000000000 +0100
57 +++ gdb-7.4.50.20120120/gdb/Makefile.in 2012-03-06 07:39:50.771713128 +0100
58 @@ -1968,6 +1968,10 @@ linux-procfs.o: $(srcdir)/common/linux-p
59 $(COMPILE) $(srcdir)/common/linux-procfs.c
62 +linux-ptrace.o: $(srcdir)/common/linux-ptrace.c
63 + $(COMPILE) $(srcdir)/common/linux-ptrace.c
67 # gdb/tui/ dependencies
69 Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.c
70 ===================================================================
71 --- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.c 2012-03-06 07:39:41.000000000 +0100
72 +++ gdb-7.4.50.20120120/gdb/common/linux-procfs.c 2012-03-06 07:39:50.771713128 +0100
73 @@ -84,3 +84,34 @@ linux_proc_pid_is_stopped (pid_t pid)
78 +/* See linux-procfs.h declaration. */
81 +linux_proc_pid_is_zombie (pid_t pid)
88 + xsnprintf (buffer, sizeof (buffer), "/proc/%d/status", (int) pid);
89 + procfile = fopen (buffer, "r");
90 + if (procfile == NULL)
92 + warning (_("unable to open /proc file '%s'"), buffer);
97 + while (fgets (buffer, sizeof (buffer), procfile) != NULL)
98 + if (strncmp (buffer, "State:", 6) == 0)
103 + retval = (have_state
104 + && strcmp (buffer, "State:\tZ (zombie)\n") == 0);
108 Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.h
109 ===================================================================
110 --- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.h 2012-03-06 07:39:41.000000000 +0100
111 +++ gdb-7.4.50.20120120/gdb/common/linux-procfs.h 2012-03-06 07:39:50.771713128 +0100
112 @@ -31,4 +31,8 @@ extern int linux_proc_get_tgid (int lwpi
114 extern int linux_proc_pid_is_stopped (pid_t pid);
116 +/* Return non-zero if PID is a zombie. */
118 +extern int linux_proc_pid_is_zombie (pid_t pid);
120 #endif /* COMMON_LINUX_PROCFS_H */
121 Index: gdb-7.4.50.20120120/gdb/common/linux-ptrace.c
122 ===================================================================
123 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
124 +++ gdb-7.4.50.20120120/gdb/common/linux-ptrace.c 2012-03-06 07:39:50.771713128 +0100
126 +/* Linux-specific ptrace manipulation routines.
127 + Copyright (C) 2012 Free Software Foundation, Inc.
129 + This file is part of GDB.
131 + This program is free software; you can redistribute it and/or modify
132 + it under the terms of the GNU General Public License as published by
133 + the Free Software Foundation; either version 3 of the License, or
134 + (at your option) any later version.
136 + This program is distributed in the hope that it will be useful,
137 + but WITHOUT ANY WARRANTY; without even the implied warranty of
138 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139 + GNU General Public License for more details.
141 + You should have received a copy of the GNU General Public License
142 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
148 +#include "gdb_string.h"
151 +#include "linux-ptrace.h"
152 Index: gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh
153 ===================================================================
154 --- gdb-7.4.50.20120120.orig/gdb/config/alpha/alpha-linux.mh 2012-01-10 17:30:44.000000000 +0100
155 +++ gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh 2012-03-06 07:39:50.771713128 +0100
157 NAT_FILE= config/nm-linux.h
158 NATDEPFILES= inf-ptrace.o alpha-linux-nat.o \
159 fork-child.o proc-service.o linux-thread-db.o \
160 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
161 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
162 NAT_CDEPS = $(srcdir)/proc-service.list
164 # The dynamically loaded libthread_db needs access to symbols in the
165 Index: gdb-7.4.50.20120120/gdb/config/arm/linux.mh
166 ===================================================================
167 --- gdb-7.4.50.20120120.orig/gdb/config/arm/linux.mh 2011-08-24 14:07:25.000000000 +0200
168 +++ gdb-7.4.50.20120120/gdb/config/arm/linux.mh 2012-03-06 07:39:50.772713125 +0100
170 NAT_FILE= config/nm-linux.h
171 NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
172 proc-service.o linux-thread-db.o \
173 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
174 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
175 NAT_CDEPS = $(srcdir)/proc-service.list
177 LOADLIBES= -ldl $(RDYNAMIC)
178 Index: gdb-7.4.50.20120120/gdb/config/i386/linux.mh
179 ===================================================================
180 --- gdb-7.4.50.20120120.orig/gdb/config/i386/linux.mh 2012-03-06 07:39:41.000000000 +0100
181 +++ gdb-7.4.50.20120120/gdb/config/i386/linux.mh 2012-03-06 07:39:50.772713125 +0100
182 @@ -4,7 +4,7 @@ NAT_FILE= nm-linux.h
183 NATDEPFILES= inf-ptrace.o fork-child.o \
184 i386-nat.o i386-linux-nat.o \
185 proc-service.o linux-thread-db.o \
186 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
187 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
188 NAT_CDEPS = $(srcdir)/proc-service.list
190 # The dynamically loaded libthread_db needs access to symbols in the
191 Index: gdb-7.4.50.20120120/gdb/config/i386/linux64.mh
192 ===================================================================
193 --- gdb-7.4.50.20120120.orig/gdb/config/i386/linux64.mh 2012-03-06 07:39:41.000000000 +0100
194 +++ gdb-7.4.50.20120120/gdb/config/i386/linux64.mh 2012-03-06 07:39:50.772713125 +0100
195 @@ -3,7 +3,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
196 i386-nat.o amd64-nat.o amd64-linux-nat.o \
197 linux-nat.o linux-osdata.o \
198 proc-service.o linux-thread-db.o linux-fork.o \
200 + linux-procfs.o linux-ptrace.o
201 NAT_FILE= nm-linux64.h
202 NAT_CDEPS = $(srcdir)/proc-service.list
204 Index: gdb-7.4.50.20120120/gdb/config/ia64/linux.mh
205 ===================================================================
206 --- gdb-7.4.50.20120120.orig/gdb/config/ia64/linux.mh 2012-01-10 17:30:44.000000000 +0100
207 +++ gdb-7.4.50.20120120/gdb/config/ia64/linux.mh 2012-03-06 07:39:50.772713125 +0100
208 @@ -5,7 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
209 core-regset.o ia64-linux-nat.o \
210 proc-service.o linux-thread-db.o \
211 linux-nat.o linux-osdata.o linux-fork.o \
213 + linux-procfs.o linux-ptrace.o
214 NAT_CDEPS = $(srcdir)/proc-service.list
216 LOADLIBES = -ldl $(RDYNAMIC)
217 Index: gdb-7.4.50.20120120/gdb/config/m32r/linux.mh
218 ===================================================================
219 --- gdb-7.4.50.20120120.orig/gdb/config/m32r/linux.mh 2012-01-10 17:30:44.000000000 +0100
220 +++ gdb-7.4.50.20120120/gdb/config/m32r/linux.mh 2012-03-06 07:39:50.773713122 +0100
222 NAT_FILE= config/nm-linux.h
223 NATDEPFILES= inf-ptrace.o fork-child.o \
224 m32r-linux-nat.o proc-service.o linux-thread-db.o \
225 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
226 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
227 NAT_CDEPS = $(srcdir)/proc-service.list
229 LOADLIBES= -ldl $(RDYNAMIC)
230 Index: gdb-7.4.50.20120120/gdb/config/m68k/linux.mh
231 ===================================================================
232 --- gdb-7.4.50.20120120.orig/gdb/config/m68k/linux.mh 2012-01-10 17:30:45.000000000 +0100
233 +++ gdb-7.4.50.20120120/gdb/config/m68k/linux.mh 2012-03-06 07:39:50.773713122 +0100
234 @@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
235 NATDEPFILES= inf-ptrace.o fork-child.o \
237 proc-service.o linux-thread-db.o \
238 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
239 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
240 NAT_CDEPS = $(srcdir)/proc-service.list
242 # The dynamically loaded libthread_db needs access to symbols in the
243 Index: gdb-7.4.50.20120120/gdb/config/mips/linux.mh
244 ===================================================================
245 --- gdb-7.4.50.20120120.orig/gdb/config/mips/linux.mh 2011-08-24 14:07:26.000000000 +0200
246 +++ gdb-7.4.50.20120120/gdb/config/mips/linux.mh 2012-03-06 07:39:50.773713122 +0100
247 @@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h
248 NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
249 linux-thread-db.o proc-service.o \
250 linux-nat.o linux-osdata.o linux-fork.o \
252 + linux-procfs.o linux-ptrace.o
253 NAT_CDEPS = $(srcdir)/proc-service.list
255 LOADLIBES = -ldl $(RDYNAMIC)
256 Index: gdb-7.4.50.20120120/gdb/config/pa/linux.mh
257 ===================================================================
258 --- gdb-7.4.50.20120120.orig/gdb/config/pa/linux.mh 2012-01-10 17:30:45.000000000 +0100
259 +++ gdb-7.4.50.20120120/gdb/config/pa/linux.mh 2012-03-06 07:39:50.773713122 +0100
260 @@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h
261 NATDEPFILES= inf-ptrace.o fork-child.o \
262 hppa-linux-nat.o proc-service.o linux-thread-db.o \
263 linux-nat.o linux-osdata.o linux-fork.o \
265 + linux-procfs.o linux-ptrace.o
266 NAT_CDEPS = $(srcdir)/proc-service.list
268 LOADLIBES = -ldl $(RDYNAMIC)
269 Index: gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh
270 ===================================================================
271 --- gdb-7.4.50.20120120.orig/gdb/config/powerpc/linux.mh 2011-08-24 14:07:27.000000000 +0200
272 +++ gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh 2012-03-06 07:39:50.773713122 +0100
273 @@ -5,7 +5,7 @@ XM_CLIBS=
274 NAT_FILE= config/nm-linux.h
275 NATDEPFILES= inf-ptrace.o fork-child.o \
276 ppc-linux-nat.o proc-service.o linux-thread-db.o \
277 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
278 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
279 NAT_CDEPS = $(srcdir)/proc-service.list
281 LOADLIBES = -ldl $(RDYNAMIC)
282 Index: gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh
283 ===================================================================
284 --- gdb-7.4.50.20120120.orig/gdb/config/powerpc/ppc64-linux.mh 2011-08-24 14:07:27.000000000 +0200
285 +++ gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh 2012-03-06 07:39:50.774713118 +0100
286 @@ -5,7 +5,7 @@ XM_CLIBS=
287 NAT_FILE= config/nm-linux.h
288 NATDEPFILES= inf-ptrace.o fork-child.o \
289 ppc-linux-nat.o proc-service.o linux-thread-db.o \
290 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
291 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
292 NAT_CDEPS = $(srcdir)/proc-service.list
294 # The PowerPC has severe limitations on TOC size, and uses them even
295 Index: gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh
296 ===================================================================
297 --- gdb-7.4.50.20120120.orig/gdb/config/powerpc/spu-linux.mh 2011-08-24 14:07:27.000000000 +0200
298 +++ gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh 2012-03-06 07:39:50.774713118 +0100
300 # PPU side of the Cell BE and debugging the SPU side.
302 NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \
304 + linux-procfs.o linux-ptrace.o
306 Index: gdb-7.4.50.20120120/gdb/config/s390/s390.mh
307 ===================================================================
308 --- gdb-7.4.50.20120120.orig/gdb/config/s390/s390.mh 2012-01-05 18:07:05.000000000 +0100
309 +++ gdb-7.4.50.20120120/gdb/config/s390/s390.mh 2012-03-06 07:39:50.774713118 +0100
311 NAT_FILE= config/nm-linux.h
312 NATDEPFILES= inf-ptrace.o fork-child.o s390-nat.o \
313 linux-thread-db.o proc-service.o \
314 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
315 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
316 NAT_CDEPS = $(srcdir)/proc-service.list
317 LOADLIBES = -ldl $(RDYNAMIC)
318 Index: gdb-7.4.50.20120120/gdb/config/sparc/linux.mh
319 ===================================================================
320 --- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux.mh 2012-01-10 17:30:49.000000000 +0100
321 +++ gdb-7.4.50.20120120/gdb/config/sparc/linux.mh 2012-03-06 07:39:50.774713118 +0100
322 @@ -4,7 +4,7 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat
323 core-regset.o fork-child.o inf-ptrace.o \
324 proc-service.o linux-thread-db.o \
325 linux-nat.o linux-osdata.o linux-fork.o \
327 + linux-procfs.o linux-ptrace.o
328 NAT_CDEPS = $(srcdir)/proc-service.list
330 # The dynamically loaded libthread_db needs access to symbols in the
331 Index: gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh
332 ===================================================================
333 --- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux64.mh 2012-01-10 17:30:49.000000000 +0100
334 +++ gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh 2012-03-06 07:39:50.775713114 +0100
335 @@ -5,7 +5,7 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o s
336 fork-child.o inf-ptrace.o \
337 proc-service.o linux-thread-db.o \
338 linux-nat.o linux-osdata.o linux-fork.o \
340 + linux-procfs.o linux-ptrace.o
341 NAT_CDEPS = $(srcdir)/proc-service.list
343 # The dynamically loaded libthread_db needs access to symbols in the
344 Index: gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh
345 ===================================================================
346 --- gdb-7.4.50.20120120.orig/gdb/config/xtensa/linux.mh 2011-08-24 14:07:27.000000000 +0200
347 +++ gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh 2012-03-06 07:39:50.775713114 +0100
348 @@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
350 NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
351 linux-thread-db.o proc-service.o \
352 - linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
353 + linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
354 NAT_CDEPS = $(srcdir)/proc-service.list
356 LOADLIBES = -ldl $(RDYNAMIC)
357 Index: gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in
358 ===================================================================
359 --- gdb-7.4.50.20120120.orig/gdb/gdbserver/Makefile.in 2012-01-04 09:17:23.000000000 +0100
360 +++ gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in 2012-03-06 07:39:50.775713114 +0100
361 @@ -408,6 +408,9 @@ signals.o: ../common/signals.c $(server_
362 linux-procfs.o: ../common/linux-procfs.c $(server_h)
363 $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
365 +linux-ptrace.o: ../common/linux-ptrace.c $(server_h)
366 + $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
368 common-utils.o: ../common/common-utils.c $(server_h)
369 $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
371 Index: gdb-7.4.50.20120120/gdb/gdbserver/configure.srv
372 ===================================================================
373 --- gdb-7.4.50.20120120.orig/gdb/gdbserver/configure.srv 2011-12-06 15:14:49.000000000 +0100
374 +++ gdb-7.4.50.20120120/gdb/gdbserver/configure.srv 2012-03-06 07:39:50.775713114 +0100
375 @@ -47,6 +47,7 @@ case "${target}" in
376 srv_regobj="${srv_regobj} arm-with-vfpv3.o"
377 srv_regobj="${srv_regobj} arm-with-neon.o"
378 srv_tgtobj="linux-low.o linux-osdata.o linux-arm-low.o linux-procfs.o"
379 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
380 srv_xmlfiles="arm-with-iwmmxt.xml"
381 srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv2.xml"
382 srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv3.xml"
383 @@ -69,16 +70,19 @@ case "${target}" in
385 bfin-*-*linux*) srv_regobj=reg-bfin.o
386 srv_tgtobj="linux-low.o linux-osdata.o linux-bfin-low.o linux-procfs.o"
387 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
388 srv_linux_usrregs=yes
389 srv_linux_thread_db=yes
391 crisv32-*-linux*) srv_regobj=reg-crisv32.o
392 srv_tgtobj="linux-low.o linux-osdata.o linux-crisv32-low.o linux-procfs.o"
393 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
394 srv_linux_regsets=yes
395 srv_linux_thread_db=yes
397 cris-*-linux*) srv_regobj=reg-cris.o
398 srv_tgtobj="linux-low.o linux-osdata.o linux-cris-low.o linux-procfs.o"
399 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
400 srv_linux_usrregs=yes
401 srv_linux_thread_db=yes
403 @@ -93,6 +97,7 @@ case "${target}" in
404 srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
406 srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
407 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
408 srv_linux_usrregs=yes
409 srv_linux_regsets=yes
410 srv_linux_thread_db=yes
411 @@ -124,10 +129,12 @@ case "${target}" in
413 ia64-*-linux*) srv_regobj=reg-ia64.o
414 srv_tgtobj="linux-low.o linux-osdata.o linux-ia64-low.o linux-procfs.o"
415 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
416 srv_linux_usrregs=yes
418 m32r*-*-linux*) srv_regobj=reg-m32r.o
419 srv_tgtobj="linux-low.o linux-osdata.o linux-m32r-low.o linux-procfs.o"
420 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
421 srv_linux_usrregs=yes
422 srv_linux_thread_db=yes
424 @@ -137,6 +144,7 @@ case "${target}" in
425 srv_regobj=reg-m68k.o
427 srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o"
428 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
429 srv_linux_usrregs=yes
430 srv_linux_regsets=yes
431 srv_linux_thread_db=yes
432 @@ -147,12 +155,14 @@ case "${target}" in
433 srv_regobj=reg-m68k.o
435 srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o"
436 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
437 srv_linux_usrregs=yes
438 srv_linux_regsets=yes
439 srv_linux_thread_db=yes
441 mips*-*-linux*) srv_regobj="mips-linux.o mips64-linux.o"
442 srv_tgtobj="linux-low.o linux-osdata.o linux-mips-low.o linux-procfs.o"
443 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
444 srv_xmlfiles="mips-linux.xml"
445 srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml"
446 srv_xmlfiles="${srv_xmlfiles} mips-cp0.xml"
447 @@ -181,6 +191,7 @@ case "${target}" in
448 srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o"
449 srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o"
450 srv_tgtobj="linux-low.o linux-osdata.o linux-ppc-low.o linux-procfs.o"
451 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
452 srv_xmlfiles="rs6000/powerpc-32l.xml"
453 srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec32l.xml"
454 srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell32l.xml"
455 @@ -223,6 +234,7 @@ case "${target}" in
456 srv_regobj="${srv_regobj} s390x-linux64v1.o"
457 srv_regobj="${srv_regobj} s390x-linux64v2.o"
458 srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o linux-procfs.o"
459 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
460 srv_xmlfiles="s390-linux32.xml"
461 srv_xmlfiles="${srv_xmlfiles} s390-linux32v1.xml"
462 srv_xmlfiles="${srv_xmlfiles} s390-linux32v2.xml"
463 @@ -243,12 +255,14 @@ case "${target}" in
465 sh*-*-linux*) srv_regobj=reg-sh.o
466 srv_tgtobj="linux-low.o linux-osdata.o linux-sh-low.o linux-procfs.o"
467 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
468 srv_linux_usrregs=yes
469 srv_linux_regsets=yes
470 srv_linux_thread_db=yes
472 sparc*-*-linux*) srv_regobj=reg-sparc64.o
473 srv_tgtobj="linux-low.o linux-osdata.o linux-sparc-low.o linux-procfs.o"
474 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
475 srv_linux_regsets=yes
476 srv_linux_thread_db=yes
478 @@ -265,12 +279,14 @@ case "${target}" in
479 srv_xmlfiles="${srv_xmlfiles} tic6x-gp.xml"
480 srv_xmlfiles="${srv_xmlfiles} tic6x-c6xp.xml"
481 srv_tgtobj="linux-low.o linux-osdata.o linux-tic6x-low.o linux-procfs.o"
482 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
483 srv_linux_regsets=yes
484 srv_linux_usrregs=yes
485 srv_linux_thread_db=yes
487 x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
488 srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
489 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
490 srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
491 srv_linux_usrregs=yes # This is for i386 progs.
492 srv_linux_regsets=yes
493 @@ -285,6 +301,7 @@ case "${target}" in
495 xtensa*-*-linux*) srv_regobj=reg-xtensa.o
496 srv_tgtobj="linux-low.o linux-osdata.o linux-xtensa-low.o linux-procfs.o"
497 + srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
498 srv_linux_regsets=yes
500 *) echo "Error: target not supported by gdbserver."
501 Index: gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c
502 ===================================================================
503 --- gdb-7.4.50.20120120.orig/gdb/gdbserver/linux-low.c 2012-03-06 07:39:41.000000000 +0100
504 +++ gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c 2012-03-06 07:39:50.776713111 +0100
505 @@ -630,10 +630,10 @@ linux_attach_lwp_1 (unsigned long lwpid,
510 - /* If we fail to attach to a process, report an error. */
511 - error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid,
512 - strerror (errno), errno);
514 + /* If we fail to attach to a process, report an error. */
515 + error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid,
516 + strerror (errno), errno);
520 Index: gdb-7.4.50.20120120/gdb/linux-nat.c
521 ===================================================================
522 --- gdb-7.4.50.20120120.orig/gdb/linux-nat.c 2012-03-06 07:39:41.000000000 +0100
523 +++ gdb-7.4.50.20120120/gdb/linux-nat.c 2012-03-06 07:39:50.777713108 +0100
524 @@ -2464,37 +2464,6 @@ linux_handle_extended_wait (struct lwp_i
525 _("unknown ptrace event %d"), event);
528 -/* Return non-zero if LWP is a zombie. */
531 -linux_lwp_is_zombie (long lwp)
533 - char buffer[MAXPATHLEN];
538 - xsnprintf (buffer, sizeof (buffer), "/proc/%ld/status", lwp);
539 - procfile = fopen (buffer, "r");
540 - if (procfile == NULL)
542 - warning (_("unable to open /proc file '%s'"), buffer);
547 - while (fgets (buffer, sizeof (buffer), procfile) != NULL)
548 - if (strncmp (buffer, "State:", 6) == 0)
553 - retval = (have_state
554 - && strcmp (buffer, "State:\tZ (zombie)\n") == 0);
559 /* Wait for LP to stop. Returns the wait status, or 0 if the LWP has
562 @@ -2548,10 +2517,10 @@ wait_lwp (struct lwp_info *lp)
564 This is racy, what if the tgl becomes a zombie right after we check?
565 Therefore always use WNOHANG with sigsuspend - it is equivalent to
566 - waiting waitpid but the linux_lwp_is_zombie is safe this way. */
567 + waiting waitpid but linux_proc_pid_is_zombie is safe this way. */
569 if (GET_PID (lp->ptid) == GET_LWP (lp->ptid)
570 - && linux_lwp_is_zombie (GET_LWP (lp->ptid)))
571 + && linux_proc_pid_is_zombie (GET_LWP (lp->ptid)))
575 @@ -3431,7 +3400,7 @@ check_zombie_leaders (void)
576 /* Check if there are other threads in the group, as we may
577 have raced with the inferior simply exiting. */
578 && num_lwps (inf->pid) > 1
579 - && linux_lwp_is_zombie (inf->pid))
580 + && linux_proc_pid_is_zombie (inf->pid))
583 fprintf_unfiltered (gdb_stdlog,