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.
This commit is contained in:
parent
d4ae193277
commit
731f534f91
5 changed files with 63 additions and 50 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue