summaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-03-13 15:00:26 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-03-13 15:00:26 +0000
commite0df8b05e0c2b392c03ba8a8b0529d16d6e34b90 (patch)
tree23b8027dad9f4bfbb17f491f6149075560bb9847 /gdb/linux-nat.c
parent5dfd18a698f2086fa06e1634b226c89c1fa8493c (diff)
downloadgdb-e0df8b05e0c2b392c03ba8a8b0529d16d6e34b90.tar.gz
gdb/
* 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/ * 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.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r--gdb/linux-nat.c37
1 files changed, 3 insertions, 34 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index e3a5e9d973f..442d6f40a47 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,