This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 4/6] Simplify regcache_dup
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 25 Apr 2017 21:28:24 +0100
- Subject: [PATCH 4/6] Simplify regcache_dup
- Authentication-results: sourceware.org; auth=none
- References: <1493152106-3246-1-git-send-email-yao.qi@linaro.org>
regcache_dup, in fact, is to create a readonly regcache from a
non-readonly regcache. This patch adds an assert that src is not
readonly.
gdb:
2017-04-25 Yao Qi <yao.qi@linaro.org>
* regcache.c (regcache_dup): Assert !src->readonly_p and
call method save instead of regcache_cpy.
* regcache.h (struct regcache): Make regcache_dup a friend.
---
gdb/regcache.c | 3 ++-
gdb/regcache.h | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gdb/regcache.c b/gdb/regcache.c
index f4fcf65..28163c2 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -422,8 +422,9 @@ regcache_dup (struct regcache *src)
{
struct regcache *newbuf;
+ gdb_assert (!src->readonly_p);
newbuf = regcache_xmalloc (src->get_arch (), get_regcache_aspace (src));
- regcache_cpy (newbuf, src);
+ newbuf->save (do_cooked_read, src);
return newbuf;
}
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 8794966..e6494a9 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -378,6 +378,9 @@ private:
friend void
regcache_cpy (struct regcache *dst, struct regcache *src);
+
+ friend struct regcache *
+ regcache_dup (struct regcache *src);
};
/* Copy/duplicate the contents of a register cache. By default, the
--
1.9.1