2017-09-25 Tom Tromey <tom@tromey.com>
+ * spu-tdep.c (spu2ppu_sniffer): Update.
+ * regcache.h (make_cleanup_regcache_xfree): Don't declare.
+ * regcache.c (do_regcache_xfree, make_cleanup_regcache_xfree):
+ Remove.
+ * ppc-linux-tdep.c (ppu2spu_sniffer): Update.
+ * mi/mi-main.c (mi_cmd_data_list_changed_registers): Update.
+ * frame.h (frame_save_as_regcache): Return std::unique_ptr.
+ * frame.c (frame_save_as_regcache): Return std::unique_ptr.
+ (frame_pop): Update.
+
+2017-09-25 Tom Tromey <tom@tromey.com>
+
* spu-tdep.c (spu2ppu_dealloc_cache): Use delete.
* regcache.h (regcache_xfree): Don't declare.
* regcache.c (regcache_xfree): Remove.
return REG_VALID;
}
-struct regcache *
+std::unique_ptr<struct regcache>
frame_save_as_regcache (struct frame_info *this_frame)
{
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = new regcache (get_frame_arch (this_frame),
- aspace);
- struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
+ std::unique_ptr<struct regcache> regcache
+ (new struct regcache (get_frame_arch (this_frame), aspace));
- regcache_save (regcache, do_frame_register_read, this_frame);
- discard_cleanups (cleanups);
+ regcache_save (regcache.get (), do_frame_register_read, this_frame);
return regcache;
}
frame_pop (struct frame_info *this_frame)
{
struct frame_info *prev_frame;
- struct regcache *scratch;
- struct cleanup *cleanups;
if (get_frame_type (this_frame) == DUMMY_FRAME)
{
Save them in a scratch buffer so that there isn't a race between
trying to extract the old values from the current regcache while
at the same time writing new values into that same cache. */
- scratch = frame_save_as_regcache (prev_frame);
- cleanups = make_cleanup_regcache_xfree (scratch);
+ std::unique_ptr<struct regcache> scratch
+ = frame_save_as_regcache (prev_frame);
/* FIXME: cagney/2003-03-16: It should be possible to tell the
target's register cache that it is about to be hit with a burst
(arguably a bug in the target code mind). */
/* Now copy those saved registers into the current regcache.
Here, regcache_cpy() calls regcache_restore(). */
- regcache_cpy (get_current_regcache (), scratch);
- do_cleanups (cleanups);
+ regcache_cpy (get_current_regcache (), scratch.get ());
/* We've made right mess of GDB's local state, just discard
everything. */
((TYPE *) frame_obstack_zalloc ((NUMBER) * sizeof (TYPE)))
/* Create a regcache, and copy the frame's registers into it. */
-struct regcache *frame_save_as_regcache (struct frame_info *this_frame);
+std::unique_ptr<struct regcache> frame_save_as_regcache
+ (struct frame_info *this_frame);
extern const struct block *get_frame_block (struct frame_info *,
CORE_ADDR *addr_in_block);
void
mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
{
- static struct regcache *this_regs = NULL;
+ static std::unique_ptr<struct regcache> this_regs;
struct ui_out *uiout = current_uiout;
- struct regcache *prev_regs;
+ std::unique_ptr<struct regcache> prev_regs;
struct gdbarch *gdbarch;
int regnum, numregs, changed;
int i;
- struct cleanup *cleanup;
/* The last time we visited this function, the current frame's
register contents were saved in THIS_REGS. Move THIS_REGS over
to PREV_REGS, and refresh THIS_REGS with the now-current register
contents. */
- prev_regs = this_regs;
+ prev_regs = std::move (this_regs);
this_regs = frame_save_as_regcache (get_selected_frame (NULL));
- cleanup = make_cleanup_regcache_xfree (prev_regs);
/* Note that the test for a valid register must include checking the
gdbarch_register_name because gdbarch_num_regs may be allocated
will change depending upon the particular processor being
debugged. */
- gdbarch = get_regcache_arch (this_regs);
+ gdbarch = get_regcache_arch (this_regs.get ());
numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
ui_out_emit_list list_emitter (uiout, "changed-registers");
if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue;
- changed = register_changed_p (regnum, prev_regs, this_regs);
+ changed = register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ());
if (changed < 0)
error (_("-data-list-changed-registers: "
"Unable to read register contents."));
&& gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000')
{
- changed = register_changed_p (regnum, prev_regs, this_regs);
+ changed = register_changed_p (regnum, prev_regs.get (),
+ this_regs.get ());
if (changed < 0)
error (_("-data-list-changed-registers: "
"Unable to read register contents."));
else
error (_("bad register number"));
}
- do_cleanups (cleanup);
}
static int
= FRAME_OBSTACK_CALLOC (1, struct ppu2spu_cache);
struct address_space *aspace = get_frame_address_space (this_frame);
- struct regcache *regcache = new regcache (data.gdbarch, aspace);
- struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
- regcache_save (regcache, ppu2spu_unwind_register, &data);
- discard_cleanups (cleanups);
+ std::unique_ptr<struct regcache> regcache
+ (new struct regcache (data.gdbarch, aspace));
+ regcache_save (regcache.get (), ppu2spu_unwind_register, &data);
cache->frame_id = frame_id_build (base, func);
- cache->regcache = regcache;
+ cache->regcache = regcache.release ();
*this_prologue_cache = cache;
return 1;
}
return regcache->ptid ();
}
-static void
-do_regcache_xfree (void *data)
-{
- delete (struct regcache *) data;
-}
-
-struct cleanup *
-make_cleanup_regcache_xfree (struct regcache *regcache)
-{
- return make_cleanup (do_regcache_xfree, regcache);
-}
-
/* Cleanup routines for invalidating a register. */
struct register_to_invalidate
struct gdbarch *,
struct address_space *);
-struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
-
/* Return REGCACHE's ptid. */
extern ptid_t regcache_get_ptid (const struct regcache *regcache);
if (fi)
{
- cache->regcache = frame_save_as_regcache (fi);
+ cache->regcache = frame_save_as_regcache (fi).release ();
*this_prologue_cache = cache;
return 1;
}