From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>,
Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH v3 04/17] Use forward_scope_exit for scoped_finish_thread_state
Date: Wed, 23 Jan 2019 15:21:00 -0000 [thread overview]
Message-ID: <20190123152131.29893-5-palves@redhat.com> (raw)
In-Reply-To: <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 <palves@redhat.com>
Andrew Burgess <andrew.burgess@embecosm.com>
* 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;
--
2.14.4
next prev parent reply other threads:[~2019-01-23 15:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 15:21 [PATCH v3 00/17] Remove some cleanups using scope_exit Pedro Alves
2019-01-23 15:21 ` [PATCH v3 08/17] Remove delete_just_stopped_threads_infrun_breakpoints_cleanup Pedro Alves
2019-01-23 15:21 ` [PATCH v3 17/17] Use scope_exit in regcache.c Pedro Alves
2019-01-23 15:21 ` [PATCH v3 02/17] Introduce scope_exit Pedro Alves
2019-01-23 15:21 ` [PATCH v3 05/17] Use SCOPE_EXIT in gdbarch-selftest.c Pedro Alves
2019-01-23 15:21 ` [PATCH v3 07/17] Remove remaining cleanup from gdb/breakpoint.c Pedro Alves
2019-01-23 15:21 ` Pedro Alves [this message]
2019-01-23 17:10 ` [PATCH v3 04/17] Use forward_scope_exit for scoped_finish_thread_state Tom Tromey
2019-01-23 15:21 ` [PATCH v3 13/17] Remove cleanup from stop_all_threads Pedro Alves
2019-01-23 15:21 ` [PATCH v3 03/17] Introduce forward_scope_exit Pedro Alves
2019-01-23 15:21 ` [PATCH v3 10/17] Remove cleanup_delete_std_terminate_breakpoint Pedro Alves
2019-01-23 15:21 ` [PATCH v3 01/17] Rename ESC -> ESC_PARENS Pedro Alves
2019-01-23 15:21 ` [PATCH v3 15/17] Update an obsolete cleanup comment Pedro Alves
2019-01-23 15:21 ` [PATCH v3 12/17] Remove clear_symtab_users_cleanup Pedro Alves
2019-01-23 15:21 ` [PATCH v3 16/17] Update cleanup comment in ui-out.h Pedro Alves
2019-01-23 15:21 ` [PATCH v3 06/17] Replace delete_longjmp_breakpoint_cleanup with a forward_scope_exit type Pedro Alves
2019-01-23 15:21 ` [PATCH v3 14/17] Remove remaining cleanup from fetch_inferior_event Pedro Alves
2019-01-23 15:28 ` [PATCH v3 09/17] Remove make_bpstat_clear_actions_cleanup Pedro Alves
2019-01-23 17:33 ` [PATCH v3 00/17] Remove some cleanups using scope_exit Tom Tromey
2019-01-23 19:18 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190123152131.29893-5-palves@redhat.com \
--to=palves@redhat.com \
--cc=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox