This is the mail archive of the gdb-patches@sources.redhat.com 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]

[PATCH RFA] Clean up spurious SIGSTOPS in lin-lwp


Mark, 

This patch will get rid of most of those "Delayed SIGSTOP" messages, 
so that lin_lwp_wait will rarely if ever get a SIGSTOP that was generated
by gdb.  It entails three basic changes:

 * In lin_lwp_attach_lwp, consume the SIGSTOP that is generated by
   PTHREAD_ATTACH.
 * In stop_wait_callback, try again to consume the SIGSTOP after
   "pushing back" a SIGTRAP for a thread other than the event thread.
 * Similarly try again to consume a SIGSTOP after tossing away a
   redundant SIGINT.

Michael
2001-05-25  Michael Snyder  <msnyder@redhat.com>

	* lin-lwp.c (lin_lwp_attach_lwp): Call stop_wait_callback,
	to consume the SIGSTOP generated by PTRACE_ATTACH.
	(stop_wait_callback): If a SIGTRAP or a SIGINT event is consumed,
	try again to get the SIGSTOP event.
	(lin_lwp_wait): Resume all threads when ignoring a signal.
	This will insure that newly attached threads get resumed.

*** lin-lwp.sigint.c	Fri May 25 15:23:46 2001
--- lin-lwp.c	Fri May 25 15:26:52 2001
*************** lin_lwp_attach_lwp (ptid_t ptid, int ver
*** 327,333 ****
      lp = add_lwp (ptid);
  
    if (is_cloned (ptid))
!     lp->signalled = 1;
  }
  
  static void
--- 327,336 ----
      lp = add_lwp (ptid);
  
    if (is_cloned (ptid))
!     {
!       lp->signalled = 1;
!       stop_wait_callback (lp, NULL);
!     }
  }
  
  static void
*************** stop_callback (struct lwp_info *lp, void
*** 539,544 ****
--- 542,548 ----
  static int
  stop_wait_callback (struct lwp_info *lp, void *data)
  {
+  get_another_event:
    if (! lp->stopped && lp->signalled)
      {
        pid_t pid;
*************** stop_wait_callback (struct lwp_info *lp,
*** 609,614 ****
--- 613,624 ----
  		write_pc_pid (read_pc_pid (pid_to_ptid (pid)) 
  		                - DECR_PC_AFTER_BREAK,
  			      pid_to_ptid (pid));
+ 
+ 	      /* Now resume this LWP and get the SIGSTOP event. */
+ 	      lp->stopped = 1;
+ 	      lp->step = 0;
+ 	      resume_callback (lp, NULL);
+ 	      goto get_another_event;
  	    }
  	  else if (WSTOPSIG (status) == SIGINT)
  	    {
*************** stop_wait_callback (struct lwp_info *lp,
*** 616,622 ****
  		 (in the case where ^C/BREAK is typed at the tty/console),
  		 just ignore all SIGINT events from all lwp's except for
  		 the one that was caught by lin_lwp_wait.  */
! 	      ;  /* Don't save.  Signal will disappear into oblivion. */
  	    }
  	  else
  	    {
--- 626,637 ----
  		 (in the case where ^C/BREAK is typed at the tty/console),
  		 just ignore all SIGINT events from all lwp's except for
  		 the one that was caught by lin_lwp_wait.  */
! 
! 	      /* Now resume this LWP and get the SIGSTP event. */
! 	      lp->stopped = 1;
! 	      lp->step = 0;
! 	      resume_callback (lp, NULL);
! 	      goto get_another_event;
  	    }
  	  else
  	    {
*************** lin_lwp_wait (ptid_t ptid, struct target
*** 867,874 ****
  	  && signal_print_state (signo) == 0
  	  && signal_pass_state (signo) == 1)
  	{
- 	  child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo);
  	  lp->stopped = 0;
  	  status = 0;
  	  goto retry;
  	}
--- 882,893 ----
  	  && signal_print_state (signo) == 0
  	  && signal_pass_state (signo) == 1)
  	{
  	  lp->stopped = 0;
+ 	  /* Resume all threads except this one
+ 	     (mainly to get the newly attached ones). */
+ 	  iterate_over_lwps (resume_callback, NULL);
+ 	  /* Now resume this thread, forwarding the signal to it. */
+ 	  child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo);
  	  status = 0;
  	  goto retry;
  	}

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