diff options
author | Paul Koning <paul_koning@dell.com> | 2015-10-16 14:06:43 -0400 |
---|---|---|
committer | Paul Koning <paul_koning@dell.com> | 2015-10-16 14:06:43 -0400 |
commit | 22855f3cab8948f5b4a0fdda9845ce47c8bafbc9 (patch) | |
tree | 64f35f0838cc9cfc268c9ec53fde4d4181684241 | |
parent | f218947cb8901642879d499fc63dd2bd32b5cb03 (diff) | |
download | gdb-22855f3cab8948f5b4a0fdda9845ce47c8bafbc9.zip gdb-22855f3cab8948f5b4a0fdda9845ce47c8bafbc9.tar.gz gdb-22855f3cab8948f5b4a0fdda9845ce47c8bafbc9.tar.bz2 |
remove to_data
There's no reason to have to_data.
On the one hand, a to_xclose target can readily subclass target_ops.
This is simple and clean.
On the other hand, a to_close target can't really use to_data in the
multi-target future, because such a target is inherently not
multi-capable.
So, this patch removes the field and fixes up its sole user.
2014-07-29 Tom Tromey <tromey@redhat.com>
* bfd-target.c (struct target_bfd_ops): Rename from
target_bfd_data. Add "base" field.
(target_bfd_xfer_partial, target_bfd_get_section_table)
(target_bfd_xclose, target_bfd_reopen): Update.
* target.h (struct target_ops) <to_data>: Remove.
-rw-r--r-- | gdb/bfd-target.c | 50 | ||||
-rw-r--r-- | gdb/target.h | 2 |
2 files changed, 25 insertions, 27 deletions
diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index 8a37696..01bcf44 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -23,10 +23,13 @@ #include "exec.h" #include "gdb_bfd.h" -/* The object that is stored in the target_ops->to_data field has this - type. */ -struct target_bfd_data +/* A subclass of target_ops that stores some extra data for use by the + BFD target. */ +struct target_bfd_ops { + /* The base class. */ + struct target_ops base; + /* The BFD we're wrapping. */ struct bfd *bfd; @@ -48,7 +51,7 @@ target_bfd_xfer_partial (struct target_ops *ops, { case TARGET_OBJECT_MEMORY: { - struct target_bfd_data *data = (struct target_bfd_data *) ops->to_data; + struct target_bfd_ops *data = (struct target_bfd_ops *) ops; return section_table_xfer_memory_partial (readbuf, writebuf, offset, len, xfered_len, data->table.sections, @@ -63,42 +66,39 @@ target_bfd_xfer_partial (struct target_ops *ops, static struct target_section_table * target_bfd_get_section_table (struct target_ops *ops) { - struct target_bfd_data *data = (struct target_bfd_data *) ops->to_data; + struct target_bfd_ops *data = (struct target_bfd_ops *) ops; return &data->table; } static void target_bfd_xclose (struct target_ops *t) { - struct target_bfd_data *data = (struct target_bfd_data *) t->to_data; + struct target_bfd_ops *data = (struct target_bfd_ops *) t; gdb_bfd_unref (data->bfd); xfree (data->table.sections); xfree (data); - xfree (t); } struct target_ops * target_bfd_reopen (struct bfd *abfd) { - struct target_ops *t; - struct target_bfd_data *data; + struct target_bfd_ops *t; + + t = XCNEW (struct target_bfd_ops); - data = XCNEW (struct target_bfd_data); - data->bfd = abfd; + t->bfd = abfd; gdb_bfd_ref (abfd); - build_section_table (abfd, &data->table.sections, &data->table.sections_end); - - t = XCNEW (struct target_ops); - t->to_shortname = "bfd"; - t->to_longname = _("BFD backed target"); - t->to_doc = _("You should never see this"); - t->to_get_section_table = target_bfd_get_section_table; - t->to_xfer_partial = target_bfd_xfer_partial; - t->to_xclose = target_bfd_xclose; - t->to_data = data; - t->to_magic = OPS_MAGIC; - t->to_identity = t; - - return t; + build_section_table (abfd, &t->table.sections, &t->table.sections_end); + + t->base.to_shortname = "bfd"; + t->base.to_longname = _("BFD backed target"); + t->base.to_doc = _("You should never see this"); + t->base.to_get_section_table = target_bfd_get_section_table; + t->base.to_xfer_partial = target_bfd_xfer_partial; + t->base.to_xclose = target_bfd_xclose; + t->base.to_magic = OPS_MAGIC; + t->base.to_identity = &t->base; + + return &t->base; } diff --git a/gdb/target.h b/gdb/target.h index fce4046..da04e47 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -430,8 +430,6 @@ struct target_ops const char *to_doc; /* Documentation. Does not include trailing newline, and starts with a one-line descrip- tion (probably similar to to_longname). */ - /* Per-target scratch pad. */ - void *to_data; /* The open routine takes the rest of the parameters from the command, and (if successful) pushes a new target onto the stack. Targets should supply this routine, if only to provide |