gdb: remove reference to current inferior in target_stack::unpush

target_stack::unpush needs to get the target beneath the target being
unpushed to update the m_top field (which keeps the stratum of the
top-most target).  It currently does so using target_ops::beneath, which
uses the target stack of the current inferior.  The target stack of the
current inferior is the same as the `this` in the unpush method.

Avoid this detour and remove this reference to the current inferior by
calling target_ops::find_beneath and passing `this` to find the target
beneath `t` in the target stack that is `this`.

gdb/ChangeLog:

	* target.c (target_stack::unpush): Call target_ops::find_beneath
	to get the target beneath `t`.

Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
This commit is contained in:
Simon Marchi 2021-05-07 11:52:51 -04:00 committed by Simon Marchi
parent 27f0a4314a
commit bedc473418
2 changed files with 6 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2021-05-07 Simon Marchi <simon.marchi@efficios.com>
* target.c (target_stack::unpush): Call target_ops::find_beneath
to get the target beneath `t`.
2021-05-07 Simon Marchi <simon.marchi@efficios.com> 2021-05-07 Simon Marchi <simon.marchi@efficios.com>
* target.c (target_close): Check in all inferiors that the * target.c (target_close): Check in all inferiors that the

View file

@ -1214,7 +1214,7 @@ target_stack::unpush (target_ops *t)
m_stack[stratum] = NULL; m_stack[stratum] = NULL;
if (m_top == stratum) if (m_top == stratum)
m_top = t->beneath ()->stratum (); m_top = this->find_beneath (t)->stratum ();
/* Finally close the target, if there are no inferiors /* Finally close the target, if there are no inferiors
referencing this target still. Note we do this after unchaining, referencing this target still. Note we do this after unchaining,