aboutsummaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2023-04-03 14:52:05 -0400
committerSimon Marchi <simon.marchi@efficios.com>2023-04-17 13:47:13 -0400
commit348da4565b5c901e9320c3e2d7f5b62793b48a38 (patch)
tree494850c0621b85dd9ef473e0ecfb65e2c6bb7ea1 /gdb/thread.c
parent2b214d3e3b51b9a6544ffbcf0a1554376c3ce9c5 (diff)
downloadbinutils-348da4565b5c901e9320c3e2d7f5b62793b48a38.zip
binutils-348da4565b5c901e9320c3e2d7f5b62793b48a38.tar.gz
binutils-348da4565b5c901e9320c3e2d7f5b62793b48a38.tar.bz2
gdb: add maybe_switch_inferior function
Add the maybe_switch_inferior function, which ensures that the given inferior is the current one. Return an instantiated scoped_restore_current_thread object only we actually needed to switch inferior. Returning a scoped_restore_current_thread requires it to be move-constructible, so give it a move constructor. Change-Id: I1231037102ed6166f2530399e8257ad937fb0569 Reviewed-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index 4d97ed3..e9432f9 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1378,6 +1378,20 @@ scoped_restore_current_thread::scoped_restore_current_thread ()
}
}
+scoped_restore_current_thread::scoped_restore_current_thread
+ (scoped_restore_current_thread &&rhs)
+ : m_dont_restore (std::move (rhs.m_dont_restore)),
+ m_thread (std::move (rhs.m_thread)),
+ m_inf (std::move (rhs.m_inf)),
+ m_selected_frame_id (std::move (rhs.m_selected_frame_id)),
+ m_selected_frame_level (std::move (rhs.m_selected_frame_level)),
+ m_was_stopped (std::move (rhs.m_was_stopped)),
+ m_lang (std::move (rhs.m_lang))
+{
+ /* Deactivate the rhs. */
+ rhs.m_dont_restore = true;
+}
+
/* See gdbthread.h. */
int