From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22206 invoked by alias); 2 Dec 2016 14:45:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22077 invoked by uid 89); 2 Dec 2016 14:45:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=surprising, re-reading, rereading X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 14:45:04 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FB588DFFA; Fri, 2 Dec 2016 14:45:03 +0000 (UTC) Received: from [127.0.0.1] (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB2Ej2uE021564; Fri, 2 Dec 2016 09:45:02 -0500 Subject: Re: [RFA 6/8] Use value_freer in dwarf2_evaluate_loc_desc_full To: Tom Tromey , gdb-patches@sourceware.org References: <1480395946-10924-1-git-send-email-tom@tromey.com> <1480395946-10924-7-git-send-email-tom@tromey.com> From: Pedro Alves Message-ID: <06e2b7b1-feca-29f7-7e49-e05f01d05485@redhat.com> Date: Fri, 02 Dec 2016 14:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1480395946-10924-7-git-send-email-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-12/txt/msg00089.txt.bz2 On 11/29/2016 05:05 AM, Tom Tromey wrote: > This changes dwarf2_evaluate_loc_desc_full to use value_freer. > > Note that this function previously called do_cleanup using the same > cleanup multiple times. I had thought this was buggy, but re-reading > make_my_cleanup2 indicates that it is not. Nevertheless it is > surprising, and at least one of the calls (the one that is completely > removed in this patch) seems to have been done under the assumption > that it would still have some effect. > > 2016-11-28 Tom Tromey > > * value.h (value_freer::~value_freer): Call release. > (value_freer::release): New method. > * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use value_freer. > --- > gdb/ChangeLog | 6 ++++++ > gdb/dwarf2loc.c | 27 +++++++++++++-------------- > gdb/value.h | 12 +++++++++++- > 3 files changed, 30 insertions(+), 15 deletions(-) > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 6197bfb..cf61306 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,5 +1,11 @@ > 2016-11-28 Tom Tromey > > + * value.h (value_freer::~value_freer): Call release. > + (value_freer::release): New method. > + * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Use value_freer. > + > +2016-11-28 Tom Tromey > + > * python/py-value.c (valpy_dereference, valpy_referenced_value) > (valpy_reference_value, valpy_const_value, valpy_get_address) > (valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast) > diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c > index 0d8a47c..43c95b8 100644 > --- a/gdb/dwarf2loc.c > +++ b/gdb/dwarf2loc.c > @@ -2321,7 +2321,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, > LONGEST byte_offset) > { > struct value *retval; > - struct cleanup *value_chain; > struct objfile *objfile = dwarf2_per_cu_objfile (per_cu); > > if (byte_offset < 0) > @@ -2335,7 +2334,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, > ctx.per_cu = per_cu; > ctx.obj_address = 0; > > - value_chain = make_cleanup_value_free_to_mark (value_mark ()); > + value_freer free_values; > > ctx.gdbarch = get_objfile_arch (objfile); > ctx.addr_size = dwarf2_per_cu_addr_size (per_cu); > @@ -2350,7 +2349,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, > { > if (ex.error == NOT_AVAILABLE_ERROR) > { > - do_cleanups (value_chain); > + free_values.release (); "release ()" looks potentially confusing to me, if you're in an "unique_ptr" mindset, where release means the opposite -- to stop managing. Can we call that something else? Maybe "free", since the class is called value_freer? Or "reset ()", following the naming used in the standard smart pointers? The latter could be naturally extended to support free_values.reset (value_mark ()); later too, if we need it. Thanks, Pedro Alves