aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/bfd-target.c1
-rw-r--r--gdb/target.c8
-rw-r--r--gdb/target.h6
3 files changed, 12 insertions, 3 deletions
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c
index ee93c3b..8a37696 100644
--- a/gdb/bfd-target.c
+++ b/gdb/bfd-target.c
@@ -98,6 +98,7 @@ target_bfd_reopen (struct bfd *abfd)
t->to_xclose = target_bfd_xclose;
t->to_data = data;
t->to_magic = OPS_MAGIC;
+ t->to_identity = t;
return t;
}
diff --git a/gdb/target.c b/gdb/target.c
index b8b1e9b..1a3d417 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -339,6 +339,8 @@ complete_target_initialization (struct target_ops *t)
gdb_assert (t->to_can_run == NULL || (t->to_can_async_p != NULL
&& t->to_supports_non_stop != NULL));
+ t->to_identity = t;
+
install_delegators (t);
}
@@ -722,7 +724,7 @@ unpush_target (struct target_ops *t)
for (cur = &target_stack; (*cur) != NULL; cur = &(*cur)->beneath)
{
- if ((*cur) == t)
+ if ((*cur) == t || (*cur)->to_identity == t)
break;
}
@@ -741,7 +743,7 @@ unpush_target (struct target_ops *t)
/* Finally close the target. Note we do this after unchaining, so
any target method calls from within the target_close
implementation don't end up in T anymore. */
- target_close (t);
+ target_close (tmp);
return 1;
}
@@ -788,7 +790,7 @@ target_is_pushed (struct target_ops *t)
}
for (cur = target_stack; cur != NULL; cur = cur->beneath)
- if (cur == t)
+ if (cur == t || cur->to_identity == t)
return 1;
return 0;
diff --git a/gdb/target.h b/gdb/target.h
index 2b2db45..804b579 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1241,6 +1241,12 @@ struct target_ops
void (*to_done_generating_core) (struct target_ops *)
TARGET_DEFAULT_IGNORE ();
+ /* This points to an "original" target_ops from which a particular
+ instance may have been cloned. This is useful if a to_xclose
+ target clones some other target_ops, but still wants to call
+ target_is_pushed or unpush_target. */
+ struct target_ops *to_identity;
+
int to_magic;
/* Need sub-structure for target machine related rather than comm related?
*/