Skip to content

Commit dea57a6

Browse files
committed
Add push_target overload
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.
1 parent 989f3c5 commit dea57a6

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

gdb/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2019-02-15 Tom Tromey <tromey@adacore.com>
2+
3+
* target.h (push_target): Declare new overload.
4+
* target.c (push_target): New overload, taking an rvalue reference.
5+
* remote.c (remote_target::open_1): Use push_target overload.
6+
* corelow.c (core_target_open): Use push_target overload.
7+
18
2019-02-15 Tom Tromey <tromey@adacore.com>
29

310
* ravenscar-thread.c (is_ravenscar_task)

gdb/corelow.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ core_target_open (const char *arg, int from_tty)
417417
if (!exec_bfd)
418418
set_gdbarch_from_file (core_bfd);
419419

420-
push_target (target);
421-
target_holder.release ();
420+
push_target (std::move (target_holder));
422421

423422
inferior_ptid = null_ptid;
424423

gdb/remote.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5547,9 +5547,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
55475547
}
55485548

55495549
/* Switch to using the remote target now. */
5550-
push_target (remote);
5551-
/* The target stack owns the target now. */
5552-
target_holder.release ();
5550+
push_target (std::move (target_holder));
55535551

55545552
/* Register extra event sources in the event loop. */
55555553
rs->remote_async_inferior_event_token

gdb/target.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,15 @@ push_target (struct target_ops *t)
585585
g_target_stack.push (t);
586586
}
587587

588+
/* See target.h */
589+
590+
void
591+
push_target (target_ops_up &&t)
592+
{
593+
g_target_stack.push (t.get ());
594+
t.release ();
595+
}
596+
588597
/* See target.h. */
589598

590599
int

gdb/target.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,9 @@ extern void add_deprecated_target_alias (const target_info &info,
23332333

23342334
extern void push_target (struct target_ops *);
23352335

2336+
/* An overload that deletes the target on failure. */
2337+
extern void push_target (target_ops_up &&);
2338+
23362339
extern int unpush_target (struct target_ops *);
23372340

23382341
extern void target_pre_inferior (int);

0 commit comments

Comments
 (0)