From patchwork Fri Jul 26 12:50:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Franco de Carvalho X-Patchwork-Id: 33806 Received: (qmail 77416 invoked by alias); 26 Jul 2019 12:50:28 -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 77407 invoked by uid 89); 26 Jul 2019 12:50:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=pedro, H*Ad:D*de.ibm.com, HContent-Transfer-Encoding:8bit X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jul 2019 12:50:26 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6QCkw5v115986 for ; Fri, 26 Jul 2019 08:50:24 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2u006tdc7c-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Jul 2019 08:50:24 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Jul 2019 13:50:23 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Jul 2019 13:50:22 +0100 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6QCoJXB34734394 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Jul 2019 12:50:19 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B92EC6066; Fri, 26 Jul 2019 12:50:19 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BD81C6063; Fri, 26 Jul 2019 12:50:19 +0000 (GMT) Received: from pedro.localdomain (unknown [9.80.227.78]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Jul 2019 12:50:19 +0000 (GMT) Received: by pedro.localdomain (Postfix, from userid 1000) id 7F2E73C0411; Fri, 26 Jul 2019 09:50:15 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com Subject: [PATCH 1/3] Add low_new_clone method to linux_nat_target. Date: Fri, 26 Jul 2019 09:50:10 -0300 In-Reply-To: <20190726125012.6503-1-pedromfc@linux.ibm.com> References: <20190726125012.6503-1-pedromfc@linux.ibm.com> MIME-Version: 1.0 x-cbid: 19072612-0004-0000-0000-0000152ED5FC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011496; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01237704; UDB=6.00652451; IPR=6.01019085; MB=3.00027903; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-26 12:50:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19072612-0005-0000-0000-00008C9E3FD4 Message-Id: <20190726125012.6503-2-pedromfc@linux.ibm.com> This patch adds a low_new_clone method to linux_nat_target, called after a PTRACE_EVENT_CLONE is detected, similar to how low_new_fork is called after PTRACE_EVENT_(V)FORK. This is useful for targets that need to copy state associated with a thread that is inherited across clones. gdb/ChangeLog: YYYY-MM-DD Pedro Franco de Carvalho * linux-nat.h (low_new_clone): New method. * linux-nat.c (linux_handle_extended_wait): Call low_new_clone. --- gdb/linux-nat.c | 4 ++++ gdb/linux-nat.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 945c19f666..586d47a71d 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1976,6 +1976,10 @@ linux_handle_extended_wait (struct lwp_info *lp, int status) inferior. */ linux_target->low_new_fork (lp, new_pid); } + else if (event == PTRACE_EVENT_CLONE) + { + linux_target->low_new_clone (lp, new_pid); + } if (event == PTRACE_EVENT_FORK && linux_fork_checkpointing_p (lp->ptid.pid ())) diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 0c1695ad10..04ebe9ba00 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -163,6 +163,10 @@ public: virtual void low_new_fork (struct lwp_info *parent, pid_t child_pid) {} + /* The method to call, if any, when a new clone event is detected. */ + virtual void low_new_clone (struct lwp_info *parent, pid_t child_lwp) + {} + /* The method to call, if any, when a process is no longer attached. */ virtual void low_forget_process (pid_t pid)