From: Pedro Alves Date: Wed, 2 May 2018 23:37:09 +0000 (+0100) Subject: Eliminate target_ops::to_xclose X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3fffc0701a26bc0baa563fdc793cafb3d3f02a93;p=binutils-gdb.git Eliminate target_ops::to_xclose In the multi-target branch, I found no need for the target_close vs target_xclose distinction. Heap-allocated targets simply delete themselves in their target_close implementation, while singleton/static targets don't. The target_ops C++ification patches will add more commentary around target_ops's destructor, but there's no destructor yet... gdb/ChangeLog: 2018-05-02 Pedro Alves * bfd-target.c (target_bfd_xclose): Rename to ... (target_bfd_close): ... this. (target_bfd_reopen): Adjust. * target.c (target_close): Remove references to to_xclose. * target.h (target_ops::to_xclose): Delete. (target_ops::to_close): Update comments. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9dad5362ec5..2faf82da09c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2018-05-02 Pedro Alves + + * bfd-target.c (target_bfd_xclose): Rename to ... + (target_bfd_close): ... this. + (target_bfd_reopen): Adjust. + * target.c (target_close): Remove references to to_xclose. + * target.h (target_ops::to_xclose): Delete. + (target_ops::to_close): Update comments. + 2018-05-02 Pedro Alves * alpha-linux-nat.c: Include "linux-nat-trad.h" instead of diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index f7928ee0b99..99b49aad13b 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -68,7 +68,7 @@ target_bfd_get_section_table (struct target_ops *ops) } static void -target_bfd_xclose (struct target_ops *t) +target_bfd_close (struct target_ops *t) { struct target_bfd_data *data = (struct target_bfd_data *) t->to_data; @@ -95,7 +95,7 @@ target_bfd_reopen (struct bfd *abfd) 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_close = target_bfd_close; t->to_data = data; t->to_magic = OPS_MAGIC; diff --git a/gdb/target.c b/gdb/target.c index e8d4ae7ea8e..2ff028cfa86 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3416,9 +3416,7 @@ target_close (struct target_ops *targ) fileio_handles_invalidate_target (targ); - if (targ->to_xclose != NULL) - targ->to_xclose (targ); - else if (targ->to_close != NULL) + if (targ->to_close != NULL) targ->to_close (targ); if (targetdebug) diff --git a/gdb/target.h b/gdb/target.h index f208b107676..f3293622856 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -418,11 +418,12 @@ struct target_ops stack. Targets should supply this routine, if only to provide an error message. */ void (*to_open) (const char *, int); - /* Old targets with a static target vector provide "to_close". - New re-entrant targets provide "to_xclose" and that is expected - to xfree everything (including the "struct target_ops"). */ - void (*to_xclose) (struct target_ops *targ); + + /* Close the target. This is where the target can handle + teardown. Heap-allocated targets should delete themselves + before returning. */ void (*to_close) (struct target_ops *); + /* Attaches to a process on the target side. Arguments are as passed to the `attach' command by the user. This routine can be called when the target is not on the target-stack, if the