[v8,2/6] gdb/infrun: move a 'regcache_read_pc' call down to first use

Message ID 20200513205338.14233-3-palves@redhat.com
State New
Headers show
Series
  • Handle already-exited threads in 'stop_all_threads'
Related show

Commit Message

Simon Marchi via Gdb-patches May 13, 2020, 8:53 p.m.
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>


In infrun.c's resume_1 function, move the definition of the local
variable PC down to its first use.  This is useful if the thread we want
to resume is already gone with a pending exit event, because we avoid
the error we would see otherwise when trying to read the PC.

gdb/ChangeLog:
2020-04-03  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* infrun.c (resume_1): Move a 'regcache_read_pc' call down to first
	use.
---
 gdb/infrun.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.14.5

Patch

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5e01336ab09..db88a1eef15 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2279,7 +2279,6 @@  resume_1 (enum gdb_signal sig)
   struct regcache *regcache = get_current_regcache ();
   struct gdbarch *gdbarch = regcache->arch ();
   struct thread_info *tp = inferior_thread ();
-  CORE_ADDR pc = regcache_read_pc (regcache);
   const address_space *aspace = regcache->aspace ();
   ptid_t resume_ptid;
   /* This represents the user's step vs continue request.  When
@@ -2358,6 +2357,8 @@  resume_1 (enum gdb_signal sig)
       step = 0;
     }
 
+  CORE_ADDR pc = regcache_read_pc (regcache);
+
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
 			"infrun: resume (step=%d, signal=%s), "