Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Paul N. Hilfinger" <hilfingr@otisco.mckusick.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] lin-lwp.c change to avoid obscure hanging
Date: Sat, 13 Apr 2002 02:05:00 -0000	[thread overview]
Message-ID: <200204130905.CAA11202@otisco.McKusick.COM> (raw)
In-Reply-To: <200204121931.g3CJVae12068@reddwarf.sfbay.redhat.com>


Under certain obscure conditions, GDB will hang when continuing a program
that uses GNU/Linux LWPs.  For example, one set of circumstances that
were uncovered in an Ada program were:

1. A breakpoint is tripped over in thread A.

2. When all threads are stopped, it turns out that thread B != A has received
   a signal (specifically SIG32, which is apparently used by the thread
   package).  This signal, furthermore, is "not of interest" to GDB
   (as if according to 'set handle SIG32 pass noprint nostop').
   A and B here stand for integer literals, of course.

3. The user executes the commands
     delete
     thread B
     continue     

I am uncertain as to the proper fix is for this, but I have provided
one possibility below (that works for us).  The long ugly comment
will, I hope, prompt the more experienced among you to resolve the
outstanding questions.

Paul Hilfinger
ACT, Inc.



2002-04-10  Paul N. Hilfinger  <hilfingr@otisco.mckusick.com>

	* lin-lwp.c (lin_lwp_resume): Pass unprocessed signals to the 
	selected lwp, if GDB is not interested in them, and no specific
	signal is requested.  Fixes regression (hanging) displayed by 
	9820-005__task_switch.


Index: gdb/lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.34
diff -u -p -r1.34 lin-lwp.c
--- gdb/lin-lwp.c	31 Mar 2002 15:10:38 -0000	1.34
+++ gdb/lin-lwp.c	13 Apr 2002 08:41:20 -0000
@@ -605,6 +605,32 @@ lin_lwp_resume (ptid_t ptid, int step, e
       /* Mark this LWP as resumed.  */
       lp->resumed = 1;
 
+      if (WIFSTOPPED (lp->status))
+	{
+	  enum target_signal stopsig 
+	    = target_signal_from_host (WSTOPSIG (lp->status));
+
+	  /* If we have a signal GDB is not interested in, then
+	     arrange to pass it to the process without comment.  This
+	     should be able to happen only when one changes threads 
+	     before continuing.  To be conservative, we do this only
+	     if signo is TARGET_SIGNAL_0.  
+	     FIXME: hilfinger/2002-04-10: But this means we can't
+	     switch to this thread and clear its signal.  We could try
+	     simply not resuming when lp->status is non-zero, and
+	     leave it to lin_lwp_wait to catch the unhandled signal,
+	     but it will resume ONLY this thread (see Kettenis's FIXME
+	     in lin_lwp_wait), and this is not always right. */
+
+	  if (signo == TARGET_SIGNAL_0 
+	      && signal_stop_state (stopsig) == 0
+	      && signal_print_state (stopsig) == 0
+	      && signal_pass_state (stopsig) == 1)
+	    {
+	      signo = stopsig;
+	      lp->status = 0;
+	    }
+	}
       /* If we have a pending wait status for this thread, there is no
          point in resuming the process.  */
       if (lp->status)


  reply	other threads:[~2002-04-13  9:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-12 12:43 [RFA] Change to parse error reporting Michael Snyder
2002-04-13  2:05 ` Paul N. Hilfinger [this message]
2002-04-15 18:10   ` [RFA] lin-lwp.c change to avoid obscure hanging Michael Snyder
2002-04-17  2:52     ` Paul N. Hilfinger
2002-04-19 11:53       ` Michael Snyder
2002-04-19 11:54 ` [RFA] Change to parse error reporting Michael Snyder
2002-04-24 15:23   ` Michael Snyder

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=200204130905.CAA11202@otisco.McKusick.COM \
    --to=hilfingr@otisco.mckusick.com \
    --cc=Hilfinger@otisco.mckusick.com \
    --cc=gdb-patches@sources.redhat.com \
    /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