[2/2] gdb: remove reference to current inferior in target_stack::unpush

Message ID 20210429193451.1866888-3-simon.marchi@polymtl.ca
State Superseded
Headers show
  • Remove two references to current inferior in
Related show

Commit Message

Simon Marchi via Gdb-patches April 29, 2021, 7:34 p.m.
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`.


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

Change-Id: If9d9661567c5c16f655d270bd2ec9f1b3aa6dadc
 gdb/target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



diff --git a/gdb/target.c b/gdb/target.c
index 00f0acde7586..78327a2a6c33 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1214,7 +1214,7 @@  target_stack::unpush (target_ops *t)
   m_stack[stratum] = NULL;
   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
      referencing this target still.  Note we do this after unchaining,