Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: jjohnstn <jjohnstn@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFC]: Ugly thread step situation
Date: Tue, 14 Sep 2004 23:25:00 -0000	[thread overview]
Message-ID: <20040914232505.GA16818@nevyn.them.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0409141729550.8039-200000@tooth.toronto.redhat.com>

On Tue, Sep 14, 2004 at 05:44:47PM -0400, jjohnstn wrote:
> I recently tracked down a problem with gdb on RHEL3 Linux regarding 
> stepping threads.  What happens is that in some instances, lin-lwp.c is 
> asked to step the thread of interest.  We then wait on all threads.  Due 
> to some form of race condition, the wait does not get back the trap from 
> the stepped thread.  If we have a number of waiting events (e.g. thread 
> create events, other breakpoints), lin-lwp picks one of them.

Could you explain this bit a little more?  What comes back instead for
the thread that was stepping?  Do we stop it with a SIGSTOP?

Is there a testcase?

> Now it gets interesting.  Infrun.c thinks the current thread is being 
> stepped and isn't ready for a breakpoint coming back.  On x86, it makes a 
> miscalculation of the pc value (for a breakpoint it should back up 1, for 
> a step it doesn't have to).  We end up pointing at an invalid pc (we 
> didn't back up 1) and everything falls apart from there.
> 
> To fix this quickly, I added the accompanying patch to lin-lwp.c.  What it 
> does is ensure that we wait on any currently stepping lwp.  In truth, this 
> isn't as bad as it sounds.  The lin-lwp code later on is set up to pick 
> the stepping lwp over all other events.  This just keeps the scenario 
> above from occurring.
> 
> Obviously, this doesn't solve everything.  Perhaps the decrement of the pc 
> needs to be done once we have established whether the thread has changed 
> underneath us.  We also could use a hook to run the lwp list and find out 
> if the current lwp was stepping or encountered a breakpoint.
> 
> Anyway, if the consensus is that the patch is helpful in the short-term, I 
> am more than happy to check it in.
> 
> -- Jeff J.
> 
> 2004-09-14  Jeff Johnston  <jjohnstn@redhat.com>
> 
> 	* lin-lwp.c (find_singlestep_lwp_callback): New static function.
> 	(lin_lwp_wait): Change code to specifically wait on any LWP
> 	that is currently stepping.

This sounds sort of like a problem I debugged on MIPS and hppa, but
never managed to reproduce.  I had tabled the patch until I had more
time to look at it - always a mistake.

The same patch may help here.  Could you tell me what resume_ptid is
before the call to target_resume, in resume?  The call in which we
request the single-step, I mean.


-- 
Daniel Jacobowitz


  parent reply	other threads:[~2004-09-14 23:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-14 21:44 jjohnstn
2004-09-14 22:42 ` Andrew Cagney
2004-09-14 23:25 ` Daniel Jacobowitz [this message]
2004-09-15 17:36   ` Jeff Johnston
2004-09-15 17:53     ` Andrew Cagney
2004-09-15 17:59       ` Jeff Johnston
2004-09-15 18:21     ` Daniel Jacobowitz

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=20040914232505.GA16818@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jjohnstn@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