* 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.
This commit is contained in:
Jan Kratochvil
2012-03-13 15:00:37 +00:00
parent 44f238bb63
commit 5f572decf9
26 changed files with 146 additions and 54 deletions

View File

@ -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,