From patchwork Sun Oct 8 22:52:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23396 Received: (qmail 89484 invoked by alias); 8 Oct 2017 22:52:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 88703 invoked by uid 89); 8 Oct 2017 22:52:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=policy X-HELO: gproxy5-pub.mail.unifiedlayer.com Received: from gproxy5-pub.mail.unifiedlayer.com (HELO gproxy5-pub.mail.unifiedlayer.com) (67.222.38.55) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Oct 2017 22:52:36 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy5.mail.unifiedlayer.com (Postfix) with ESMTP id BD60F140415 for ; Sun, 8 Oct 2017 16:52:34 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id KAsX1w0082f2jeq01AsaAt; Sun, 08 Oct 2017 16:52:34 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=wiL9YbqU0ZILWRXJxIoA:9 a=kdx2oG5HkeRkyn0h:21 a=a5Jy02RwFT4bUKPV:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-4-236.hlrn.qwest.net ([75.166.4.236]:42152 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e1KQv-0026Os-5S; Sun, 08 Oct 2017 16:52:29 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove make_cleanup_value_free Date: Sun, 8 Oct 2017 16:52:25 -0600 Message-Id: <20171008225225.21838-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e1KQv-0026Os-5S X-Source-Sender: 75-166-4-236.hlrn.qwest.net (bapiya.localdomain) [75.166.4.236]:42152 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes 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. --- gdb/ChangeLog | 9 +++++++++ gdb/dwarf2loc.c | 5 +---- gdb/utils.c | 16 ---------------- gdb/utils.h | 1 - gdb/value.h | 15 +++++++++++++++ 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index c485eaf8b0..fe2fea0d0e 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 118fcc3e6d..07841afb8f 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 022af5116c..7af0a5f5ae 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 6dee80af33..bc97ec0728 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);