Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Two threads hitting the same break
@ 2010-03-18 19:27 Paul Koning
  2010-03-18 19:36 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Koning @ 2010-03-18 19:27 UTC (permalink / raw)
  To: gdb

Gentlepeople,

I'm running into a problem in trying to add threads support for NetBSD
to GDB.

The situation is a breakpoint set in a function that is called by
multiple threads.  One thread hits the break.  It gets the signal, the
process stops, GDB gets control, and sees what it expects.

I then tell GDB to continue.  It does a stepi, reinserts the break, and
lets the process go.  But the other thread has also hit the same
breakpoint.  That signal is delivered at the time I do the continue --
so at that point the break instruction isn't present.  The result is
that GDB sees this as a SIGTRAP at break address + 1 (this is on i386),
and when I continue I get a segfault because the thread is continued in
the middle of an instruction.

I think I've seen discussion of this sort of issue, possibly in the
code, but I'm not having much luck finding it.  Any suggestions for the
right way to handle this?

	paul


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Two threads hitting the same break
  2010-03-18 19:27 Two threads hitting the same break Paul Koning
@ 2010-03-18 19:36 ` Pedro Alves
  2010-03-18 20:02   ` Paul Koning
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2010-03-18 19:36 UTC (permalink / raw)
  To: gdb; +Cc: Paul Koning

On Thursday 18 March 2010 19:26:52, Paul Koning wrote:
> I think I've seen discussion of this sort of issue, possibly in the
> code, but I'm not having much luck finding it.  Any suggestions for the
> right way to handle this?

See linux-nat.c:cancel_breakpoint.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Two threads hitting the same break
  2010-03-18 19:36 ` Pedro Alves
@ 2010-03-18 20:02   ` Paul Koning
  2010-03-18 20:09     ` Paul Koning
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Koning @ 2010-03-18 20:02 UTC (permalink / raw)
  To: Pedro Alves, gdb

Thanks.

I'm not sure about using that model -- it doesn't behave in an intuitive
fashion.

If I have two threads that hit the same break at the same time, I would
expect to see both breaks.  The Linux code tosses one of them.  Given
how it picks threads to report, the next time the two threads hit a
break, the one that wasn't reported the first time will be reported this
time.  But the net result is that I only see a portion of the breaks --
half of them if there are two threads.

Consider a test case of the form
  - print something
  - wait a bit
  - repeat

If I set a break in that loop and keep hitting continue, I see one break
per pass through the loop even if there are two threads executing this
loop.  I'm not sure why the Linux folks chose to make it work that way;
I'm not sure I want to copy that behavior.

Then again, doing something more obvious might be hard...

	paul

> -----Original Message-----
> From: Pedro Alves [mailto:pedro@codesourcery.com]
> Sent: Thursday, March 18, 2010 3:36 PM
> To: gdb@sourceware.org
> Cc: Paul Koning
> Subject: Re: Two threads hitting the same break
> 
> On Thursday 18 March 2010 19:26:52, Paul Koning wrote:
> > I think I've seen discussion of this sort of issue, possibly in the
> > code, but I'm not having much luck finding it.  Any suggestions for
> the
> > right way to handle this?
> 
> See linux-nat.c:cancel_breakpoint.
> 
> --
> Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Two threads hitting the same break
  2010-03-18 20:02   ` Paul Koning
@ 2010-03-18 20:09     ` Paul Koning
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Koning @ 2010-03-18 20:09 UTC (permalink / raw)
  To: Pedro Alves, gdb

Never mind, I misread a test.  It looks like the Linux code does behave
the way I want.  Sorry for the confusion, and thanks for the help.

	paul

> -----Original Message-----
> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
> Behalf Of Paul Koning
> Sent: Thursday, March 18, 2010 4:02 PM
> To: Pedro Alves; gdb@sourceware.org
> Subject: RE: Two threads hitting the same break
> 
> Thanks.
> 
> I'm not sure about using that model -- it doesn't behave in an
> intuitive
> fashion.
> 
> If I have two threads that hit the same break at the same time, I
would
> expect to see both breaks.  The Linux code tosses one of them.  Given
> how it picks threads to report, the next time the two threads hit a
> break, the one that wasn't reported the first time will be reported
> this
> time.  But the net result is that I only see a portion of the breaks
--
> half of them if there are two threads.
> 
> Consider a test case of the form
>   - print something
>   - wait a bit
>   - repeat
> 
> If I set a break in that loop and keep hitting continue, I see one
> break
> per pass through the loop even if there are two threads executing this
> loop.  I'm not sure why the Linux folks chose to make it work that
way;
> I'm not sure I want to copy that behavior.
> 
> Then again, doing something more obvious might be hard...
> 
> 	paul
> 
> > -----Original Message-----
> > From: Pedro Alves [mailto:pedro@codesourcery.com]
> > Sent: Thursday, March 18, 2010 3:36 PM
> > To: gdb@sourceware.org
> > Cc: Paul Koning
> > Subject: Re: Two threads hitting the same break
> >
> > On Thursday 18 March 2010 19:26:52, Paul Koning wrote:
> > > I think I've seen discussion of this sort of issue, possibly in
the
> > > code, but I'm not having much luck finding it.  Any suggestions
for
> > the
> > > right way to handle this?
> >
> > See linux-nat.c:cancel_breakpoint.
> >
> > --
> > Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-18 20:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-18 19:27 Two threads hitting the same break Paul Koning
2010-03-18 19:36 ` Pedro Alves
2010-03-18 20:02   ` Paul Koning
2010-03-18 20:09     ` Paul Koning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox