Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA] Fix hand called function when another thread has hit a bp.
Date: Sun, 14 Dec 2008 22:00:00 -0000	[thread overview]
Message-ID: <e394668d0812141359x30734dfdxab254c5a2b58060f@mail.gmail.com> (raw)
In-Reply-To: <e394668d0812020340j228bfa2eia22ed846ea82a2c7@mail.gmail.com>

Ping.

On Tue, Dec 2, 2008 at 3:40 AM, Doug Evans <dje@google.com> wrote:
> On Mon, Dec 1, 2008 at 7:46 PM, Doug Evans <dje@google.com> wrote:
>> On Mon, Dec 1, 2008 at 7:00 PM, Doug Evans <dje@google.com> wrote:
>>> Hi.  In http://sourceware.org/ml/gdb-patches/2008-11/msg00531.html
>>> I wrote:
>>>
>>>> I wrote a testcase that calls functions in multiple threads (with
>>>> scheduler-locking on) by setting a breakpoint on the function being
>>>> called.  I think there's a bug in scheduler-locking support as when I
>>>> make the second call in the second thread, gdb makes the first thread
>>>> step over the breakpoint and then resume, and control returns to
>>>> call_function_by_hand with inferior_ptid changed to the first thread.
>>>
>>> Here's a patch.
>>> This is separate from my dummy-frames cleanup patch.
>>>
>>> Ok to check in?
>>
>> Except of course nothing is ever this easy. :-(
>>
>> My testcase isn't complete:
>>
>> set scheduler-locking off
>> continue
>>
>> Adding the above to the end of the testcase reveals the fact that this
>> patch causes gdb to lose track of the fact that it needs to single
>> step over the breakpoint at all_threads_running in the main thread,
>> and resuming execution causes the breakpoint to be hit again.  Global
>> state, gotta love it.
>>
>> I'm assuming non-stop mode doesn't have this problem.
>> Can we record in struct thread_info (or some such) the last stop
>> reason and before resuming with !scheduler-locking iterate over all
>> threads, single stepping them as necessary?  Is there a better
>> solution?
>
> This patch fixes the expanded hand-call-in-threads.exp testcase (which
> is part of the patch).  In the process I discovered a bigger problem -
> gdb doesn't handle resuming after more than one thread is stopped at a
> breakpoint.  This can happen if the user runs several threads in turn
> with scheduler-locking on, and then turns scheduler-locking off and
> resumes the program.  I wrote another testcase,
> multi-bp-in-threads.exp, to expose this issue.  Fixing this appears to
> be a much harder problem, and I think I'd like to declare partial
> victory with this patch ...
>
> Comments?
>
> I have some questions.  Is it sufficient to test "thread->stop_signal
> == TRAP && breakpoint_here_p (pc)" to check if a thread is stopped at
> a breakpoint?  It seems to be.
>
> Another thing this revised patch does is stop SIGTRAP from being
> passed to the current thread to be run if it was received in the last
> thread that ran.  The comments say this is how gdb behaved before
> stop_signal was recorded for each thread.  It seems odd though.  If an
> asynchronous signal comes in and it is masked in some threads, if the
> kernel chooses a thread in which it's not blocked, should gdb be
> changing the thread that receives the signal?
> This patch takes a minimalist approach and only changes the behaviour
> of SIGTRAP.
>
> 2008-12-02  Doug Evans  <dje@google.com>
>
>        * infrun.c (prepare_to_proceed_callback): New function.
>        (prepare_to_proceed): Document.  Assert !non_stop.  Add debugging
>        printf.  If scheduler-locking is enabled, no other thread need to
>        be singlestepped.  Otherwise scan all threads for whether they're
>        stopped at a breakpoint instead of just the last thread that ran.
>        (proceed): Add FIXME.  Don't pass on TARGET_SIGNAL_TRAP from the
>        last thread that ran to the current thread to run.
>
>        * gdb.threads/hand-call-in-threads.exp: New file.
>        * gdb.threads/hand-call-in-threads.c: New file.
>        * gdb.threads/multi-bp-in-threads.exp: New file.
>        * gdb.threads/multi-bp-in-threads.c: New file.
>


  reply	other threads:[~2008-12-14 22:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-02  3:01 Doug Evans
2008-12-02  3:48 ` Doug Evans
2008-12-02 11:41   ` Doug Evans
2008-12-14 22:00     ` Doug Evans [this message]
2008-12-14 22:14       ` Ulrich Weigand
2008-12-15 22:07         ` Doug Evans
2008-12-15 22:50           ` Ulrich Weigand
2008-12-15 23:15             ` Doug Evans
2008-12-17 19:14               ` Ulrich Weigand
2009-02-24 10:42                 ` Doug Evans
2009-03-13 17:06                   ` Doug Evans
2009-03-29 13:36                     ` Doug Evans
2009-03-30 18:48                   ` Ulrich Weigand
2009-04-03 23:25                     ` Doug Evans

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=e394668d0812141359x30734dfdxab254c5a2b58060f@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb-patches@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