From: Tom Tromey Date: Sun, 8 Oct 2017 18:20:49 +0000 (-0600) Subject: Remove make_cleanup_value_free X-Git-Tag: users/ARM/embedded-binutils-master-2017q4~711 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=757325a3f24e01bf8e7b7214f33c546bc52d1d12;p=external%2Fbinutils.git Remove make_cleanup_value_free This removes make_cleanup_value_free, in favor of a unique_ptr specialization. Regression tested by the buildbot. gdb/ChangeLog 2017-10-08 Tom Tromey * utils.h (make_cleanup_value_free): Remove. * utils.c (do_value_free, struct cleanup): Remove. * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) : Use gdb_value_up. * value.h (struct value_deleter): New. (gdb_value_up): New typedef. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 511df16..34a6107 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2017-10-08 Tom Tromey + * utils.h (make_cleanup_value_free): Remove. + * utils.c (do_value_free, struct cleanup): Remove. + * dwarf2loc.c (dwarf2_evaluate_loc_desc_full) : + Use gdb_value_up. + * value.h (struct value_deleter): New. + (gdb_value_up): New typedef. + +2017-10-08 Tom Tromey + * symtab.c (free_search_symbols, do_free_search_symbols_cleanup) (make_cleanup_free_search_symbols): Remove. (search_symbols): Return std::vector. diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index c485eaf..fe2fea0 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -2478,7 +2478,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, size_t len = TYPE_LENGTH (subobj_type); size_t max = TYPE_LENGTH (type); struct gdbarch *objfile_gdbarch = get_objfile_arch (objfile); - struct cleanup *cleanup; if (subobj_byte_offset + len > max) invalid_synthetic_pointer (); @@ -2488,7 +2487,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, below. */ value_incref (value); free_values.free_to_mark (); - cleanup = make_cleanup_value_free (value); + gdb_value_up value_holder (value); retval = allocate_value (subobj_type); @@ -2498,8 +2497,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, memcpy (value_contents_raw (retval), value_contents_all (value) + subobj_byte_offset, len); - - do_cleanups (cleanup); } break; diff --git a/gdb/utils.c b/gdb/utils.c index 118fcc3..07841af 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -185,22 +185,6 @@ make_cleanup_value_free_to_mark (struct value *mark) return make_cleanup (do_value_free_to_mark, mark); } -/* Helper for make_cleanup_value_free. */ - -static void -do_value_free (void *value) -{ - value_free ((struct value *) value); -} - -/* Free VALUE. */ - -struct cleanup * -make_cleanup_value_free (struct value *value) -{ - return make_cleanup (do_value_free, value); -} - /* This function is useful for cleanups. Do diff --git a/gdb/utils.h b/gdb/utils.h index 022af51..7af0a5f 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -215,7 +215,6 @@ struct target_ops; extern struct cleanup *make_cleanup_unpush_target (struct target_ops *ops); extern struct cleanup *make_cleanup_value_free_to_mark (struct value *); -extern struct cleanup *make_cleanup_value_free (struct value *); /* A deleter for a hash table. */ struct htab_deleter diff --git a/gdb/value.h b/gdb/value.h index 6dee80a..bc97ec0 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1018,6 +1018,21 @@ extern void value_incref (struct value *val); extern void value_free (struct value *val); +/* A free policy class to interface std::unique_ptr with + value_free. */ + +struct value_deleter +{ + void operator() (struct value *value) const + { + value_free (value); + } +}; + +/* A unique pointer to a struct value. */ + +typedef std::unique_ptr gdb_value_up; + extern void free_all_values (void); extern void free_value_chain (struct value *v);