Use forward_scope_exit for scoped_finish_thread_state
authorPedro Alves <palves@redhat.com>
Wed, 23 Jan 2019 18:58:30 +0000 (18:58 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 23 Jan 2019 19:03:48 +0000 (19:03 +0000)
This reimplements the manually-written scoped_finish_thread_state
class as a forward_scope_exit instantiation.  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:
2019-01-23  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/ChangeLog
gdb/gdbthread.h

index dff515d8cebfeef62e6cc60537efd813faa5e8a4..008208e6ec31a16e3e6cd34e43c788afc0f9519b 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-23  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.
+
 2019-01-23  Pedro Alves  <palves@redhat.com>
            Andrew Burgess  <andrew.burgess@embecosm.com>
 
index 95db69605e099ef4612061f5c08002d9b7ce0889..c35a54e75d35439337249a31510cc700fab986b0 100644 (file)
@@ -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;
This page took 0.026501 seconds and 4 git commands to generate.