From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122883 invoked by alias); 12 Jan 2019 11:50:47 -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 121792 invoked by uid 89); 12 Jan 2019 11:50:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=cancel, submission, demonstrate, boiler X-HELO: mail-wr1-f67.google.com Received: from mail-wr1-f67.google.com (HELO mail-wr1-f67.google.com) (209.85.221.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 12 Jan 2019 11:50:44 +0000 Received: by mail-wr1-f67.google.com with SMTP id l9so17859022wrt.13 for ; Sat, 12 Jan 2019 03:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ocEQoIWZkmaqNsD1NbWRJtG8xI8B9/R4yp2+KHv8NlQ=; b=GkAB1OIPKLw837wppHntBwWPmw470pO4NJL3SgsuFblIrkfx5pedmSzaa3RxWHjbGM bsN1NxmU6aFxkVtrhnf6NUQhRBGFsOi+0QY0nfR7uqiJ0nFvX49tWmdSeDs8aoLiVFv6 V4BgXr+UFWwO4fFJij7R0o+GJbC1EEcj5n49+NJxBjyM5YkNmUR/qNKeICrNCvlOq2Ms Fr3T+rD7LaXyTl0wiTYxFGm7rv3jBvZox8aQyUD+RUWqZuR/6LcQbxt4j5fwSjJ6hQfP 9wDcKW5Ky5RQ9wivfJPQV6CgWPo1JTyEPNHDb+IF7wsDvRb2Or36Akbop/2jOWD2icUO mdMw== Return-Path: Received: from localhost (host86-172-198-47.range86-172.btcentralplus.com. [86.172.198.47]) by smtp.gmail.com with ESMTPSA id k26sm15495603wmi.28.2019.01.12.03.50.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 12 Jan 2019 03:50:41 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess Subject: Re: [PATCH 00/12] remove some cleanups using a cleanup function Date: Sat, 12 Jan 2019 11:50:00 -0000 Message-Id: In-Reply-To: <20190109033426.16062-1-tom@tromey.com> References: <20190109033426.16062-1-tom@tromey.com> X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg00273.txt.bz2 I've been thinking about a similar idea for a while too. I wondered if there was a way we could make use of templates to generate some of the common boiler plate cleanups. This mini-series changes the first 4 of your patches to you this idea so you can see how it might work. First, the ideal, description, a new templated class `cleanup_function` that allows you to do something like this: void delete_longjmp_breakpoint (int arg) { /* Blah, blah, blah... */ } using longjmp_breakpoint_cleanup = cleanup_function ; This creates a new cleanup class `longjmp_breakpoint_cleanup` than can then be used like this: longjmp_breakpoint_cleanup obj (thread); /* Blah, blah, blah... */ obj.cancel (); /* Optional cancel if needed. */ The cleanup_function class can take any number of arguments, and is cancellable if needed, it can also take zero arguments. In theory this would allow any cleanup that only needs to hold some simple arguments by value and call a static function to be made into a `cleanup_function` specialisation. Now the only slight problem is that the above requires C++17, which isn't what we use right now. However, there is a C++11 alternative which we can use for now, so you _actually_ have to write this: using longjmp_breakpoint_cleanup = cleanup_function ; The function signature is added in as pre-C++17 GCC doesn't support `auto` template parameters. The 4 patches below make use of `#ifdef __cpp_template_auto` to demonstrate the pre and post C++17 code variants. A final submission would be based on pre-C++11 and include the function signatures, but add a comment in the `cleanup_function` class that when we update the C++ standard, we can update how the class is used. How do you think this compares to your original patches? Any interest in this approach? Thanks, Andrew -- Andrew Burgess (4): gdb: Remove delete_longjmp_breakpoint_cleanup gdb: Remove remaining cleanup from breakpoint.c gdb: Remove make_bpstat_clear_actions_cleanup gdb/testsuite: Don't allow paths to appear in test name gdb/ChangeLog | 29 +++++++++++ gdb/breakpoint.c | 26 +++------- gdb/breakpoint.h | 19 +++++++ gdb/common/cleanup-function.h | 118 ++++++++++++++++++++++++++++++++++++++++++ gdb/infcmd.c | 12 +---- gdb/inferior.h | 2 - gdb/infrun.c | 7 +-- gdb/testsuite/ChangeLog | 4 ++ gdb/top.c | 7 ++- gdb/utils.c | 17 ------ gdb/utils.h | 1 - 11 files changed, 187 insertions(+), 55 deletions(-) create mode 100644 gdb/common/cleanup-function.h -- 2.14.5