From patchwork Tue Jun 28 23:00:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 13460 Received: (qmail 102042 invoked by alias); 28 Jun 2016 23:00:49 -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 100838 invoked by uid 89); 28 Jun 2016 23:00:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=suspend, traced, HX-Greylist:EDT, HX-Greylist:0400 X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 28 Jun 2016 23:00:34 +0000 Received: from ralph.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id CBEFEB96C for ; Tue, 28 Jun 2016 19:00:31 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH 2/3] Move fbsd_resume and related functions below fork following helper code. Date: Tue, 28 Jun 2016 16:00:10 -0700 Message-Id: <20160628230011.80849-3-jhb@FreeBSD.org> In-Reply-To: <20160628230011.80849-1-jhb@FreeBSD.org> References: <20160628230011.80849-1-jhb@FreeBSD.org> X-IsSubscribed: yes gdb/ChangeLog: * fbsd-nat.c (super_resume): Move earlier next to "super_wait". (resume_one_thread_cb): Move below fork following helper code. (resume_all_threads_cb): Likewise. (fbsd_resume): Likewise. --- gdb/ChangeLog | 7 ++++ gdb/fbsd-nat.c | 127 ++++++++++++++++++++++++++++----------------------------- 2 files changed, 70 insertions(+), 64 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1c90732..09b75a5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2016-06-24 John Baldwin + * fbsd-nat.c (super_resume): Move earlier next to "super_wait". + (resume_one_thread_cb): Move below fork following helper code. + (resume_all_threads_cb): Likewise. + (fbsd_resume): Likewise. + +2016-06-24 John Baldwin + * fbsd-nat.c (fbsd_follow_fork): Only detach child if "detach_fork" is true. diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 0f375f5..4b2b41a 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -281,6 +281,10 @@ fbsd_xfer_partial (struct target_ops *ops, enum target_object object, #ifdef PT_LWPINFO static int debug_fbsd_lwp; +static void (*super_resume) (struct target_ops *, + ptid_t, + int, + enum gdb_signal); static ptid_t (*super_wait) (struct target_ops *, ptid_t, struct target_waitstatus *, @@ -492,70 +496,6 @@ fbsd_update_thread_list (struct target_ops *ops) #endif } -static void (*super_resume) (struct target_ops *, - ptid_t, - int, - enum gdb_signal); - -static int -resume_one_thread_cb (struct thread_info *tp, void *data) -{ - ptid_t *ptid = (ptid_t *) data; - int request; - - if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid)) - return 0; - - if (ptid_get_lwp (tp->ptid) == ptid_get_lwp (*ptid)) - request = PT_RESUME; - else - request = PT_SUSPEND; - - if (ptrace (request, ptid_get_lwp (tp->ptid), NULL, 0) == -1) - perror_with_name (("ptrace")); - return 0; -} - -static int -resume_all_threads_cb (struct thread_info *tp, void *data) -{ - ptid_t *filter = (ptid_t *) data; - - if (!ptid_match (tp->ptid, *filter)) - return 0; - - if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1) - perror_with_name (("ptrace")); - return 0; -} - -/* Implement the "to_resume" target_ops method. */ - -static void -fbsd_resume (struct target_ops *ops, - ptid_t ptid, int step, enum gdb_signal signo) -{ - - if (debug_fbsd_lwp) - fprintf_unfiltered (gdb_stdlog, - "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n", - ptid_get_pid (ptid), ptid_get_lwp (ptid), - ptid_get_tid (ptid)); - if (ptid_lwp_p (ptid)) - { - /* If ptid is a specific LWP, suspend all other LWPs in the process. */ - iterate_over_threads (resume_one_thread_cb, &ptid); - } - else - { - /* If ptid is a wildcard, resume all matching threads (they won't run - until the process is continued however). */ - iterate_over_threads (resume_all_threads_cb, &ptid); - ptid = inferior_ptid; - } - super_resume (ops, ptid, step, signo); -} - #ifdef TDP_RFPPWAIT /* To catch fork events, PT_FOLLOW_FORK is set on every traced process @@ -638,6 +578,65 @@ fbsd_is_child_pending (pid_t pid) } #endif +static int +resume_one_thread_cb (struct thread_info *tp, void *data) +{ + ptid_t *ptid = (ptid_t *) data; + int request; + + if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid)) + return 0; + + if (ptid_get_lwp (tp->ptid) == ptid_get_lwp (*ptid)) + request = PT_RESUME; + else + request = PT_SUSPEND; + + if (ptrace (request, ptid_get_lwp (tp->ptid), NULL, 0) == -1) + perror_with_name (("ptrace")); + return 0; +} + +static int +resume_all_threads_cb (struct thread_info *tp, void *data) +{ + ptid_t *filter = (ptid_t *) data; + + if (!ptid_match (tp->ptid, *filter)) + return 0; + + if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1) + perror_with_name (("ptrace")); + return 0; +} + +/* Implement the "to_resume" target_ops method. */ + +static void +fbsd_resume (struct target_ops *ops, + ptid_t ptid, int step, enum gdb_signal signo) +{ + + if (debug_fbsd_lwp) + fprintf_unfiltered (gdb_stdlog, + "FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n", + ptid_get_pid (ptid), ptid_get_lwp (ptid), + ptid_get_tid (ptid)); + if (ptid_lwp_p (ptid)) + { + /* If ptid is a specific LWP, suspend all other LWPs in the process. */ + iterate_over_threads (resume_one_thread_cb, &ptid); + } + else + { + /* If ptid is a wildcard, resume all matching threads (they won't run + until the process is continued however). */ + iterate_over_threads (resume_all_threads_cb, &ptid); + ptid = inferior_ptid; + } + super_resume (ops, ptid, step, signo); +} + /* Wait for the child specified by PTID to do something. Return the process ID of the child, or MINUS_ONE_PTID in case of error; store the status in *OURSTATUS. */