From patchwork Fri May 22 18:55:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Breazeal X-Patchwork-Id: 6895 Received: (qmail 94162 invoked by alias); 22 May 2015 18:55:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 94095 invoked by uid 89); 22 May 2015 18:55:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 May 2015 18:55:54 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1Yvs6p-0003iV-I1 from Don_Breazeal@mentor.com for gdb-patches@sourceware.org; Fri, 22 May 2015 11:55:51 -0700 Received: from build4-lucid-cs (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.3.224.2; Fri, 22 May 2015 11:55:51 -0700 Received: by build4-lucid-cs (Postfix, from userid 1905) id 1982440E8F; Fri, 22 May 2015 11:55:51 -0700 (PDT) From: Don Breazeal To: Subject: [PATCH 2/3] Initialize last_resume_kind for remote fork child Date: Fri, 22 May 2015 11:55:30 -0700 Message-ID: <1432320931-1550-3-git-send-email-donb@codesourcery.com> In-Reply-To: <1432320931-1550-1-git-send-email-donb@codesourcery.com> References: <1432320931-1550-1-git-send-email-donb@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes This patch fixes some intermittent test failures in gdb.base/foll-vfork.exp where a vfork child could sometimes be (incorrectly) resumed when handling the vfork event. In this case the result was a subsequent event reported to the client side as a SIGTRAP delivered to the as-yet-unknown child thread. The fix is to initialize the threadinfo.last_resume_kind field for new fork children in gdbserver/linux-low.c:handle_extended_wait. This prevents the event handler from incorrectly resuming the child if the stop event that is generated when it starts is reported before the vfork event that initiated it. The same thing is done for the native case in linux-nat.c:linux_child_follow_fork. In addition, it seemed prudent to initialize lwp_info.status_pending_p for the new fork child. I also rearranged the initialization code so that all of the lwp_info initialization was together, rather than intermixed with thread_info and process_info initialization. Tested native, native-gdbserver, native-extended-gdbserver on x86_64 GNU/Linux. OK? Thanks --Don gdb/gdbserver/ 2015-05-22 Don Breazeal * linux-low.c (handle_extended_wait): --- gdb/gdbserver/linux-low.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 9f3ea48..d763c66 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -457,6 +457,7 @@ handle_extended_wait (struct lwp_info *event_lwp, int wstat) struct process_info *parent_proc; struct process_info *child_proc; struct lwp_info *child_lwp; + struct thread_info *child_thr; struct target_desc *tdesc; ptid = ptid_build (new_pid, new_pid, 0); @@ -479,6 +480,10 @@ handle_extended_wait (struct lwp_info *event_lwp, int wstat) child_lwp = add_lwp (ptid); gdb_assert (child_lwp != NULL); child_lwp->stopped = 1; + child_lwp->must_set_ptrace_flags = 1; + child_lwp->status_pending_p = 0; + child_thr = get_lwp_thread (child_lwp); + child_thr->last_resume_kind = resume_stop; parent_proc = get_thread_process (event_thr); child_proc->attached = parent_proc->attached; clone_all_breakpoints (&child_proc->breakpoints, @@ -488,7 +493,6 @@ handle_extended_wait (struct lwp_info *event_lwp, int wstat) tdesc = xmalloc (sizeof (struct target_desc)); copy_target_description (tdesc, parent_proc->tdesc); child_proc->tdesc = tdesc; - child_lwp->must_set_ptrace_flags = 1; /* Clone arch-specific process data. */ if (the_low_target.new_fork != NULL)