gdb/infrun: move a 'regcache_read_pc' call down to first use

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-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* infrun.c (resume_1): Move a 'regcache_read_pc' call down to first
	use.
This commit is contained in:
Tankut Baris Aktemur 2020-05-14 13:59:53 +02:00
parent fc75c28ba1
commit 7ca9b62a2b
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (resume_1): Move a 'regcache_read_pc' call down to first
use.
2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* regcache.c (regcache_read_pc_protected): New function

View File

@ -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), "