gdb/gdb-attach-fail-reasons-3of...

584 lines
24 KiB
Diff

http://sourceware.org/ml/gdb-patches/2012-03/msg00169.html
Subject: [patch 1/3] attach-fail-reasons: Reshuffle code
Hi,
this patch does not make sense on its own but it contains all the
uninteresting code moves / reconfigurations.
Thanks,
Jan
gdb/
2012-03-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* Makefile.in (linux-ptrace.o): New.
* common/linux-procfs.c (linux_proc_pid_is_zombie): New,
from linux-nat.c.
* common/linux-procfs.h (linux_proc_pid_is_zombie): New declaration.
* common/linux-ptrace.c: New file.
* config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-ptrace.o.
* config/arm/linux.mh: Likewise.
* config/i386/linux.mh: Likewise.
* config/i386/linux64.mh: Likewise.
* config/ia64/linux.mh: Likewise.
* config/m32r/linux.mh: Likewise.
* config/m68k/linux.mh: Likewise.
* config/mips/linux.mh: Likewise.
* config/pa/linux.mh: Likewise.
* config/powerpc/linux.mh: Likewise.
* config/powerpc/ppc64-linux.mh: Likewise.
* config/powerpc/spu-linux.mh: Likewise.
* config/s390/s390.mh: Likewise.
* config/sparc/linux.mh: Likewise.
* config/sparc/linux64.mh: Likewise.
* config/xtensa/linux.mh: Likewise.
* linux-nat.c (linux_lwp_is_zombie): Remove, move it to
common/linux-procfs.c.
(wait_lwp): Rename linux_lwp_is_zombie to linux_proc_pid_is_zombie.
gdb/gdbserver/
2012-03-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* Makefile.in (linux-ptrace.o): New.
* configure.srv (arm*-*-linux*, bfin-*-*linux*, crisv32-*-linux*)
(cris-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
(m68*-*-linux*, m68*-*-uclinux*, mips*-*-linux*, powerpc*-*-linux*)
(s390*-*-linux*, sh*-*-linux*, sparc*-*-linux*, tic6x-*-uclinux)
(x86_64-*-linux*, xtensa*-*-linux*): Add linux-ptrace.o to SRV_TGTOBJ
of these targets.
* linux-low.c (linux_attach_lwp_1): Remove redundent else clause.
Index: gdb-7.4.50.20120120/gdb/Makefile.in
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/Makefile.in 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/Makefile.in 2012-03-06 07:39:50.771713128 +0100
@@ -1968,6 +1968,10 @@ linux-procfs.o: $(srcdir)/common/linux-p
$(COMPILE) $(srcdir)/common/linux-procfs.c
$(POSTCOMPILE)
+linux-ptrace.o: $(srcdir)/common/linux-ptrace.c
+ $(COMPILE) $(srcdir)/common/linux-ptrace.c
+ $(POSTCOMPILE)
+
#
# gdb/tui/ dependencies
#
Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.c 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.c 2012-03-06 07:39:50.771713128 +0100
@@ -84,3 +84,34 @@ linux_proc_pid_is_stopped (pid_t pid)
}
return retval;
}
+
+/* See linux-procfs.h declaration. */
+
+int
+linux_proc_pid_is_zombie (pid_t pid)
+{
+ char buffer[100];
+ FILE *procfile;
+ int retval;
+ int have_state;
+
+ xsnprintf (buffer, sizeof (buffer), "/proc/%d/status", (int) pid);
+ procfile = fopen (buffer, "r");
+ if (procfile == NULL)
+ {
+ warning (_("unable to open /proc file '%s'"), buffer);
+ return 0;
+ }
+
+ have_state = 0;
+ while (fgets (buffer, sizeof (buffer), procfile) != NULL)
+ if (strncmp (buffer, "State:", 6) == 0)
+ {
+ have_state = 1;
+ break;
+ }
+ retval = (have_state
+ && strcmp (buffer, "State:\tZ (zombie)\n") == 0);
+ fclose (procfile);
+ return retval;
+}
Index: gdb-7.4.50.20120120/gdb/common/linux-procfs.h
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/common/linux-procfs.h 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/common/linux-procfs.h 2012-03-06 07:39:50.771713128 +0100
@@ -31,4 +31,8 @@ extern int linux_proc_get_tgid (int lwpi
extern int linux_proc_pid_is_stopped (pid_t pid);
+/* Return non-zero if PID is a zombie. */
+
+extern int linux_proc_pid_is_zombie (pid_t pid);
+
#endif /* COMMON_LINUX_PROCFS_H */
Index: gdb-7.4.50.20120120/gdb/common/linux-ptrace.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.4.50.20120120/gdb/common/linux-ptrace.c 2012-03-06 07:39:50.771713128 +0100
@@ -0,0 +1,26 @@
+/* Linux-specific ptrace manipulation routines.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef GDBSERVER
+#include "server.h"
+#else
+#include "defs.h"
+#include "gdb_string.h"
+#endif
+
+#include "linux-ptrace.h"
Index: gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/alpha/alpha-linux.mh 2012-01-10 17:30:44.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/alpha/alpha-linux.mh 2012-03-06 07:39:50.771713128 +0100
@@ -2,7 +2,7 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o alpha-linux-nat.o \
fork-child.o proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
Index: gdb-7.4.50.20120120/gdb/config/arm/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/arm/linux.mh 2011-08-24 14:07:25.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/arm/linux.mh 2012-03-06 07:39:50.772713125 +0100
@@ -3,7 +3,7 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES= -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/i386/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/i386/linux.mh 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/i386/linux.mh 2012-03-06 07:39:50.772713125 +0100
@@ -4,7 +4,7 @@ NAT_FILE= nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o i386-linux-nat.o \
proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
Index: gdb-7.4.50.20120120/gdb/config/i386/linux64.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/i386/linux64.mh 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/i386/linux64.mh 2012-03-06 07:39:50.772713125 +0100
@@ -3,7 +3,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o amd64-nat.o amd64-linux-nat.o \
linux-nat.o linux-osdata.o \
proc-service.o linux-thread-db.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_FILE= nm-linux64.h
NAT_CDEPS = $(srcdir)/proc-service.list
Index: gdb-7.4.50.20120120/gdb/config/ia64/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/ia64/linux.mh 2012-01-10 17:30:44.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/ia64/linux.mh 2012-03-06 07:39:50.772713125 +0100
@@ -5,7 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
core-regset.o ia64-linux-nat.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/m32r/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/m32r/linux.mh 2012-01-10 17:30:44.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/m32r/linux.mh 2012-03-06 07:39:50.773713122 +0100
@@ -3,7 +3,7 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
m32r-linux-nat.o proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES= -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/m68k/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/m68k/linux.mh 2012-01-10 17:30:45.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/m68k/linux.mh 2012-03-06 07:39:50.773713122 +0100
@@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
m68klinux-nat.o \
proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
Index: gdb-7.4.50.20120120/gdb/config/mips/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/mips/linux.mh 2011-08-24 14:07:26.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/mips/linux.mh 2012-03-06 07:39:50.773713122 +0100
@@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
linux-thread-db.o proc-service.o \
linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/pa/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/pa/linux.mh 2012-01-10 17:30:45.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/pa/linux.mh 2012-03-06 07:39:50.773713122 +0100
@@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
hppa-linux-nat.o proc-service.o linux-thread-db.o \
linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/powerpc/linux.mh 2011-08-24 14:07:27.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/powerpc/linux.mh 2012-03-06 07:39:50.773713122 +0100
@@ -5,7 +5,7 @@ XM_CLIBS=
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/powerpc/ppc64-linux.mh 2011-08-24 14:07:27.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/powerpc/ppc64-linux.mh 2012-03-06 07:39:50.774713118 +0100
@@ -5,7 +5,7 @@ XM_CLIBS=
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The PowerPC has severe limitations on TOC size, and uses them even
Index: gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/powerpc/spu-linux.mh 2011-08-24 14:07:27.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/powerpc/spu-linux.mh 2012-03-06 07:39:50.774713118 +0100
@@ -4,5 +4,5 @@
# PPU side of the Cell BE and debugging the SPU side.
NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
Index: gdb-7.4.50.20120120/gdb/config/s390/s390.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/s390/s390.mh 2012-01-05 18:07:05.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/s390/s390.mh 2012-03-06 07:39:50.774713118 +0100
@@ -2,6 +2,6 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o s390-nat.o \
linux-thread-db.o proc-service.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/config/sparc/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux.mh 2012-01-10 17:30:49.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/sparc/linux.mh 2012-03-06 07:39:50.774713118 +0100
@@ -4,7 +4,7 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat
core-regset.o fork-child.o inf-ptrace.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
Index: gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/sparc/linux64.mh 2012-01-10 17:30:49.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/config/sparc/linux64.mh 2012-03-06 07:39:50.775713114 +0100
@@ -5,7 +5,7 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o s
fork-child.o inf-ptrace.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-osdata.o linux-fork.o \
- linux-procfs.o
+ linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
Index: gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config/xtensa/linux.mh 2011-08-24 14:07:27.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config/xtensa/linux.mh 2012-03-06 07:39:50.775713114 +0100
@@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
linux-thread-db.o proc-service.o \
- linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o
+ linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o
NAT_CDEPS = $(srcdir)/proc-service.list
LOADLIBES = -ldl $(RDYNAMIC)
Index: gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/gdbserver/Makefile.in 2012-01-04 09:17:23.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/gdbserver/Makefile.in 2012-03-06 07:39:50.775713114 +0100
@@ -408,6 +408,9 @@ signals.o: ../common/signals.c $(server_
linux-procfs.o: ../common/linux-procfs.c $(server_h)
$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
+linux-ptrace.o: ../common/linux-ptrace.c $(server_h)
+ $(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
+
common-utils.o: ../common/common-utils.c $(server_h)
$(CC) -c $(CPPFLAGS) $(INTERNAL_CFLAGS) $< -DGDBSERVER
Index: gdb-7.4.50.20120120/gdb/gdbserver/configure.srv
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/gdbserver/configure.srv 2011-12-06 15:14:49.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/gdbserver/configure.srv 2012-03-06 07:39:50.775713114 +0100
@@ -47,6 +47,7 @@ case "${target}" in
srv_regobj="${srv_regobj} arm-with-vfpv3.o"
srv_regobj="${srv_regobj} arm-with-neon.o"
srv_tgtobj="linux-low.o linux-osdata.o linux-arm-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_xmlfiles="arm-with-iwmmxt.xml"
srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv2.xml"
srv_xmlfiles="${srv_xmlfiles} arm-with-vfpv3.xml"
@@ -69,16 +70,19 @@ case "${target}" in
;;
bfin-*-*linux*) srv_regobj=reg-bfin.o
srv_tgtobj="linux-low.o linux-osdata.o linux-bfin-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
crisv32-*-linux*) srv_regobj=reg-crisv32.o
srv_tgtobj="linux-low.o linux-osdata.o linux-crisv32-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
cris-*-linux*) srv_regobj=reg-cris.o
srv_tgtobj="linux-low.o linux-osdata.o linux-cris-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
@@ -93,6 +97,7 @@ case "${target}" in
srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
fi
srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
@@ -124,10 +129,12 @@ case "${target}" in
;;
ia64-*-linux*) srv_regobj=reg-ia64.o
srv_tgtobj="linux-low.o linux-osdata.o linux-ia64-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
;;
m32r*-*-linux*) srv_regobj=reg-m32r.o
srv_tgtobj="linux-low.o linux-osdata.o linux-m32r-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
@@ -137,6 +144,7 @@ case "${target}" in
srv_regobj=reg-m68k.o
fi
srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
@@ -147,12 +155,14 @@ case "${target}" in
srv_regobj=reg-m68k.o
fi
srv_tgtobj="linux-low.o linux-osdata.o linux-m68k-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
mips*-*-linux*) srv_regobj="mips-linux.o mips64-linux.o"
srv_tgtobj="linux-low.o linux-osdata.o linux-mips-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_xmlfiles="mips-linux.xml"
srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml"
srv_xmlfiles="${srv_xmlfiles} mips-cp0.xml"
@@ -181,6 +191,7 @@ case "${target}" in
srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o"
srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o"
srv_tgtobj="linux-low.o linux-osdata.o linux-ppc-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_xmlfiles="rs6000/powerpc-32l.xml"
srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-altivec32l.xml"
srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-cell32l.xml"
@@ -223,6 +234,7 @@ case "${target}" in
srv_regobj="${srv_regobj} s390x-linux64v1.o"
srv_regobj="${srv_regobj} s390x-linux64v2.o"
srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_xmlfiles="s390-linux32.xml"
srv_xmlfiles="${srv_xmlfiles} s390-linux32v1.xml"
srv_xmlfiles="${srv_xmlfiles} s390-linux32v2.xml"
@@ -243,12 +255,14 @@ case "${target}" in
;;
sh*-*-linux*) srv_regobj=reg-sh.o
srv_tgtobj="linux-low.o linux-osdata.o linux-sh-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
sparc*-*-linux*) srv_regobj=reg-sparc64.o
srv_tgtobj="linux-low.o linux-osdata.o linux-sparc-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
@@ -265,12 +279,14 @@ case "${target}" in
srv_xmlfiles="${srv_xmlfiles} tic6x-gp.xml"
srv_xmlfiles="${srv_xmlfiles} tic6x-c6xp.xml"
srv_tgtobj="linux-low.o linux-osdata.o linux-tic6x-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_regsets=yes
srv_linux_usrregs=yes
srv_linux_thread_db=yes
;;
x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
srv_tgtobj="linux-low.o linux-osdata.o linux-x86-low.o i386-low.o i387-fp.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
srv_linux_usrregs=yes # This is for i386 progs.
srv_linux_regsets=yes
@@ -285,6 +301,7 @@ case "${target}" in
xtensa*-*-linux*) srv_regobj=reg-xtensa.o
srv_tgtobj="linux-low.o linux-osdata.o linux-xtensa-low.o linux-procfs.o"
+ srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
srv_linux_regsets=yes
;;
*) echo "Error: target not supported by gdbserver."
Index: gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/gdbserver/linux-low.c 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/gdbserver/linux-low.c 2012-03-06 07:39:50.776713111 +0100
@@ -630,10 +630,10 @@ linux_attach_lwp_1 (unsigned long lwpid,
fflush (stderr);
return;
}
- else
- /* If we fail to attach to a process, report an error. */
- error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid,
- strerror (errno), errno);
+
+ /* If we fail to attach to a process, report an error. */
+ error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid,
+ strerror (errno), errno);
}
if (initial)
Index: gdb-7.4.50.20120120/gdb/linux-nat.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/linux-nat.c 2012-03-06 07:39:41.000000000 +0100
+++ gdb-7.4.50.20120120/gdb/linux-nat.c 2012-03-06 07:39:50.777713108 +0100
@@ -2464,37 +2464,6 @@ linux_handle_extended_wait (struct lwp_i
_("unknown ptrace event %d"), event);
}
-/* Return non-zero if LWP is a zombie. */
-
-static int
-linux_lwp_is_zombie (long lwp)
-{
- char buffer[MAXPATHLEN];
- FILE *procfile;
- int retval;
- int have_state;
-
- xsnprintf (buffer, sizeof (buffer), "/proc/%ld/status", lwp);
- procfile = fopen (buffer, "r");
- if (procfile == NULL)
- {
- warning (_("unable to open /proc file '%s'"), buffer);
- return 0;
- }
-
- have_state = 0;
- while (fgets (buffer, sizeof (buffer), procfile) != NULL)
- if (strncmp (buffer, "State:", 6) == 0)
- {
- have_state = 1;
- break;
- }
- retval = (have_state
- && strcmp (buffer, "State:\tZ (zombie)\n") == 0);
- fclose (procfile);
- return retval;
-}
-
/* Wait for LP to stop. Returns the wait status, or 0 if the LWP has
exited. */
@@ -2548,10 +2517,10 @@ wait_lwp (struct lwp_info *lp)
This is racy, what if the tgl becomes a zombie right after we check?
Therefore always use WNOHANG with sigsuspend - it is equivalent to
- waiting waitpid but the linux_lwp_is_zombie is safe this way. */
+ waiting waitpid but linux_proc_pid_is_zombie is safe this way. */
if (GET_PID (lp->ptid) == GET_LWP (lp->ptid)
- && linux_lwp_is_zombie (GET_LWP (lp->ptid)))
+ && linux_proc_pid_is_zombie (GET_LWP (lp->ptid)))
{
thread_dead = 1;
if (debug_linux_nat)
@@ -3431,7 +3400,7 @@ check_zombie_leaders (void)
/* Check if there are other threads in the group, as we may
have raced with the inferior simply exiting. */
&& num_lwps (inf->pid) > 1
- && linux_lwp_is_zombie (inf->pid))
+ && linux_proc_pid_is_zombie (inf->pid))
{
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,