From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109269 invoked by alias); 14 Feb 2020 19:39:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 109261 invoked by uid 89); 14 Feb 2020 19:39:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Feb 2020 19:39:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581709150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1WJbUXTMRW+9oSmaP2l25PibqU68ivrnyEbWp5yKpWM=; b=MeEoB6VcEHD78/PKi8mZN9Mvn7a03XbGsSKNUfKtLmv64jrubsqGtcn0f0mbANTqhvr2Nk SNDVERmsB9ZTvXCwEf6mZqO3ud0arGpLPZ9FEQYo5pySYqqmrtayynvFNixmhnC1ztCt5c 4+87sv6ssaoMp5RL+wQ33TTlDKLSPA4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-194-Y68lqziZNtyCR8Whd0yBFw-1; Fri, 14 Feb 2020 14:39:08 -0500 Received: by mail-wm1-f72.google.com with SMTP id f66so4419165wmf.9 for ; Fri, 14 Feb 2020 11:39:08 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f909:7b00:56ee:75ff:fe8d:232b? ([2001:8a0:f909:7b00:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id p5sm8097365wrt.79.2020.02.14.11.39.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Feb 2020 11:39:06 -0800 (PST) Subject: Re: [PATCH 1/2] gdb: cleanup of displaced_step_inferior_state::reset/displaced_step_clear To: Simon Marchi , gdb-patches@sourceware.org References: <20200122151410.30012-1-simon.marchi@efficios.com> From: Pedro Alves Message-ID: Date: Fri, 14 Feb 2020 19:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20200122151410.30012-1-simon.marchi@efficios.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00576.txt.bz2 On 1/22/20 3:14 PM, Simon Marchi wrote: > displaced_step_inferior_state::reset and displaced_step_clear appear to > have the same goal, but they don't do the same thing. > displaced_step_inferior_state::reset clears more things than > displaced_step_clear, but it misses free'ing the closure, which > displaced_step_clear does. > > This patch replaces displaced_step_clear's implementation with just a call to > displaced_step_inferior_state::reset. It then changes > displaced_step_inferior_state::step_closure to be a unique_ptr, to indicate the > fact that displaced_step_inferior_state owns the closure (and so that it is > automatically freed when the field is reset). > > It should be possible to get rid of displaced_step_clear entirely, but I'm not > sure what the best way, give that it's used in scope exit macros. The reason it needs to be wrapped in a cleanup instead of say SCOPE_EXIT, is that it needs to be discardable with the "cleanup.release ();" call. I'm not sure there's a better way. Renaming displaced_step_clear to displaced_step_reset and adding a comment may result in clearer code, though. > diff --git a/gdb/infrun.h b/gdb/infrun.h > index 8040b28f0172..c6329c844d9b 100644 > --- a/gdb/infrun.h > +++ b/gdb/infrun.h > @@ -290,7 +290,7 @@ struct displaced_step_inferior_state > failed_before = 0; > step_thread = nullptr; > step_gdbarch = nullptr; > - step_closure = nullptr; > + step_closure.reset (); I see people sometimes doing this change and I'm curious. Is it for clarity? Anyway, this LGTM. Thanks, Pedro Alves