diff options
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/regcache.c | 18 | ||||
-rw-r--r-- | gdb/regcache.h | 11 |
3 files changed, 21 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c475cd9..1600232 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2018-06-09 Simon Marchi <simon.marchi@ericsson.com> + * regcache.h (reg_buffer) <~reg_buffer>: Use default destructor. + <m_registers, m_register_status>: Change type to + std::unique_ptr. + * regcache.c (reg_buffer::reg_buffer): Use new instead of + XCNEWVEC. + +2018-06-09 Simon Marchi <simon.marchi@ericsson.com> + * common/common-regcache.h (enum register_status): Add underlying type "signed char". * regcache.h (reg_buffer) <m_register_status>: Change type to diff --git a/gdb/regcache.c b/gdb/regcache.c index 626d424..3eed7b6 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -185,15 +185,15 @@ 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 (register_status, m_descr->nr_cooked_registers); + m_registers.reset (new gdb_byte[m_descr->sizeof_cooked_registers] ()); + m_register_status.reset + (new register_status[m_descr->nr_cooked_registers] ()); } else { - m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_raw_registers); - m_register_status - = XCNEWVEC (register_status, gdbarch_num_regs (gdbarch)); + m_registers.reset (new gdb_byte[m_descr->sizeof_raw_registers] ()); + m_register_status.reset + (new register_status[gdbarch_num_regs (gdbarch)] ()); } } @@ -260,7 +260,7 @@ private: gdb_byte * reg_buffer::register_buffer (int regnum) const { - return m_registers + m_descr->register_offset[regnum]; + return m_registers.get () + m_descr->register_offset[regnum]; } void @@ -273,8 +273,8 @@ reg_buffer::save (regcache_cooked_read_ftype *cooked_read, /* It should have pseudo registers. */ gdb_assert (m_has_pseudo); /* Clear the dest. */ - memset (m_registers, 0, m_descr->sizeof_cooked_registers); - memset (m_register_status, REG_UNKNOWN, m_descr->nr_cooked_registers); + memset (m_registers.get (), 0, m_descr->sizeof_cooked_registers); + memset (m_register_status.get (), 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 diff --git a/gdb/regcache.h b/gdb/regcache.h index 1001eed..2f460a0 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -153,11 +153,8 @@ public: buffer. */ enum register_status get_register_status (int regnum) const; - virtual ~reg_buffer () - { - xfree (m_registers); - xfree (m_register_status); - } + virtual ~reg_buffer () = default; + protected: /* Assert on the range of REGNUM. */ void assert_regnum (int regnum) const; @@ -175,9 +172,9 @@ protected: bool m_has_pseudo; /* The register buffers. */ - gdb_byte *m_registers; + std::unique_ptr<gdb_byte[]> m_registers; /* Register cache status. */ - register_status *m_register_status; + std::unique_ptr<register_status[]> m_register_status; friend class regcache; friend class detached_regcache; |