From 9ac86b52da268147b2565e4920357432bb7a34c3 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 23 Sep 2017 15:34:30 -0600 Subject: Remove make_cleanup_regcache_xfree This removes make_cleanup_regcache_xfree in favor of using std::unique_ptr as the return type of frame_save_as_regcache. gdb/ChangeLog 2017-09-25 Tom Tromey * 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. --- gdb/frame.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'gdb/frame.c') diff --git a/gdb/frame.c b/gdb/frame.c index ad0cb92..a74deef 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1017,16 +1017,14 @@ do_frame_register_read (void *src, int regnum, gdb_byte *buf) return REG_VALID; } -struct regcache * +std::unique_ptr 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 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; } @@ -1034,8 +1032,6 @@ void 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) { @@ -1062,8 +1058,8 @@ frame_pop (struct frame_info *this_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 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 @@ -1075,8 +1071,7 @@ frame_pop (struct frame_info *this_frame) (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. */ -- cgit v1.1