This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] gdbserver: keep event_child and current_inferior in sync
- From: Pedro Alves <palves at redhat dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 05 Feb 2014 23:16:02 +0000
- Subject: Re: [PATCH] gdbserver: keep event_child and current_inferior in sync
- Authentication-results: sourceware.org; auth=none
- References: <yjt2zjmhchyv dot fsf at ruffy dot mtv dot corp dot google dot com>
On 01/27/2014 08:01 PM, Doug Evans wrote:
> Hi.
>
> I ran into this while debugging some testsuite failures in my rewrite
> of speeding up gdbserver attach.
>
> linux_wait_1 calls linux_wait_for_event, and one of the things
> linux_wait_for_event does is set current_inferior (blech, but
> a cleanup for another day).
>
> linux_wait_1 then sets event_child to the "lwp" part of current_inferior here:
>
> event_child = get_thread_lwp (current_inferior);
>
> and assumes the two remain in sync.
>
> However later it calls select_event_lwp to pick an event to report back:
>
> select_event_lwp (&event_child);
>
> but doesn't update current_inferior. Later code then does:
>
> if (current_inferior->last_resume_kind == resume_stop
> && WSTOPSIG (w) == SIGSTOP)
>
> which can use a stale current_inferior.
>
> In my patch to speed up attach I see the bug more easily because
> I changed the end of the function to be (effectively):
>
> - return ptid_of (event_child);
> + return current_inferior->entry.id;
>
> FAIL: gdb.threads/watchthreads.exp: threaded watch loop
> FAIL: gdb.threads/watchthreads.exp: combination of threaded watchpoints = 30
>
> The test fails because a h/w watchpoint is missed, and that happens
> because linux_wait_1 reports the wrong thread.
>
> 2014-01-27 Doug Evans <dje@google.com>
>
> * linux-low.c (linux_wait_for_event): Improve comment.
> (linux_wait_1): Keep current_inferior in sync with event_child.
OK, thanks!
--
Pedro Alves