[v1.99,1/6] Introduce regcache_get_ptid

Message ID 20170311170354.18468-2-simon.marchi@polymtl.ca
State New, archived
Headers

Commit Message

Simon Marchi March 11, 2017, 5:03 p.m. UTC
  This patch introduces the regcache_get_ptid function, which can be used
to retrieve the ptid a regcache is connected to.  It is used in
subsequent patches.

gdb/ChangeLog:

	* regcache.h (regcache_get_ptid): New function.
	* regcache.c (regcache_get_ptid): New function.
---
 gdb/regcache.c | 10 ++++++++++
 gdb/regcache.h |  4 ++++
 2 files changed, 14 insertions(+)
  

Patch

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 0728a03b65..58d4f56292 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -215,6 +215,16 @@  struct regcache
   ptid_t ptid;
 };
 
+/* See regcache.h.  */
+
+ptid_t
+regcache_get_ptid (const struct regcache *regcache)
+{
+  gdb_assert (!ptid_equal (regcache->ptid, minus_one_ptid));
+
+  return regcache->ptid;
+}
+
 static struct regcache *
 regcache_xmalloc_1 (struct gdbarch *gdbarch, struct address_space *aspace,
 		    int readonly_p)
diff --git a/gdb/regcache.h b/gdb/regcache.h
index e1495f6142..d0107cd76e 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -39,6 +39,10 @@  struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
 struct regcache *regcache_xmalloc (struct gdbarch *gdbarch,
 				   struct address_space *aspace);
 
+/* Return REGCACHE's ptid.  */
+
+extern ptid_t regcache_get_ptid (const struct regcache *regcache);
+
 /* Return REGCACHE's architecture.  */
 
 extern struct gdbarch *get_regcache_arch (const struct regcache *regcache);