gdb: remove unpush_target free function

unpush_target unpushes the passed-in target from the current inferior's
target stack.  Calling it is therefore an implicit dependency on the
current global inferior.  Remove that function and make the callers use
the inferior::unpush_target method directly.  This sometimes allows
using the inferior from the context rather than the global current
inferior.

target_unpusher::operator() now needs to be implemented in target.c,
otherwise target.h and inferior.h both need to include each other, and
that wouldn't work.

gdb/ChangeLog:

	* target.h (unpush_target): Remove, update all callers
	to use `inferior::unpush_target` instead.
	(struct target_unpusher) <operator()>: Just declare.
	* target.c (unpush_target): Remove.
	(target_unpusher::operator()): New.

Change-Id: Ia5172dfb3f373e0a75b991885b50322ca2142a8c
This commit is contained in:
Simon Marchi
2021-03-23 09:50:32 -04:00
parent 70e958370c
commit fadf6add30
17 changed files with 36 additions and 35 deletions

View File

@ -160,7 +160,7 @@ set_targetdebug (const char *args, int from_tty, struct cmd_list_element *c)
if (targetdebug)
push_target (the_debug_target);
else
unpush_target (the_debug_target);
current_inferior ()->unpush_target (the_debug_target);
}
static void
@ -589,14 +589,6 @@ push_target (target_ops_up &&t)
/* See target.h. */
int
unpush_target (struct target_ops *t)
{
return current_inferior ()->unpush_target (t);
}
/* See target.h. */
bool
target_stack::unpush (target_ops *t)
{
@ -640,7 +632,7 @@ target_stack::unpush (target_ops *t)
static void
unpush_target_and_assert (struct target_ops *target)
{
if (!unpush_target (target))
if (!current_inferior ()->unpush_target (target))
{
fprintf_unfiltered (gdb_stderr,
"pop_all_targets couldn't find target %s\n",
@ -681,6 +673,12 @@ target_is_pushed (target_ops *t)
return current_inferior ()->target_is_pushed (t);
}
void
target_unpusher::operator() (struct target_ops *ops) const
{
current_inferior ()->unpush_target (ops);
}
/* Default implementation of to_get_thread_local_address. */
static void