This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit, gdbserver] Fix SPU gdbserver regression


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]