+struct scoped_mark_target_starting
+{
+ /* Constructor, TARGET is the target to be marked as starting, its
+ reference count will be incremented. */
+ scoped_mark_target_starting (remote_target *target)
+ : m_remote_target (target)
+ {
+ m_remote_target->incref ();
+ remote_state *rs = m_remote_target->get_remote_state ();
+ rs->starting_up = true;
+ }
+
+ /* Destructor, mark the target being worked on as no longer starting, and
+ decrement the reference count. */
+ ~scoped_mark_target_starting ()
+ {
+ remote_state *rs = m_remote_target->get_remote_state ();
+ rs->starting_up = false;
+ decref_target (m_remote_target);
+ }
+
+private:
+
+ /* The target on which we are operating. */
+ remote_target *m_remote_target;
+};
+
+/* Helper for remote_target::start_remote, start the remote connection and
+ sync state. Return true if everything goes OK, otherwise, return false.
+ This function exists so that the scoped_restore created within it will
+ expire before we return to remote_target::start_remote. */
+
+bool
+remote_target::start_remote_1 (int from_tty, int extended_p)