This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 0/3] More cleanup elimination / gdb::unique_ptr
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 10 Oct 2016 17:58:43 +0100
- Subject: Re: [PATCH 0/3] More cleanup elimination / gdb::unique_ptr
- Authentication-results: sourceware.org; auth=none
- References: <1476117992-5689-1-git-send-email-palves@redhat.com>
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<expression>
>
> 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
>