From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0/NxElmktmBSaQAAWB0awg (envelope-from ) for ; Tue, 01 Jun 2021 17:19:21 -0400 Received: by simark.ca (Postfix, from userid 112) id 3B6041F163; Tue, 1 Jun 2021 17:19:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7A5851E813 for ; Tue, 1 Jun 2021 17:19:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F463398A86D for ; Tue, 1 Jun 2021 21:19:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F463398A86D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1622582360; bh=LKgVTYB4fGiTHgUrhsuEottLmrNbMcTlobptgHJxeI8=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Y3OsufkhX8oeMkB7ui1Wx3WZXULoM69Ni/+kj2YFmneAk3BymvfZsbDCw6BpWmFX7 VJ1WmAzyQu150ULVYk+fnQOB0p+EocGMX0PvIWBWji6fg5GV0+eTn+ySyvntwevv26 qIWavHVPLG2Fm0pj/D1PFyoY9RBOiuroWCqnc7Qw= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 4FB3C398A438 for ; Tue, 1 Jun 2021 21:19:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4FB3C398A438 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 151LIqDT025321 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 1 Jun 2021 17:18:57 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 151LIqDT025321 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id AFAF61E813; Tue, 1 Jun 2021 17:18:52 -0400 (EDT) Subject: Re: [PATCH v2] Conditionally restore displaced stepping state after fork. To: John Baldwin , gdb-patches@sourceware.org References: <20210531161558.10600-1-jhb@FreeBSD.org> <20210601211137.83647-1-jhb@FreeBSD.org> Message-ID: <97d48a49-1acc-56ed-d4eb-3e57946f6fac@polymtl.ca> Date: Tue, 1 Jun 2021 17:18:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210601211137.83647-1-jhb@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 1 Jun 2021 21:18:52 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-06-01 5:11 p.m., John Baldwin wrote: > There is no default method for > gdbarch_displaced_step_restore_all_in_ptid, so calling it > unconditionally for fork events triggered an assertion failure on > platforms that do not support displaced stepping. To fix, only invoke > the method if the gdbarch supports displaced stepping. > > Note that not all gdbarches support both displaced stepping and fork > events, so gdbarch validation does not require > gdbarch_displaced_step_restore_all_in_ptid for any gdbarch supporting > displaced stepping. However, the internal assertion in > gdbarch_displaced_step_restore_all_in_ptid should catch any gdbarches > which do support both but fail to provide this method. > > gdb/ChangeLog: > > * infrun.c (handle_inferior_event): Only call > gdbarch_displaced_step_restore_all_in_ptid if > gdbarch_supports_displaced_stepping is true. > --- > gdb/ChangeLog | 6 ++++++ > gdb/infrun.c | 16 ++++++++++++---- > 2 files changed, 18 insertions(+), 4 deletions(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 03910c0634..b0f448a35e 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,9 @@ > +2021-05-30 John Baldwin > + > + * infrun.c (handle_inferior_event): Only call > + gdbarch_displaced_step_restore_all_in_ptid if > + gdbarch_supports_displaced_stepping is true. > + > 2021-05-27 Simon Marchi > > * Fix tab after space indentation issues throughout. > diff --git a/gdb/infrun.c b/gdb/infrun.c > index e9624d2a9b..488bcc1e10 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -5493,10 +5493,18 @@ handle_inferior_event (struct execution_control_state *ecs) > struct gdbarch *gdbarch = regcache->arch (); > inferior *parent_inf = find_inferior_ptid (ecs->target, ecs->ptid); > > - /* If this is a fork (child gets its own address space copy) and some > - displaced step buffers were in use at the time of the fork, restore > - the displaced step buffer bytes in the child process. */ > - if (ecs->ws.kind == TARGET_WAITKIND_FORKED) > + /* If this is a fork (child gets its own address space copy) > + and some displaced step buffers were in use at the time of > + the fork, restore the displaced step buffer bytes in the > + child process. > + > + Architectures which support displaced stepping and fork > + events must supply an implementation of > + gdbarch_displaced_step_restore_all_in_ptid. This is not > + enforced during gdbarch validation to support architectures > + which support displaced stepping but not forks. */ > + if (ecs->ws.kind == TARGET_WAITKIND_FORKED > + && gdbarch_supports_displaced_stepping (gdbarch)) > gdbarch_displaced_step_restore_all_in_ptid > (gdbarch, parent_inf, ecs->ws.value.related_pid); > > LGTM, thanks! Simon