aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-05-14 13:59:53 +0200
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-05-14 13:59:53 +0200
commitfc75c28ba1ea7353fb6e1e5904c5703a48504b67 (patch)
tree5b1a59f1c2cb60a34c7ca6b34e7868aaac49c975 /gdbsupport
parent9d95b8e9d631e76eb152c86003db6b89e913bdd9 (diff)
downloadgdb-fc75c28ba1ea7353fb6e1e5904c5703a48504b67.zip
gdb-fc75c28ba1ea7353fb6e1e5904c5703a48504b67.tar.gz
gdb-fc75c28ba1ea7353fb6e1e5904c5703a48504b67.tar.bz2
gdb: protect some 'regcache_read_pc' calls
It possible that a thread whose PC we attempt to read is already dead. In this case, 'regcache_read_pc' errors out. This impacts the "proceed" execution flow, where GDB quits early before having a chance to check if there exists a pending event. To remedy, keep going with a 0 value for the PC if 'regcache_read_pc' fails. Because the value of PC before resuming a thread is mostly used for storing and checking the next time the thread stops, this tolerance is expected to be harmless for a dead thread/process. gdb/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * regcache.c (regcache_read_pc_protected): New function implementation that returns 0 if the PC cannot read via 'regcache_read_pc'. * infrun.c (proceed): Call 'regcache_read_pc_protected' instead of 'regcache_read_pc'. (keep_going_pass_signal): Ditto. gdbsupport/ChangeLog: 2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * common-regcache.h (regcache_read_pc_protected): New function declaration.
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog5
-rw-r--r--gdbsupport/common-regcache.h5
2 files changed, 10 insertions, 0 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 194811e..636a3d3 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * common-regcache.h (regcache_read_pc_protected): New function
+ declaration.
+
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb-sigmask.h: Fix typo (pthead_sigmask -> pthread_sigmask).
diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h
index 18446ff..650536e 100644
--- a/gdbsupport/common-regcache.h
+++ b/gdbsupport/common-regcache.h
@@ -56,6 +56,11 @@ extern int regcache_register_size (const struct regcache *regcache, int n);
extern CORE_ADDR regcache_read_pc (struct regcache *regcache);
+/* Read the PC register. If PC cannot be read, return 0.
+ This is a wrapper around 'regcache_read_pc'. */
+
+extern CORE_ADDR regcache_read_pc_protected (regcache *regcache);
+
/* Read a raw register into a unsigned integer. */
extern enum register_status regcache_raw_read_unsigned
(struct regcache *regcache, int regnum, ULONGEST *val);