From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37530 invoked by alias); 4 Sep 2017 16:15:55 -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 37521 invoked by uid 89); 4 Sep 2017 16:15:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=preference, frustrating, disguised, management 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; Mon, 04 Sep 2017 16:15:49 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D25C6AAF8 for ; Mon, 4 Sep 2017 16:15:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2D25C6AAF8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com 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 B7DDF81530 for ; Mon, 4 Sep 2017 16:15:47 +0000 (UTC) Subject: Re: [PATCH 0/3] Introduce gdb::array_view, symtabs_and_lines -> std::vector To: GDB Patches References: <1503343667-6790-1-git-send-email-palves@redhat.com> From: Pedro Alves Message-ID: <6746557f-eaf0-74d6-9b50-0ab48a7918db@redhat.com> Date: Mon, 04 Sep 2017 16:15: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: <1503343667-6790-1-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-09/txt/msg00054.txt.bz2 On 08/21/2017 08:27 PM, Pedro Alves wrote: > Looking at the "list and multiple locations" patch [1], I thought that > it's a bit annoying/frustrating to have do remember to free the sals > array that a symtabs_and_lines object wraps, with 'xfree (sals.sals)' > or the equivalent make_cleanup(xfree, ...), not to mention how > error-prone manual memory management is. We can do better in C++. > > So I wrote a patch to replace 'struct symtabs_and_lines' with 'typedef > std::vector symtabs_and_lines'. That works nicelly, > except that I wasn't entirely happy that that would introduce heap > allocations in a few cases where there is none nowadays. > > I then addressed that by adding an array_view abstraction, which is > something that I've wanted at other times before. > > After that, we'd end up with some places using a std::vector disguised > behind the symtabs_and_lines typedef, while in other places we'd be > spelling out gdb::array_view. With that, I no longer see any value in > keeping the symtabs_and_lines typedef, kind of giving preference to > std::vector, so I removed the typedef, choosing to spell out > std::vector explicitly. > > (I'm aware that there are several proposals for adding something like > array_view to the standard C++ library. In this implementation, which > was written from scratch and developed in parallel with the unit > tests, I chose to keep it as simple and safe as possible. For > example, there is no support for ranks != 1, simply because the main > use case this aims at addressing is abstracting out std::vector vs > stack arrays in APIs.) > > [1] https://sourceware.org/ml/gdb-patches/2017-07/msg00280.html > > Note that the net increase shown below is mostly caused by the new > unit tests. If we only count patches 2 and 3, then we get instead: > > 33 files changed, 537 insertions(+), 820 deletions(-) FYI, I'm pushing this in now. Thanks, Pedro Alves