public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: move some variables to an inner scope in save_waitstatus
@ 2021-04-29 14:16 Simon Marchi
0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2021-04-29 14:16 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=89ba430c6b4cba43a2e77fe9a103e26e6c96bc12
commit 89ba430c6b4cba43a2e77fe9a103e26e6c96bc12
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Thu Apr 29 10:16:28 2021 -0400
gdb: move some variables to an inner scope in save_waitstatus
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
Diff:
---
gdb/ChangeLog | 4 ++++
gdb/infrun.c | 5 ++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f24075461b6..ea65327e6e0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2021-04-29 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * infrun.c (save_waitstatus): Move variables to inner scope.
+
2021-04-29 Andrew Burgess <andrew.burgess@embecosm.com>
* NEWS: Fix typo and stray full stop.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index cfec07994f4..90bab8d984f 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-29 14:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 14:16 [binutils-gdb] gdb: move some variables to an inner scope in save_waitstatus Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).