From patchwork Wed Jan 23 15:21:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 31182 Received: (qmail 63834 invoked by alias); 23 Jan 2019 15:21:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 63703 invoked by uid 89); 23 Jan 2019 15:21:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Wed, 23 Jan 2019 15:21:39 +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 CF41D7F3FC; Wed, 23 Jan 2019 15:21:37 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09E5E67141; Wed, 23 Jan 2019 15:21:36 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey , Andrew Burgess Subject: [PATCH v3 04/17] Use forward_scope_exit for scoped_finish_thread_state Date: Wed, 23 Jan 2019 15:21:18 +0000 Message-Id: <20190123152131.29893-5-palves@redhat.com> In-Reply-To: <20190123152131.29893-1-palves@redhat.com> References: <20190123152131.29893-1-palves@redhat.com> This reimplements the manually-written scoped_finish_thread_state class as a forward_scope_exit instanciation. forward_scope_exit has the same interface as scoped_finish_thread_state, so nothing else has to change. A forward_scope_exit is preferred over make_scope_exit here because infrun.c:normal_stop needs to wrap scoped_finish_thread_state in a gdb::optional. Since we need the type there, might as well use it everywhere. gdb/ChangeLog: yyyy-mm-dd Pedro Alves Andrew Burgess * gdbthread.h: Include "common/forward-scope-exit.h". (scoped_finish_thread_state): Redefine custom class in terms of forward_scope_exit. --- gdb/gdbthread.h | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 95db69605e..c35a54e75d 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -32,6 +32,7 @@ struct symtab; #include "cli/cli-utils.h" #include "common/refcounted-object.h" #include "common-gdbthread.h" +#include "common/forward-scope-exit.h" struct inferior; @@ -612,31 +613,8 @@ extern void finish_thread_state (ptid_t ptid); /* Calls finish_thread_state on scope exit, unless release() is called to disengage. */ -class scoped_finish_thread_state -{ -public: - explicit scoped_finish_thread_state (ptid_t ptid) - : m_ptid (ptid) - {} - - ~scoped_finish_thread_state () - { - if (!m_released) - finish_thread_state (m_ptid); - } - - /* Disengage. */ - void release () - { - m_released = true; - } - - DISABLE_COPY_AND_ASSIGN (scoped_finish_thread_state); - -private: - bool m_released = false; - ptid_t m_ptid; -}; +using scoped_finish_thread_state + = FORWARD_SCOPE_EXIT (finish_thread_state); /* Commands with a prefix of `thread'. */ extern struct cmd_list_element *thread_cmd_list;