Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org
Subject: [commit, gdbserver] Fix SPU gdbserver regression
Date: Sun, 27 Sep 2009 20:57:00 -0000	[thread overview]
Message-ID: <200909272056.n8RKuxMM011923@d12av02.megacenter.de.ibm.com> (raw)

Hello,

several gdbserver test cases were failing on spu-elf.  This turned out
to be caused by the multi-process gdbserver changes.  In particular,
gdbserver now always keeps a list a threads, even for a single-threaded
inferior.  spu-low.c fails to clear this thread list in the spu_kill
and spu_detach routines, causing GDB to report that the inferior was
still running even when killed.

While debugging this, I noticed that gdbserver leaves the inferior
as zombie after spu_kill, because it never waits on it.  The patch
below fixes this issue as well.

Tested on spu-elf, fixes all gdbserver test case failures.
Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* spu-low.c (spu_kill): Wait for inferior to terminate.
	Call clear_inferiors.
	(spu_detach): Call clear_inferiors.


Index: gdb/gdbserver/spu-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/spu-low.c,v
retrieving revision 1.25
diff -c -p -r1.25 spu-low.c
*** gdb/gdbserver/spu-low.c	22 Jun 2009 19:33:41 -0000	1.25
--- gdb/gdbserver/spu-low.c	25 Sep 2009 14:43:07 -0000
*************** spu_attach (unsigned long  pid)
*** 321,331 ****
--- 321,340 ----
  static int
  spu_kill (int pid)
  {
+   int status, ret;
    struct process_info *process = find_process_pid (pid);
    if (process == NULL)
      return -1;
  
    ptrace (PTRACE_KILL, pid, 0, 0);
+ 
+   do {
+     ret = waitpid (pid, &status, 0);
+     if (WIFEXITED (status) || WIFSIGNALED (status))
+       break;
+   } while (ret != -1 || errno != ECHILD);
+ 
+   clear_inferiors ();
    remove_process (process);
    return 0;
  }
*************** spu_detach (int pid)
*** 339,344 ****
--- 348,355 ----
      return -1;
  
    ptrace (PTRACE_DETACH, pid, 0, 0);
+ 
+   clear_inferiors ();
    remove_process (process);
    return 0;
  }
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


             reply	other threads:[~2009-09-27 20:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-27 20:57 Ulrich Weigand [this message]
2009-09-28 18:07 ` Joel Brobecker
2009-09-28 19:15   ` Pedro Alves
2009-09-29  0:43     ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200909272056.n8RKuxMM011923@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox