+2018-06-20 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * regcache.h (regcache_cooked_read_ftype): Rename to...
+ (register_read_ftype): ...this, change type to function_view.
+ (class reg_buffer) <save>: Remove src parameter.
+ (readonly_detached_regcache) <readonly_detached_regcache>: Make
+ parameter non-const in first overload. Remove src parameter in
+ second overload.
+ * regcache.c (do_cooked_read): Remove.
+ (readonly_detached_regcache::readonly_detached_regcache): Make
+ parameter non-const, adjust call to other constructor.
+ (reg_buffer::save): Remove src parameter.
+ * frame.c (do_frame_register_read): Remove.
+ (frame_save_as_regcache): Use lambda function.
+ * ppc-linux-tdep.c (ppu2spu_unwind_register): Change type of src
+ parameter to ppu2spu_data *.
+ (ppu2spu_sniffer): Use lambda function.
+
2018-06-20 Simon Marchi <simon.marchi@polymtl.ca>
* record-full.c (record_full_target::insert_breakpoint): Remove
return pc;
}
-static enum register_status
-do_frame_register_read (void *src, int regnum, gdb_byte *buf)
-{
- if (!deprecated_frame_register_read ((struct frame_info *) src, regnum, buf))
- return REG_UNAVAILABLE;
- else
- return REG_VALID;
-}
-
std::unique_ptr<readonly_detached_regcache>
frame_save_as_regcache (struct frame_info *this_frame)
{
+ auto cooked_read = [this_frame] (int regnum, gdb_byte *buf)
+ {
+ if (!deprecated_frame_register_read (this_frame, regnum, buf))
+ return REG_UNAVAILABLE;
+ else
+ return REG_VALID;
+ };
+
std::unique_ptr<readonly_detached_regcache> regcache
- (new readonly_detached_regcache (get_frame_arch (this_frame),
- do_frame_register_read, this_frame));
+ (new readonly_detached_regcache (get_frame_arch (this_frame), cooked_read));
return regcache;
}
};
static enum register_status
-ppu2spu_unwind_register (void *src, int regnum, gdb_byte *buf)
+ppu2spu_unwind_register (ppu2spu_data *data, int regnum, gdb_byte *buf)
{
- struct ppu2spu_data *data = (struct ppu2spu_data *) src;
enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
if (regnum >= 0 && regnum < SPU_NUM_GPRS)
data.gprs, 0, sizeof data.gprs)
== sizeof data.gprs)
{
+ auto cooked_read = [&data] (int regnum, gdb_byte *buf)
+ {
+ return ppu2spu_unwind_register (&data, regnum, buf);
+ };
struct ppu2spu_cache *cache
= FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
std::unique_ptr<readonly_detached_regcache> regcache
- (new readonly_detached_regcache (data.gdbarch,
- ppu2spu_unwind_register,
- &data));
+ (new readonly_detached_regcache (data.gdbarch, cooked_read));
cache->frame_id = frame_id_build (base, func);
cache->regcache = regcache.release ();
m_ptid = minus_one_ptid;
}
-static enum register_status
-do_cooked_read (void *src, int regnum, gdb_byte *buf)
-{
- struct regcache *regcache = (struct regcache *) src;
-
- return regcache->cooked_read (regnum, buf);
-}
-
-readonly_detached_regcache::readonly_detached_regcache (const regcache &src)
- : readonly_detached_regcache (src.arch (), do_cooked_read, (void *) &src)
+readonly_detached_regcache::readonly_detached_regcache (regcache &src)
+ : readonly_detached_regcache (src.arch (),
+ [&src] (int regnum, gdb_byte *buf)
+ {
+ return src.cooked_read (regnum, buf);
+ })
{
}
}
void
-reg_buffer::save (regcache_cooked_read_ftype *cooked_read,
- void *src)
+reg_buffer::save (register_read_ftype cooked_read)
{
struct gdbarch *gdbarch = m_descr->gdbarch;
int regnum;
if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
{
gdb_byte *dst_buf = register_buffer (regnum);
- enum register_status status = cooked_read (src, regnum, dst_buf);
+ enum register_status status = cooked_read (regnum, dst_buf);
gdb_assert (status != REG_UNKNOWN);
extern int register_size (struct gdbarch *gdbarch, int regnum);
-typedef enum register_status (regcache_cooked_read_ftype) (void *src,
- int regnum,
- gdb_byte *buf);
+typedef gdb::function_view<register_status (int regnum, gdb_byte *buf)>
+ register_read_ftype;
/* A (register_number, register_value) pair. */
/* Save a register cache. The set of registers saved into the
regcache determined by the save_reggroup. COOKED_READ returns
zero iff the register's value can't be returned. */
- void save (regcache_cooked_read_ftype *cooked_read, void *src);
+ void save (register_read_ftype cooked_read);
struct regcache_descr *m_descr;
class readonly_detached_regcache : public readable_regcache
{
public:
- readonly_detached_regcache (const regcache &src);
+ readonly_detached_regcache (regcache &src);
/* Create a readonly regcache by getting contents from COOKED_READ. */
- readonly_detached_regcache (gdbarch *gdbarch,
- regcache_cooked_read_ftype *cooked_read,
- void *src)
+ readonly_detached_regcache (gdbarch *gdbarch, register_read_ftype cooked_read)
: readable_regcache (gdbarch, true)
{
- save (cooked_read, src);
+ save (cooked_read);
}
DISABLE_COPY_AND_ASSIGN (readonly_detached_regcache);