From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46491 invoked by alias); 26 Nov 2015 02:53:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 46477 invoked by uid 89); 26 Nov 2015 02:53:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 26 Nov 2015 02:53:52 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 842793B712; Thu, 26 Nov 2015 02:53:50 +0000 (UTC) Received: from moya.redhat.com (ovpn-113-83.phx2.redhat.com [10.3.113.83]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAQ2rnFM010310; Wed, 25 Nov 2015 21:53:49 -0500 From: Josh Stone To: gdb-patches@sourceware.org Cc: philippe.waroquiers@skynet.be, sergiodj@redhat.com, palves@redhat.com, eliz@gnu.org, xdje42@gmail.com, Josh Stone Subject: [PATCH v2 1/2] gdbserver: Set Linux ptrace options ASAP Date: Thu, 26 Nov 2015 02:53:00 -0000 Message-Id: <1448506425-24691-1-git-send-email-jistone@redhat.com> In-Reply-To: <1446169946-28117-1-git-send-email-jistone@redhat.com> References: <1446169946-28117-1-git-send-email-jistone@redhat.com> X-SW-Source: 2015-11/txt/msg00536.txt.bz2 The ptrace options should be set as soon as we know a thread is stopped, so no events can be missed. There's an arch-setup early return that was effectively delaying this update before, and I found for instance that the first syscall event wouldn't be properly reported with TRACESYSGOOD. It's now more similar to the way that gdb/linux-nat.c handles it. gdb/gdbserver/ChangeLog: 2015-11-25 Josh Stone * linux-low.c (linux_low_filter_event): Set ptrace options as soon as each thread is stopped, even before arch-specific setup. --- gdb/gdbserver/linux-low.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index e3a56a7c1690..9f577aefee1b 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2249,6 +2249,16 @@ linux_low_filter_event (int lwpid, int wstat) gdb_assert (WIFSTOPPED (wstat)); + /* Set ptrace flags ASAP, so no events can be missed. */ + if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags) + { + struct process_info *proc = find_process_pid (pid_of (thread)); + int options = linux_low_ptrace_options (proc->attached); + + linux_enable_event_reporting (lwpid, options); + child->must_set_ptrace_flags = 0; + } + if (WIFSTOPPED (wstat)) { struct process_info *proc; @@ -2276,15 +2286,6 @@ linux_low_filter_event (int lwpid, int wstat) } } - if (WIFSTOPPED (wstat) && child->must_set_ptrace_flags) - { - struct process_info *proc = find_process_pid (pid_of (thread)); - int options = linux_low_ptrace_options (proc->attached); - - linux_enable_event_reporting (lwpid, options); - child->must_set_ptrace_flags = 0; - } - /* Be careful to not overwrite stop_pc until check_stopped_by_breakpoint is called. */ if (WIFSTOPPED (wstat) && WSTOPSIG (wstat) == SIGTRAP -- 2.5.0