From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8482 invoked by alias); 6 Apr 2018 19:33:14 -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 8470 invoked by uid 89); 6 Apr 2018 19:33:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=toward, suffered, occasion, Hx-languages-length:1769 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Apr 2018 19:33:12 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83CF05BCBE; Fri, 6 Apr 2018 19:33:11 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 105BF215CDC6; Fri, 6 Apr 2018 19:33:10 +0000 (UTC) Subject: Re: [RFA 00/12] (somewhat) clean up struct value ownership To: Tom Tromey , gdb-patches@sourceware.org References: <20180405211507.6103-1-tom@tromey.com> From: Pedro Alves Message-ID: <97bbc817-5825-9abb-54d4-df041a61700f@redhat.com> Date: Fri, 06 Apr 2018 19:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180405211507.6103-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-04/txt/msg00102.txt.bz2 On 04/05/2018 10:14 PM, Tom Tromey wrote: > struct value has long suffered from a complicated approach to > ownership. In particular, values are reference counted, but they are > also handled specially if they are on the "value chain". I believe > this has led to bugs on occasion; and anyway requires oddities like > release_value_or_incref. > > This series goes some way toward cleaning up ownership for values. It > introduces a gdb_ref_ptr specialization for values and then changes > various things to use it. After this, it cleans up various code doing > manual memory mangement related to value; and in particular unifies > the value chain with the reference counting mechanism. > This is seriously cool. Thanks much for doing this. I've sent a few comments here and there, but overall this looks good to me. > There is still more work that could be done in this area. For > example: > > * struct lval_funcs could be turned into a base class and then the > implementers rewritten as ordinary objects. > > * Likewise struct internalvar_funcs; and this would allow better type > safety through the removal of union internalvar_data. > > * Perhaps the "location" union could be removed from struct value, > also providing more type safety. > Yeah, this would be nice. > However, I didn't do these, as this series seemed to reach a > reasonable stopping point. Definitely agreed. As I'm reading the series, I'm also wishing for making some of the value-related free-functions methods of value instead, so that instead of having to write ref_ptr::get() calls like in: struct type *t = value_type (val.get ()); we'd be able to write instead: struct type *t = val->type (); Thanks, Pedro Alves