From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53807 invoked by alias); 10 Oct 2016 16:58:57 -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 53790 invoked by uid 89); 10 Oct 2016 16:58:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=palves, Hx-languages-length:4732 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, 10 Oct 2016 16:58:46 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 1E7AB3F1F8 for ; Mon, 10 Oct 2016 16:58:45 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9AGwhoO028498 for ; Mon, 10 Oct 2016 12:58:44 -0400 Subject: Re: [PATCH 0/3] More cleanup elimination / gdb::unique_ptr To: gdb-patches@sourceware.org References: <1476117992-5689-1-git-send-email-palves@redhat.com> From: Pedro Alves Message-ID: <8a49f675-dc9f-e1e9-73ae-e15522b395ae@redhat.com> Date: Mon, 10 Oct 2016 16:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1476117992-5689-1-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-10/txt/msg00226.txt.bz2 I'm not sure whether patch #2 is just delayed, or whether it was too big for the list (172K on disk). Meanwhile, I've force-pushed the series to the users/palves/cxx-eliminate-cleanups branch. Thanks, Pedro Alves On 10/10/2016 05:46 PM, Pedro Alves wrote: > This patch series aims at removing more cleanups. > > It eliminates ~90 out of the ~1800 make_cleanup calls left in the > tree. > > It also tries to answer the "which smart pointer?" question. Many > make_cleanup uses in the code base are best eliminated by using a > "owning" smart pointer to manage ownership of the resource > automatically. > > We don't require C++11 yet, but OTOH, std::unique_ptr is quite nice. > C++03 has std::auto_ptr, but, that's best avoided. I'd also like to > have a smart pointer that manages malloc'ed objects, so std::auto_ptr > alone won't cut it. > > The solution proposed by this series is a new gdb::unique_ptr smart > pointer that is mapped to std::unique_ptr when compiling with a C++11 > compiler (really, just a template alias), and is a simple > std::unique_ptr emulation when compiled with a C++03 compiler. > > The patch series first adds the smart pointer to the tree, and then > follows up with examples of C++fycation that use it, and more. > > Series tested on: > > - NetBSD 5.1 (gcc70 on the compile farm), w/ gcc 4.1.3 > - x86-64 Fedora 23, gcc 5.3.1 (gnu++03) native/gdbserver > - x86-64 Fedora 23, and gcc 7.0 (gnu++14) > > Note that while the series' diffstat is practically a wash > linecount-wise: > > 87 files changed, 1450 insertions(+), 1429 deletions(-) > > if we don't count the first patch, i.e., the new smart pointer, then > we get: > > 84 files changed, 1017 insertions(+), 1429 deletions(-) > > So while there's a lot of churn, there's a significant drop in number > of lines of code. > > Pedro Alves (3): > Introduce gdb::unique_ptr > ui_file_xstrdup -> std::string > 'struct parse_expression *' -> gdb::unique_ptr > > gdb/ada-lang.c | 83 +++------ > gdb/ada-lang.h | 2 +- > gdb/ada-valprint.c | 53 +++--- > gdb/ada-varobj.c | 130 ++++++-------- > gdb/arm-tdep.c | 6 +- > gdb/ax-gdb.c | 15 +- > gdb/break-catch-sig.c | 2 +- > gdb/break-catch-syscall.c | 2 +- > gdb/break-catch-throw.c | 26 +-- > gdb/breakpoint.c | 144 +++++++--------- > gdb/breakpoint.h | 8 +- > gdb/c-exp.y | 9 +- > gdb/c-lang.c | 9 +- > gdb/c-lang.h | 7 +- > gdb/c-typeprint.c | 5 +- > gdb/c-varobj.c | 142 ++++++++-------- > gdb/cli/cli-script.c | 130 +++++--------- > gdb/cli/cli-setshow.c | 7 +- > gdb/common/common-defs.h | 3 + > gdb/common/common-utils.c | 31 ++++ > gdb/common/common-utils.h | 6 + > gdb/common/gdb_unique_ptr.h | 363 ++++++++++++++++++++++++++++++++++++++++ > gdb/common/safe-bool.h | 67 ++++++++ > gdb/compile/compile-c-support.c | 6 +- > gdb/compile/compile.c | 70 ++++---- > gdb/cp-abi.c | 2 +- > gdb/cp-abi.h | 7 +- > gdb/cp-support.c | 60 +++---- > gdb/cp-support.h | 10 +- > gdb/dbxread.c | 22 +-- > gdb/dtrace-probe.c | 6 +- > gdb/dwarf2read.c | 25 ++- > gdb/eval.c | 43 ++--- > gdb/expression.h | 12 +- > gdb/gdbarch.c | 8 +- > gdb/gdbarch.sh | 8 +- > gdb/gdbcmd.h | 2 +- > gdb/gdbtypes.c | 12 +- > gdb/gnu-v3-abi.c | 55 ++---- > gdb/guile/guile.c | 18 +- > gdb/guile/scm-breakpoint.c | 6 +- > gdb/guile/scm-disasm.c | 6 +- > gdb/guile/scm-frame.c | 6 +- > gdb/guile/scm-type.c | 27 ++- > gdb/guile/scm-value.c | 18 +- > gdb/infcmd.c | 9 +- > gdb/infrun.c | 6 +- > gdb/language.c | 7 +- > gdb/language.h | 14 +- > gdb/linespec.c | 53 +++--- > gdb/location.c | 11 +- > gdb/location.h | 6 - > gdb/mi/mi-cmd-var.c | 70 +++----- > gdb/mi/mi-main.c | 41 ++--- > gdb/minsyms.c | 17 +- > gdb/objc-lang.c | 7 +- > gdb/parse.c | 50 +++--- > gdb/printcmd.c | 65 +++---- > gdb/python/py-arch.c | 10 +- > gdb/python/py-breakpoint.c | 8 +- > gdb/python/py-frame.c | 8 +- > gdb/python/py-type.c | 10 +- > gdb/python/py-unwind.c | 7 +- > gdb/python/py-value.c | 7 +- > gdb/python/py-varobj.c | 4 +- > gdb/python/python.c | 19 +-- > gdb/remote.c | 56 ++----- > gdb/rust-exp.y | 11 +- > gdb/rust-lang.c | 50 ++---- > gdb/stabsread.c | 21 ++- > gdb/stack.c | 6 +- > gdb/symtab.c | 61 +++---- > gdb/symtab.h | 19 ++- > gdb/top.c | 13 +- > gdb/tracepoint.c | 143 +++++----------- > gdb/tracepoint.h | 18 +- > gdb/typeprint.c | 21 +-- > gdb/ui-file.c | 24 ++- > gdb/ui-file.h | 9 +- > gdb/ui-out.c | 9 +- > gdb/utils.c | 5 +- > gdb/value.c | 8 +- > gdb/value.h | 2 +- > gdb/varobj-iter.h | 4 +- > gdb/varobj.c | 216 +++++++++++------------- > gdb/varobj.h | 66 ++++---- > gdb/xtensa-tdep.c | 9 +- > 87 files changed, 1450 insertions(+), 1429 deletions(-) > create mode 100644 gdb/common/gdb_unique_ptr.h > create mode 100644 gdb/common/safe-bool.h >