From patchwork Fri Feb 14 20:54:41 2020 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: 38088 Received: (qmail 37217 invoked by alias); 14 Feb 2020 20:55:14 -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 35492 invoked by uid 89); 14 Feb 2020 20:55:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 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=linuxnatc, UD:linux-nat.c, yyyymmdd, linux-nat.c 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, 14 Feb 2020 20:55:12 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01EKrZkc014307 for ; Fri, 14 Feb 2020 15:55:11 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y4j886mqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 14 Feb 2020 15:55:10 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 01EKrFxb022870 for ; Fri, 14 Feb 2020 20:55:10 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03dal.us.ibm.com with ESMTP id 2y5bc0brgy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 14 Feb 2020 20:55:10 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01EKt8GA51577096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Feb 2020 20:55:08 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 501ADAC05B; Fri, 14 Feb 2020 20:55:08 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FF0BAC059; Fri, 14 Feb 2020 20:55:08 +0000 (GMT) Received: from pedro.localdomain (unknown [9.85.204.156]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 14 Feb 2020 20:55:08 +0000 (GMT) Received: by pedro.localdomain (Postfix, from userid 1000) id 2ECAE3C04AD; Fri, 14 Feb 2020 17:55:04 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: ulrich.weigand@de.ibm.com, rcardoso@linux.ibm.com Subject: [PATCH v2 1/3] Add low_new_clone method to linux_nat_target. Date: Fri, 14 Feb 2020 17:54:41 -0300 Message-Id: <20200214205443.1073579-2-pedromfc@linux.ibm.com> In-Reply-To: <20200214205443.1073579-1-pedromfc@linux.ibm.com> References: <20200214205443.1073579-1-pedromfc@linux.ibm.com> MIME-Version: 1.0 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 81af83c4ac..1af7825c92 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1978,6 +1978,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 f800e43997..4e2c622ec4 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -164,6 +164,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)