From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 73QGB1VkimBpPgAAWB0awg (envelope-from ) for ; Thu, 29 Apr 2021 03:46:29 -0400 Received: by simark.ca (Postfix, from userid 112) id 0EE1D1F11C; Thu, 29 Apr 2021 03:46:29 -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,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 3F6341E01F for ; Thu, 29 Apr 2021 03:46:28 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C9BC398407B; Thu, 29 Apr 2021 07:46:27 +0000 (GMT) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 010AE3951415 for ; Thu, 29 Apr 2021 07:46:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 010AE3951415 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x436.google.com with SMTP id e5so37100432wrg.7 for ; Thu, 29 Apr 2021 00:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dhRd6Ar76kqmfvr9hxga6zFaTDJ6FwM7xeZwW72bH4Y=; b=KJAzJwThUVcv/fc8EwsQ6k7c2uPUNKYDTDU+gjvjlF5o90HiNGrit78wKyhMH+Wvv7 rR0Ytf80bG3T/uEiQ67BGx4aUSgos8/G8YvbDz94KGPFqm/Opz8yUx4e69rWtY0tqUgx H0Mrdiz61/wmXyhyvRwixHd6oBSWlFikv+7JV86VOjrPD6fcInyjVYvlII7w1TzZLCEh WgH6SuRjrNGl8pQCF9ghUXoAUSf9gY0FFzD1Onh1uRxO8ZBU1syBcxn3Ej2VhUtQ83Ly 6/+2C5NAyEL8IDgGEeC9fyG87EHjLFyqYPZo8RWCLaqgQxcUgVzqqyMJv/mx6OOA1qwn OfAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dhRd6Ar76kqmfvr9hxga6zFaTDJ6FwM7xeZwW72bH4Y=; b=nxAxF901EbFaU712VerGVWOLBzQL2ZAAFMui38BM9M8lLxBtuCaYUOGoj6wqg+tBVw qJ1MMaYCJcyvf1dl8lctxp+IeIeBnih7G3oe99Vf5NXaX1AmXKb16mbcMBl+WOZ0LlBb 93nCN5HZ4JHHexFTMYVzrrEWODWWDk6D17wEKyAI4/MX7wm36Ubni1e5Yo0dfSCVVxVZ /kyw+SU3Ia7AeORodnPYbGKssYTO21GmSn9GJUQHWjFwJEXN6SKrU9WgOzeD5Qft7rhT 1CSHub2LyUrR+j7aen5C+LsEtPfiwQSzR7FsmQkCUduEkoA+z+Sj7nyACXi3FSd6ZNkF 3Z1g== X-Gm-Message-State: AOAM5317Vhe8NK6q9wG7d0Sfx7IPxJKFUIRz+TnbskZYyFF1zYRHBYl6 DLLTTw7gl5Pf0x1GmX+ighy9kQ== X-Google-Smtp-Source: ABdhPJzNzskjDLujhSBkP6ofc4A1MUzBjaqWAfMcLM+v2usnVF+FRGi4D7IZflmYyr0TzQhjZHeGCg== X-Received: by 2002:adf:fc85:: with SMTP id g5mr15414379wrr.295.1619682384127; Thu, 29 Apr 2021 00:46:24 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id a9sm2659857wmj.1.2021.04.29.00.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 00:46:23 -0700 (PDT) Date: Thu, 29 Apr 2021 08:46:22 +0100 From: Andrew Burgess To: Simon Marchi Subject: Re: [PATCH] gdb: move some variables to an inner scope in save_waitstatus Message-ID: <20210429074622.GD2364578@embecosm.com> References: <20210429035451.1825919-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429035451.1825919-1-simon.marchi@polymtl.ca> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 08:46:08 up 18 days, 18:33, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] 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: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * Simon Marchi via Gdb-patches [2021-04-28 23:54:51 -0400]: > These two variables: > > struct regcache *regcache = get_thread_regcache (tp); > const address_space *aspace = regcache->aspace (); > > are only needed inside the "if". Getting a thread's regcache is a > somewhat expensive operation, so it's good to avoid it if not necessary. > Move the variable declarations and their initialization to the "if" > scope. > > gdb/ChangeLog: > > * infrun.c (save_waitstatus): Move variables to inner scope. LGTM. Thanks, Andrew > > Change-Id: Ief1463728755b4dcc142c0a0a76896e9d594ae84 > --- > gdb/infrun.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/gdb/infrun.c b/gdb/infrun.c > index cfec07994f4c..90bab8d984f5 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -4703,12 +4703,11 @@ save_waitstatus (struct thread_info *tp, const target_waitstatus *ws) > tp->suspend.waitstatus = *ws; > tp->suspend.waitstatus_pending_p = 1; > > - struct regcache *regcache = get_thread_regcache (tp); > - const address_space *aspace = regcache->aspace (); > - > if (ws->kind == TARGET_WAITKIND_STOPPED > && ws->value.sig == GDB_SIGNAL_TRAP) > { > + struct regcache *regcache = get_thread_regcache (tp); > + const address_space *aspace = regcache->aspace (); > CORE_ADDR pc = regcache_read_pc (regcache); > > adjust_pc_after_break (tp, &tp->suspend.waitstatus); > -- > 2.30.1 >