summaryrefslogtreecommitdiff
path: root/gdbserver/gdbthread.h
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-12-13 12:22:48 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-12-13 12:22:48 +0100
commitf24791b72e764ada576901c0e866bf7768773a16 (patch)
treed3e09e57eb5a5787b80d78f239fefa4ee27a6e74 /gdbserver/gdbthread.h
parent200fd2874d2c147539f756b29e15ebbafa81dfcf (diff)
downloadbinutils-gdb-f24791b72e764ada576901c0e866bf7768773a16.tar.gz
gdbserver: introduce scoped_restore_current_thread and switch_to_thread
Introduce a class for restoring the current thread and a function to switch to the given thread. This is a preparation for a refactoring that aims to remove direct assignments to 'current_thread'.
Diffstat (limited to 'gdbserver/gdbthread.h')
-rw-r--r--gdbserver/gdbthread.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index 7c293b1f89d..315a4da5167 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -233,4 +233,26 @@ lwpid_of (const thread_info *thread)
return thread->id.lwp ();
}
+/* Switch the current thread. */
+
+void switch_to_thread (thread_info *thread);
+
+/* Save/restore current thread. */
+
+class scoped_restore_current_thread
+{
+public:
+ scoped_restore_current_thread ();
+ ~scoped_restore_current_thread ();
+
+ DISABLE_COPY_AND_ASSIGN (scoped_restore_current_thread);
+
+ /* Cancel restoring on scope exit. */
+ void dont_restore () { m_dont_restore = true; }
+
+private:
+ bool m_dont_restore = false;
+ thread_info *m_thread;
+};
+
#endif /* GDBSERVER_GDBTHREAD_H */