Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb@sourceware.org
Cc: Brian Heilig <bheilig@etinternational.com>
Subject: Re: Porting gdb to Cyclops64
Date: Thu, 05 Aug 2010 14:19:00 -0000	[thread overview]
Message-ID: <201008051519.39349.pedro@codesourcery.com> (raw)
In-Reply-To: <1281016608.1560.79.camel@random>

On Thursday 05 August 2010 14:56:48, Brian Heilig wrote:

> In my previous message I described a problem I encountered while
> stepping a multi-threaded program. Here is a general description of
> what's happening.
> 
> All threads execute in parallel (on their own core) on the Cyclops64
> chip. I implemented a queue on the gdb server to serialize events. This
> makes Cyclops64 look like a cooperatively scheduled architecture to gdb
> in stop mode.
> 
> While single stepping a single thread (let's call it thread 5) gdb
> decided to set a breakpoint at some address and continue all threads.
> All threads hit this internal breakpoint including thread 5. The
> breakpoint events for threads 1-4 are reported and ignored by gdb (gdb
> knows it doesn't care about these threads). Then thread 5 is reported
> and gdb removes the breakpoint. However the event for threads 6-n are
> still in the queue. The next time the user continues these events are
> reported. Since gdb removed the internal breakpoint it assumes these
> events must be caused by something else and doesn't filter them out.
> 
> Is there anything I can do about this?

Yes.  I'll suggest two alternatives.

 #1 - before reporting a delayed/queued breakpoint hit event, check
   whether there's still a breakpoint still inserted where the
   thread is stopped.  If there isn't, then just resume the thread
   without telling gdb about the stop.

 #2 - don't leave breakpoint hit events queued (all other events, yes,
   leave them).  When you've stopped all threads to report a breakpoint
   hit to gdb, go through all threads, and those that have stopped
   due to a breakpoint, simply forget their breakpoint hits.  The
   next time gdb resumes those threads, they'll immediately hit
   the same breakpoint again.  You'll most likely want to
   add a bit of randomness to which of the threads amongs those
   that have hit a breakpoint you're going to report to gdb.

#2 is what both native linux gdb and linux gdbserver implement
nowadays.  gdbserver used to implement #1 until recently.
#1 has the advantage that it's a bit more efficient since it
avoids resuming the target when not strictly necessary.  The
disadvantage is that it makes managing the PC adjustment after
breakpoint traps more complicated.  E.g., the stub needs extra
care to present to GDB already adjusted PCs for all those
threads that still have pending breakpoint hits to report to gdb
in the event queue, but, to unadjust them when finally report
the queued breakpoint hit, so that gdb itself does the necessary
adjustment.  This may not be a concern on Cyclops64, I don't know.

> Is there a facility to set a
> breakpoint for a single thread and filter them on the server? 

Nope, it's one of those IWBN things that nobody ever got around to
working on, AFAIK.

> Or is this
> just a consequence of gdb not knowing how to deal with an SPMD
> architecture yet?

Nope.

-- 
Pedro Alves


  reply	other threads:[~2010-08-05 14:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-30 17:13 Brian Heilig
2010-07-30 17:26 ` Michael Snyder
2010-07-30 18:53   ` Brian Heilig
2010-07-30 18:57     ` Michael Snyder
2010-07-30 20:28       ` Brian Heilig
2010-07-30 22:54         ` Michael Snyder
2010-07-30 23:18         ` Pedro Alves
2010-08-02 13:25           ` Brian Heilig
2010-08-02 13:35             ` Pedro Alves
2010-08-03 16:52               ` Brian Heilig
2010-08-05 13:56               ` Brian Heilig
2010-08-05 14:19                 ` Pedro Alves [this message]
2010-08-06 18:39                   ` Problems with non-stop - " Brian Heilig
2010-08-30 19:44                   ` Cyclops64 Multi-Process Brian Heilig

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=201008051519.39349.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=bheilig@etinternational.com \
    --cc=gdb@sourceware.org \
    /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