This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC PATCH v5 3/9] Add scoped_restore_regcache_ptid
- From: Philipp Rudo <prudo at linux dot vnet dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: Omair Javaid <omair dot javaid at linaro dot org>, Yao Qi <qiyaoltc at gmail dot com>, arnez at linux dot vnet dot ibm dot com
- Date: Mon, 12 Mar 2018 16:31:09 +0100
- Subject: [RFC PATCH v5 3/9] Add scoped_restore_regcache_ptid
- Authentication-results: sourceware.org; auth=none
- References: <20180312153115.47321-1-prudo@linux.vnet.ibm.com>
When a target and its target beneath use different ptids to identify a
thread the regcaches ptid has to be set/restored when calls are passed down
to the target beneath to e.g. fetch_registers. Add a scoped_restore to
simplify this.
gdb/ChangeLog:
regcache.h (scoped_restore_regcache_ptid): New class.
---
gdb/regcache.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/gdb/regcache.h b/gdb/regcache.h
index d7bb8b5c93..8e45d7c513 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -403,6 +403,27 @@ private:
registers_changed_ptid (ptid_t ptid);
};
+/* Save/restore the current ptid of REGCACHE. */
+
+class scoped_restore_regcache_ptid
+{
+public:
+ scoped_restore_regcache_ptid (regcache *regcache)
+ : m_regcache (regcache), m_ptid (regcache->ptid ())
+ {}
+
+ ~scoped_restore_regcache_ptid ()
+ {
+ m_regcache->set_ptid (m_ptid);
+ }
+
+ DISABLE_COPY_AND_ASSIGN (scoped_restore_regcache_ptid);
+
+private:
+ regcache *m_regcache;
+ ptid_t m_ptid;
+};
+
class readonly_detached_regcache : public readable_regcache
{
public:
--
2.13.5