diff options
-rw-r--r-- | gdb/ChangeLog | 27 | ||||
-rw-r--r-- | gdb/Makefile.in | 4 | ||||
-rw-r--r-- | gdb/common/linux-procfs.c | 31 | ||||
-rw-r--r-- | gdb/common/linux-procfs.h | 4 | ||||
-rw-r--r-- | gdb/common/linux-ptrace.c | 26 | ||||
-rw-r--r-- | gdb/config/alpha/alpha-linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/arm/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/i386/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/i386/linux64.mh | 2 | ||||
-rw-r--r-- | gdb/config/ia64/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/m32r/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/m68k/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/mips/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/pa/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/powerpc/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/powerpc/ppc64-linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/powerpc/spu-linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/s390/s390.mh | 2 | ||||
-rw-r--r-- | gdb/config/sparc/linux.mh | 2 | ||||
-rw-r--r-- | gdb/config/sparc/linux64.mh | 2 | ||||
-rw-r--r-- | gdb/config/xtensa/linux.mh | 2 | ||||
-rw-r--r-- | gdb/gdbserver/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/gdbserver/Makefile.in | 3 | ||||
-rw-r--r-- | gdb/gdbserver/configure.srv | 17 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 8 | ||||
-rw-r--r-- | gdb/linux-nat.c | 37 |
26 files changed, 146 insertions, 54 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c422451..f7f564c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,30 @@ +2012-03-13 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. + 2012-03-13 Hui Zhu <teawater@gmail.com> Pedro Alves <palves@redhat.com> diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 84eda7d..4d85662 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1929,6 +1929,10 @@ linux-procfs.o: $(srcdir)/common/linux-procfs.c $(COMPILE) $(srcdir)/common/linux-procfs.c $(POSTCOMPILE) +linux-ptrace.o: $(srcdir)/common/linux-ptrace.c + $(COMPILE) $(srcdir)/common/linux-ptrace.c + $(POSTCOMPILE) + common-agent.o: $(srcdir)/common/agent.c $(COMPILE) $(srcdir)/common/agent.c $(POSTCOMPILE) diff --git a/gdb/common/linux-procfs.c b/gdb/common/linux-procfs.c index 165383e..b7d98a5 100644 --- a/gdb/common/linux-procfs.c +++ b/gdb/common/linux-procfs.c @@ -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; +} diff --git a/gdb/common/linux-procfs.h b/gdb/common/linux-procfs.h index c1e5547..130adeb 100644 --- a/gdb/common/linux-procfs.h +++ b/gdb/common/linux-procfs.h @@ -31,4 +31,8 @@ extern int linux_proc_get_tgid (int lwpid); 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 */ diff --git a/gdb/common/linux-ptrace.c b/gdb/common/linux-ptrace.c new file mode 100644 index 0000000..6dea677 --- /dev/null +++ b/gdb/common/linux-ptrace.c @@ -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" diff --git a/gdb/config/alpha/alpha-linux.mh b/gdb/config/alpha/alpha-linux.mh index 15dc989..9eb9e4b 100644 --- a/gdb/config/alpha/alpha-linux.mh +++ b/gdb/config/alpha/alpha-linux.mh @@ -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 diff --git a/gdb/config/arm/linux.mh b/gdb/config/arm/linux.mh index 78918d2..c0a1c66 100644 --- a/gdb/config/arm/linux.mh +++ b/gdb/config/arm/linux.mh @@ -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) diff --git a/gdb/config/i386/linux.mh b/gdb/config/i386/linux.mh index 3a158c6..8316d87 100644 --- a/gdb/config/i386/linux.mh +++ b/gdb/config/i386/linux.mh @@ -4,7 +4,7 @@ NAT_FILE= config/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 diff --git a/gdb/config/i386/linux64.mh b/gdb/config/i386/linux64.mh index a5e8c14..d2b95fd 100644 --- a/gdb/config/i386/linux64.mh +++ b/gdb/config/i386/linux64.mh @@ -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= config/nm-linux.h NAT_CDEPS = $(srcdir)/proc-service.list diff --git a/gdb/config/ia64/linux.mh b/gdb/config/ia64/linux.mh index c72929c..1a4c68e 100644 --- a/gdb/config/ia64/linux.mh +++ b/gdb/config/ia64/linux.mh @@ -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) diff --git a/gdb/config/m32r/linux.mh b/gdb/config/m32r/linux.mh index 32a4428..b461806 100644 --- a/gdb/config/m32r/linux.mh +++ b/gdb/config/m32r/linux.mh @@ -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) diff --git a/gdb/config/m68k/linux.mh b/gdb/config/m68k/linux.mh index b116819..e3aaf38 100644 --- a/gdb/config/m68k/linux.mh +++ b/gdb/config/m68k/linux.mh @@ -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 diff --git a/gdb/config/mips/linux.mh b/gdb/config/mips/linux.mh index 1ef3bce..2f8e5dd 100644 --- a/gdb/config/mips/linux.mh +++ b/gdb/config/mips/linux.mh @@ -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) diff --git a/gdb/config/pa/linux.mh b/gdb/config/pa/linux.mh index e9b7114..fa46db6 100644 --- a/gdb/config/pa/linux.mh +++ b/gdb/config/pa/linux.mh @@ -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) diff --git a/gdb/config/powerpc/linux.mh b/gdb/config/powerpc/linux.mh index 0ae9368..b0d4ce7 100644 --- a/gdb/config/powerpc/linux.mh +++ b/gdb/config/powerpc/linux.mh @@ -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) diff --git a/gdb/config/powerpc/ppc64-linux.mh b/gdb/config/powerpc/ppc64-linux.mh index bf1bb5b..367a818 100644 --- a/gdb/config/powerpc/ppc64-linux.mh +++ b/gdb/config/powerpc/ppc64-linux.mh @@ -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 diff --git a/gdb/config/powerpc/spu-linux.mh b/gdb/config/powerpc/spu-linux.mh index f6e7396..1bc279a 100644 --- a/gdb/config/powerpc/spu-linux.mh +++ b/gdb/config/powerpc/spu-linux.mh @@ -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 diff --git a/gdb/config/s390/s390.mh b/gdb/config/s390/s390.mh index 44c7a9a..a53835c 100644 --- a/gdb/config/s390/s390.mh +++ b/gdb/config/s390/s390.mh @@ -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) diff --git a/gdb/config/sparc/linux.mh b/gdb/config/sparc/linux.mh index 25c4ad5..6a2cefd 100644 --- a/gdb/config/sparc/linux.mh +++ b/gdb/config/sparc/linux.mh @@ -4,7 +4,7 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat.o \ 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 diff --git a/gdb/config/sparc/linux64.mh b/gdb/config/sparc/linux64.mh index 363e19b..d1e1a97 100644 --- a/gdb/config/sparc/linux64.mh +++ b/gdb/config/sparc/linux64.mh @@ -5,7 +5,7 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.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 diff --git a/gdb/config/xtensa/linux.mh b/gdb/config/xtensa/linux.mh index c637ec7..deffe25 100644 --- a/gdb/config/xtensa/linux.mh +++ b/gdb/config/xtensa/linux.mh @@ -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) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 04c0709..726a6b4 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2012-03-13 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. + 2012-03-08 Yao Qi <yao@codesourcery.com> Pedro Alves <palves@redhat.com> diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index ce220cb..6d77ce2 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -415,6 +415,9 @@ signals.o: ../common/signals.c $(server_h) $(signals_def) 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 diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 3358c33..bdd9916 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -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,6 +155,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 @@ -156,6 +165,7 @@ case "${target}" in srv_regobj="${srv_regobj} mips64-linux.o" srv_regobj="${srv_regobj} mips64-dsp-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-dsp-linux.xml" srv_xmlfiles="${srv_xmlfiles} mips-cpu.xml" @@ -188,6 +198,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" @@ -230,6 +241,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" @@ -250,12 +262,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 ;; @@ -272,12 +286,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 @@ -292,6 +308,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." diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 997e5a0..06ec576 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -660,10 +660,10 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) 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) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index e3a5e9d..442d6f4 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2465,37 +2465,6 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, _("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. */ @@ -2549,10 +2518,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) @@ -3499,7 +3468,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, |