From: Simon Marchi Date: Sun, 10 Jun 2018 02:08:06 +0000 (-0400) Subject: Change type of reg_buffer::m_register_status to register_status X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aac0d564cea04b1c5f386e8cea924ca59057e8b4;p=binutils-gdb.git Change type of reg_buffer::m_register_status to register_status The type of reg_buffer::m_register_status is an array of signed char, probably to ensure that each element takes up only one byte. Instead, since we use C++11, we can force the underlying type of register_status to be signed char and use the enum type. gdb/ChangeLog: * common/common-regcache.h (enum register_status): Add underlying type "signed char". * regcache.h (reg_buffer) : Change type to register_status *. * regcache.c (reg_buffer::reg_buffer): Alocate arrays of register_status instead of signed char. (reg_buffer::save): Use REG_UNKNOWN instead of 0. (reg_buffer::get_register_status): Remove cast. (readable_regcache::raw_read): Remove cast. (readable_regcache::cooked_read): Remove cast. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1ff0e165fa2..c475cd9ed94 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2018-06-09 Simon Marchi + + * common/common-regcache.h (enum register_status): Add + underlying type "signed char". + * regcache.h (reg_buffer) : Change type to + register_status *. + * regcache.c (reg_buffer::reg_buffer): Alocate arrays of + register_status instead of signed char. + (reg_buffer::save): Use REG_UNKNOWN instead of 0. + (reg_buffer::get_register_status): Remove cast. + (readable_regcache::raw_read): Remove cast. + (readable_regcache::cooked_read): Remove cast. + 2018-06-09 Tom Tromey * source.c (reverse_search_command, forward_search_command): Use diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h index 696ba00955b..9709ba414ee 100644 --- a/gdb/common/common-regcache.h +++ b/gdb/common/common-regcache.h @@ -22,7 +22,7 @@ /* This header is a stopgap until we have an independent regcache. */ -enum register_status +enum register_status : signed char { /* The register value is not in the cache, and we don't know yet whether it's available in the target (or traceframe). */ diff --git a/gdb/regcache.c b/gdb/regcache.c index 225b3a0ef05..626d4242fa7 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -186,13 +186,14 @@ reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo) if (has_pseudo) { m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_cooked_registers); - m_register_status = XCNEWVEC (signed char, - m_descr->nr_cooked_registers); + m_register_status + = XCNEWVEC (register_status, m_descr->nr_cooked_registers); } else { m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_raw_registers); - m_register_status = XCNEWVEC (signed char, gdbarch_num_regs (gdbarch)); + m_register_status + = XCNEWVEC (register_status, gdbarch_num_regs (gdbarch)); } } @@ -273,7 +274,7 @@ reg_buffer::save (regcache_cooked_read_ftype *cooked_read, gdb_assert (m_has_pseudo); /* Clear the dest. */ memset (m_registers, 0, m_descr->sizeof_cooked_registers); - memset (m_register_status, 0, m_descr->nr_cooked_registers); + memset (m_register_status, REG_UNKNOWN, m_descr->nr_cooked_registers); /* Copy over any registers (identified by their membership in the save_reggroup) and mark them as valid. The full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) range is checked since some architectures need @@ -325,7 +326,7 @@ reg_buffer::get_register_status (int regnum) const { assert_regnum (regnum); - return (enum register_status) m_register_status[regnum]; + return m_register_status[regnum]; } void @@ -515,7 +516,7 @@ readable_regcache::raw_read (int regnum, gdb_byte *buf) memcpy (buf, register_buffer (regnum), m_descr->sizeof_register[regnum]); - return (enum register_status) m_register_status[regnum]; + return m_register_status[regnum]; } enum register_status @@ -609,7 +610,7 @@ readable_regcache::cooked_read (int regnum, gdb_byte *buf) else memset (buf, 0, m_descr->sizeof_register[regnum]); - return (enum register_status) m_register_status[regnum]; + return m_register_status[regnum]; } else if (gdbarch_pseudo_register_read_value_p (m_descr->gdbarch)) { diff --git a/gdb/regcache.h b/gdb/regcache.h index 3edddf47e12..1001eed8d68 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -177,7 +177,7 @@ protected: /* The register buffers. */ gdb_byte *m_registers; /* Register cache status. */ - signed char *m_register_status; + register_status *m_register_status; friend class regcache; friend class detached_regcache;