From patchwork Thu May 16 20:12:17 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: 32727 Received: (qmail 79229 invoked by alias); 16 May 2019 20:13:51 -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 79135 invoked by uid 89); 16 May 2019 20:13:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 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=HX-Languages-Length:2029, accross 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; Thu, 16 May 2019 20:13:49 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GKDino134365 for ; Thu, 16 May 2019 16:13:48 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shbdgrc4r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 16:13:45 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 21:12:33 +0100 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 21:12:30 +0100 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GKCSwU19398986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 20:12:29 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D89E5112061; Thu, 16 May 2019 20:12:28 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8ED45112062; Thu, 16 May 2019 20:12:28 +0000 (GMT) Received: from pedro.localdomain (unknown [9.18.235.49]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 20:12:28 +0000 (GMT) Received: by pedro.localdomain (Postfix, from userid 1000) id 9C7073C03E6; Thu, 16 May 2019 17:12:25 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com Subject: [PATCH 1/2] linux-nat: Callback for exec events Date: Thu, 16 May 2019 17:12:17 -0300 In-Reply-To: <20190516201218.29403-1-pedromfc@linux.ibm.com> References: <20190516201218.29403-1-pedromfc@linux.ibm.com> MIME-Version: 1.0 x-cbid: 19051620-0052-0000-0000-000003C04EF7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011106; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01204288; UDB=6.00632196; IPR=6.00985218; MB=3.00026921; MTD=3.00000008; XFM=3.00000015; UTC=2019-05-16 20:12:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051620-0053-0000-0000-000060EC17E6 Message-Id: <20190516201218.29403-2-pedromfc@linux.ibm.com> This patch adds a new virtual low method to the linux native target, called when an exec event is detected (PTRACE_EVENT_EXEC). The main motivation for this is for arch-specific code to be able to update its debug register state, since infrun assumes that an exec will cause the hardware watchpoints in the inferior to be cleared. Because this callback is called before infrun and other GDB layers become aware of the exec event, care must be taken when overriding it. 2019-05-16 Pedro Franco de Carvalho * linux-nat.h (class linux_nat_target) : New method. * linux-nat.c (linux_handle_extended_wait): Call low_post_exec. --- gdb/linux-nat.c | 4 ++++ gdb/linux-nat.h | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 65165a2d46..188b1696a8 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2092,6 +2092,10 @@ linux_handle_extended_wait (struct lwp_info *lp, int status) thread execs, it changes its tid to the tgid, and the old tgid thread might have not been resumed. */ lp->resumed = 1; + + /* Let the arch know that lp called exec. */ + linux_target->low_post_exec (lp); + return 0; } diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 0c1695ad10..569683ba33 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -168,6 +168,19 @@ public: virtual void low_forget_process (pid_t pid) {} + /* The method to call, if any, when an exec event is detected on + LWP. + + This is meant to be used by the low target to update its own + internal state of debug registers, given that infrun assumes that + watchpoints are cleared accross an exec. + + For other needs, be careful of assumptions about the state of + other layers of GDB, which haven't been notified of the exec + event at this point. */ + virtual void low_post_exec (struct lwp_info * lwp) + {} + /* Hook to call prior to resuming a thread. */ virtual void low_prepare_to_resume (struct lwp_info *) {}