This adds a push_target overload that takes a "target_ops_up &&".
This removes some calls to release a target_ops_up, and makes the
intent here clearer.
gdb/ChangeLog
2019-02-15 Tom Tromey <tromey@adacore.com>
* target.h (push_target): Declare new overload.
* target.c (push_target): New overload, taking an rvalue reference.
* remote.c (remote_target::open_1): Use push_target overload.
* corelow.c (core_target_open): Use push_target overload.
+2019-02-15 Tom Tromey <tromey@adacore.com>
+
+ * target.h (push_target): Declare new overload.
+ * target.c (push_target): New overload, taking an rvalue reference.
+ * remote.c (remote_target::open_1): Use push_target overload.
+ * corelow.c (core_target_open): Use push_target overload.
+
2019-02-15 Tom Tromey <tromey@adacore.com>
* ravenscar-thread.c (is_ravenscar_task)
if (!exec_bfd)
set_gdbarch_from_file (core_bfd);
- push_target (target);
- target_holder.release ();
+ push_target (std::move (target_holder));
inferior_ptid = null_ptid;
}
/* Switch to using the remote target now. */
- push_target (remote);
- /* The target stack owns the target now. */
- target_holder.release ();
+ push_target (std::move (target_holder));
/* Register extra event sources in the event loop. */
rs->remote_async_inferior_event_token
g_target_stack.push (t);
}
+/* See target.h */
+
+void
+push_target (target_ops_up &&t)
+{
+ g_target_stack.push (t.get ());
+ t.release ();
+}
+
/* See target.h. */
int
extern void push_target (struct target_ops *);
+/* An overload that deletes the target on failure. */
+extern void push_target (target_ops_up &&);
+
extern int unpush_target (struct target_ops *);
extern void target_pre_inferior (int);