summaryrefslogtreecommitdiff
path: root/gdb/frame.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-09-23 15:34:30 -0600
committerTom Tromey <tom@tromey.com>2017-09-25 19:54:07 -0600
commit9ac86b52da268147b2565e4920357432bb7a34c3 (patch)
treeecd744af89f932b6cad7bfcce62c28a91c33e85a /gdb/frame.c
parentc0e383c63818baee1daf51b8fb1bae34d1e0597f (diff)
downloadbinutils-gdb-9ac86b52da268147b2565e4920357432bb7a34c3.tar.gz
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 <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.
Diffstat (limited to 'gdb/frame.c')
-rw-r--r--gdb/frame.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index ad0cb927593..a74deef7ed2 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<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;
}
@@ -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<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
@@ -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. */