aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.h
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-06-16 15:38:42 +0100
committerYao Qi <yao.qi@linaro.org>2017-06-16 15:38:42 +0100
commit6f98355cda4ac718855d247fd942553b1706549b (patch)
tree060aa7cfb453b4fb17d91c615fa15a30739013f5 /gdb/regcache.h
parente197589b72e7b7b2db95c63acd58abb574b4249c (diff)
extract/store integer function template
This patch converts functions extract_{unsigned,signed}_integer to a function template extract_integer, which has two instantiations. It also does the similar changes to store__{unsigned,signed}_integer, regcache::raw_read_{unsigned,signed}, regcache::raw_write_{unsigned,signed}, regcache::cooked_read_{unsigned,signed}, regcache::cooked_write_{unsigned,signed}. This patch was posted here https://sourceware.org/ml/gdb-patches/2017-05/msg00492.html but the problem was fixed in a different way. However, I think the patch is still useful to shorten the code. gdb: 2017-06-16 Alan Hayward <alan.hayward@arm.com> Pedro Alves <palves@redhat.com> Yao Qi <yao.qi@linaro.org> * defs.h (RequireLongest): New. (extract_integer): Declare function template. (extract_signed_integer): Remove the declaration, but define it static inline. (extract_unsigned_integer): Likewise. (store_integer): Declare function template. (store_signed_integer): Remove the declaration, but define it static inline. (store_unsigned_integer): Likewise. * findvar.c (extract_integer): New function template. (extract_signed_integer): Remove. (extract_unsigned_integer): Remove. (extract_integer<LONGEST>, extract_integer<ULONGEST>): Explicit instantiations. (store_integer): New function template. (store_signed_integer): Remove. (store_unsigned_integer): Remove. (store_integer): Explicit instantiations. * regcache.c (regcache_raw_read_signed): Update. (regcache::raw_read): New function. (regcache::raw_read_signed): Remove. (regcache::raw_read_unsigned): Remove. (regcache_raw_read_unsigned): Update. (regcache_raw_write_unsigned): Update. (regcache::raw_write_signed): Remove. (regcache::raw_write): New function. (regcache_cooked_read_signed): Update. (regcache::raw_write_unsigned): Remove. (regcache::cooked_read_signed): Remove. (regcache_cooked_read_unsigned): Update. (regcache::cooked_read_unsigned): Remove. (regcache_cooked_write_signed): Update. (regcache_cooked_write_unsigned): Update. * regcache.h (regcache) <raw_read_signed>: Remove. <raw_write_signed, raw_read_unsigned, raw_write_unsigned>: Remove. <raw_read, raw_write>: New. <cooked_read_signed, cooked_write_signed>: Remove. <cooked_write_unsigned, cooked_read_unsigned>: Remove. <cooked_read, cooked_write>: New. * sh64-tdep.c (sh64_pseudo_register_read): Update. (sh64_pseudo_register_write): Update.
Diffstat (limited to 'gdb/regcache.h')
-rw-r--r--gdb/regcache.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 4cf27a0b67..3f3f823ad7 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -282,23 +282,19 @@ public:
#endif
void raw_write (int regnum, const gdb_byte *buf);
- enum register_status raw_read_signed (int regnum, LONGEST *val);
+ template<typename T, typename = RequireLongest<T>>
+ enum register_status raw_read (int regnum, T *val);
- void raw_write_signed (int regnum, LONGEST val);
-
- enum register_status raw_read_unsigned (int regnum, ULONGEST *val);
-
- void raw_write_unsigned (int regnum, ULONGEST val);
+ template<typename T, typename = RequireLongest<T>>
+ void raw_write (int regnum, T val);
struct value *cooked_read_value (int regnum);
- enum register_status cooked_read_signed (int regnum, LONGEST *val);
-
- void cooked_write_signed (int regnum, LONGEST val);
-
- enum register_status cooked_read_unsigned (int regnum, ULONGEST *val);
+ template<typename T, typename = RequireLongest<T>>
+ enum register_status cooked_read (int regnum, T *val);
- void cooked_write_unsigned (int regnum, ULONGEST val);
+ template<typename T, typename = RequireLongest<T>>
+ void cooked_write (int regnum, T val);
void raw_update (int regnum);