scoped_restore_current_thread ();
~scoped_restore_current_thread ();
+ scoped_restore_current_thread (scoped_restore_current_thread &&rhs);
+
DISABLE_COPY_AND_ASSIGN (scoped_restore_current_thread);
/* Cancel restoring on scope exit. */
set_current_program_space (inf->pspace);
}
+/* See regcache.h. */
+
+gdb::optional<scoped_restore_current_thread>
+maybe_switch_inferior (inferior *inf)
+{
+ gdb::optional<scoped_restore_current_thread> maybe_restore_thread;
+ if (inf != current_inferior ())
+ {
+ maybe_restore_thread.emplace ();
+ switch_to_inferior_no_thread (inf);
+ }
+
+ return maybe_restore_thread;
+}
+
static void
inferior_command (const char *args, int from_tty)
{
selected. */
extern void switch_to_inferior_no_thread (inferior *inf);
+/* Ensure INF is the current inferior.
+
+ If the current inferior was changed, return an RAII object that will
+ restore the original current context. */
+extern gdb::optional<scoped_restore_current_thread> maybe_switch_inferior
+ (inferior *inf);
+
/* Info about an inferior's target description. There's one of these
for each inferior. */
}
}
+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