diff options
author | Paul Koning <paul_koning@dell.com> | 2015-10-14 16:03:09 -0400 |
---|---|---|
committer | Paul Koning <paul_koning@dell.com> | 2015-10-14 16:03:09 -0400 |
commit | 1f92c67a165696fb15f36fcbee0b9f2d2b3a1b1e (patch) | |
tree | 03548f9d310f8c1fdd6c2720af32dbd296f45769 /gdb/bfd-target.c | |
parent | 41f0b53b94eb41ba14a5439b965d516c449d6d64 (diff) | |
download | gdb-1f92c67a165696fb15f36fcbee0b9f2d2b3a1b1e.zip gdb-1f92c67a165696fb15f36fcbee0b9f2d2b3a1b1e.tar.gz gdb-1f92c67a165696fb15f36fcbee0b9f2d2b3a1b1e.tar.bz2 |
add to_identity
Right now a target_ops has an odd sense of identity.
Most times some identity is needed, a pointer to a static object is
passed in. For example, calls to unpush_target generally work like
this:
unpush_target (&exec_ops);
Conceptually this is a kind of "instanceof" checking.
Now, consider this with "to_xclose" targets. In this case the
target_ops is allocated on the heap and there's no good way to talk
about the identity. Code could remember the pointer, of course, but
this usually just begs the question.
For example in a to_open implementation it is reasonably normal to
check target_is_pushed and then do nothing if the target is pushed.
However, there's no reasonable way way to do this with a to_xclose
target.
This patch introduces a to_identity field that just points to the
"prototype" implementation of a target_ops. This lets us convert
targets to to_xclose without difficulty.
2014-07-29 Tom Tromey <tromey@redhat.com>
* bfd-target.c (target_bfd_reopen): Set to_identity.
* target.c (complete_target_initialization): Set to_identity.
(unpush_target): Check to_identity. Call target_close on the real
target.
(target_is_pushed): Check to_identity.
* target.h (struct target_ops) <to_identity>: New field.
Diffstat (limited to 'gdb/bfd-target.c')
-rw-r--r-- | gdb/bfd-target.c | 1 |
1 files changed, 1 insertions, 0 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; } |