Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] Heap-allocate core_target instances
Date: Fri, 04 May 2018 16:36:00 -0000	[thread overview]
Message-ID: <87in832x9t.fsf@tromey.com> (raw)
In-Reply-To: <20180503162234.15371-4-palves@redhat.com> (Pedro Alves's message	of "Thu, 3 May 2018 17:22:34 +0100")

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> This gets rid of the core_ops global, and replaces it with
Pedro> heap-allocated core_target instances.  In practice, there will only be
Pedro> one such instance, though that will change further ahead as more
Pedro> pieces of multi-target support are merged.

Pedro> +  /* FIXME: kettenis/20031023: Eventually this variable should
Pedro> +     disappear.  */
Pedro> +  struct gdbarch *m_core_gdbarch = NULL;

This comment is very gdb.


It was a bit hard to read the patch but I think I excerpted this correctly:

Pedro> +void
Pedro> +core_target::close ()
[...]
Pedro> +  delete this;

I realize this is what was planned from your c++-ification series, but
today I was wondering if this code path:

    void
    core_target::detach (inferior *inf, int from_tty)
    {
      unpush_target (this);

  =>

    int
    unpush_target (struct target_ops *t)
    ...
      target_close (t);

invokes undefined behavior.

"delete this" seems to be ok if you are careful not to use "this"
afterward, but is this particular use ok?  I don't know the rule here
but I thought I'd mention it just in case.

Pedro> +/* Deleter for std::unique_ptr.  Closes the target if an exception is
Pedro> +   thrown.  */
Pedro> +struct target_ops_closer
Pedro> +{
Pedro> +  void operator() (target_ops *target)
Pedro> +  {
Pedro> +    target->close ();
Pedro> +  }
Pedro> +};

This seems like something to put in target.h.

Tom


  reply	other threads:[~2018-05-04 16:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03 16:22 [PATCH 0/3] Torward multiple simultaneous core instances Pedro Alves
2018-05-03 16:22 ` [PATCH 3/3] Heap-allocate core_target instances Pedro Alves
2018-05-04 16:36   ` Tom Tromey [this message]
2018-05-06 15:38     ` Pedro Alves
2018-05-07 14:26       ` Tom Tromey
2018-05-11 19:40         ` Pedro Alves
2018-05-03 16:22 ` [PATCH 2/3] Eliminate the 'the_core_target' global Pedro Alves
2018-05-04 15:59   ` Tom Tromey
2018-05-03 16:22 ` [PATCH 1/3] Move core_bfd to program space Pedro Alves
2018-05-04 15:41   ` Tom Tromey
2018-05-04 16:09     ` Pedro Alves
2018-05-04 16:46       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87in832x9t.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox