diff options
author | Pedro Alves <palves@redhat.com> | 2018-04-10 14:49:30 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-04-10 14:49:30 +0100 |
commit | 731f534f918cfaa35c20b5eb6220a8eba4819f04 (patch) | |
tree | 32d4b440a20836edfca758a05a36629c745e1d54 /gdb/gdbthread.h | |
parent | d4ae1932770d9ec76f3d0a429aab45f1cb15e964 (diff) | |
download | gdb-731f534f918cfaa35c20b5eb6220a8eba4819f04.zip gdb-731f534f918cfaa35c20b5eb6220a8eba4819f04.tar.gz gdb-731f534f918cfaa35c20b5eb6220a8eba4819f04.tar.bz2 |
Replace finish_thread_state_cleanup with a RAII class
gdb/ChangeLog:
2018-04-10 Pedro Alves <palves@redhat.com>
* gdbthread.h (finish_thread_state_cleanup): Delete declaration.
(scoped_finish_thread_state): New class.
* infcmd.c (run_command_1): Use it instead of finish_thread_state
cleanup.
* infrun.c (proceed, prepare_for_detach, wait_for_inferior)
(fetch_inferior_event, normal_stop): Likewise.
* thread.c (finish_thread_state_cleanup): Delete.
Diffstat (limited to 'gdb/gdbthread.h')
-rw-r--r-- | gdb/gdbthread.h | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 9b468db..09ea5ba 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -567,10 +567,33 @@ extern int threads_are_executing (void); Notifications are only emitted if the thread state did change. */ extern void finish_thread_state (ptid_t ptid); -/* Same as FINISH_THREAD_STATE, but with an interface suitable to be - registered as a cleanup. PTID_P points to the ptid_t that is - passed to FINISH_THREAD_STATE. */ -extern void finish_thread_state_cleanup (void *ptid_p); +/* 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; +}; /* Commands with a prefix of `thread'. */ extern struct cmd_list_element *thread_cmd_list; |