Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [RFA 2/2] Change install_breakpoint to take a std::unique_ptr
Date: Mon, 21 Aug 2017 10:12:00 -0000	[thread overview]
Message-ID: <b1d36e26-c505-54e8-79be-8c9953fe2fff@redhat.com> (raw)
In-Reply-To: <20170820135402.1213-3-tom@tromey.com>

On 08/20/2017 02:54 PM, Tom Tromey wrote:
> @@ -8540,8 +8540,10 @@ init_catchpoint (struct breakpoint *b,
>  }
>  
>  void
> -install_breakpoint (int internal, struct breakpoint *b, int update_gll)
> +install_breakpoint (int internal, std::unique_ptr<breakpoint> &&arg, int update_gll)
>  {
> +  breakpoint *b = arg.release ();
> +
>    add_to_breakpoint_chain (b);

I think we should defer .release() until the ownership
transfer actually happened, for stronger exception safety.

I.e., either:

    add_to_breakpoint_chain (arg.get ());
    breakpoint *b = arg.release ();

or change add_to_breakpoint_chain to take an rvalue-ref unique_ptr
too, and return the raw breakpoint, and then write here:

    breakpoint *b = add_to_breakpoint_chain (std::move (arg));

Some spots were/are already only doing the release after
adding the breakpoint to the chain, but not all.  See e.g.,
set_raw_breakpoint.

The latter approach is my preferred for enforcing the pattern.

Otherwise both patches LGTM.

Thanks,
Pedro Alves


  reply	other threads:[~2017-08-21 10:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-20 13:54 [RFA 0/2] small clean ups in breakpoint allocation Tom Tromey
2017-08-20 14:06 ` [RFA 2/2] Change install_breakpoint to take a std::unique_ptr Tom Tromey
2017-08-21 10:12   ` Pedro Alves [this message]
2017-08-22  3:55     ` Tom Tromey
2017-08-22  8:56       ` Pedro Alves
2017-08-20 14:06 ` [RFA 1/2] Fix erroneous cleanup use in add_solib_catchpoint 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=b1d36e26-c505-54e8-79be-8c9953fe2fff@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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