From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MgkQEBIuimDsOAAAWB0awg (envelope-from ) for ; Wed, 28 Apr 2021 23:54:58 -0400 Received: by simark.ca (Postfix, from userid 112) id 33E661F11C; Wed, 28 Apr 2021 23:54:58 -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 AA5E11E783 for ; Wed, 28 Apr 2021 23:54:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED9FD3857830; Thu, 29 Apr 2021 03:54:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED9FD3857830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1619668496; bh=Bd2cZQ8ZSTzUqhDMuDIwkvjBEYmdQ0DLn3ctC0TJ8IQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=J8LMIV2sQ3vySANcLdgaTO1T18Aphvk5QDOCmlgmqDW7w74DDt4APIr8nOcglq5Tj uuqkRDStcVyJv2lPsDyB6gbAGnazqitvftY8DlOLa8V0hZNBbsBLQhpuedu2xA4U+t ilUa93kyV2GKweO4su1KUg1B+ZQYlno/OZlNp6Is= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id A3AE6385E447 for ; Thu, 29 Apr 2021 03:54:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A3AE6385E447 X-ASG-Debug-ID: 1619668492-0c856e6cd511338e0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id neKWHQTRJfLxDoVU (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 28 Apr 2021 23:54:52 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 25E6E441B21; Wed, 28 Apr 2021 23:54:52 -0400 (EDT) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH] gdb: move some variables to an inner scope in save_waitstatus Date: Wed, 28 Apr 2021 23:54:51 -0400 X-ASG-Orig-Subj: [PATCH] gdb: move some variables to an inner scope in save_waitstatus Message-Id: <20210429035451.1825919-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1619668492 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 1347 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.89583 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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@sourceware.org Sender: "Gdb-patches" 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. 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