Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Make breakpoint subclasses inherit from breakpoint, add virtual destructor
Date: Wed, 03 May 2017 15:08:00 -0000	[thread overview]
Message-ID: <a614f0fe-4895-e155-2d82-eff19ea6d678@redhat.com> (raw)
In-Reply-To: <647998f3cb9e763dd7da94e9c9d675ca@polymtl.ca>

On 05/03/2017 03:36 PM, Simon Marchi wrote:
>>> I want to replace the vectors in the various breakpoint subclasses by
>>> std::vector.  The problem right now is that while breakpoint
>>> subclasses are constructed using new, they are not properly deleted.
>>

>> I think "properly deleted" might not be 100% accurate.
> 
> Hmm what do you suggest?  I could say:
> 
>   ... their C++ destructor is not being called.

Yeah.  It's not very important.  I was more referring to the fact that
there's actual destruction of the "subclasses" than talking about
properly-deleted-as-in-the-corresponding-dtor-is-called.

To be crystal clear, I'd put "subclasses" in quotes, and add an example:

~~~
 I want to replace the vectors in the various breakpoint subclasses by
 std::vector.  The problem right now is that while breakpoint
 "subclasses" are constructed using new, they are not properly deleted:

  struct syscall_catchpoint
  {
    /* The base class, old C style.  */
    struct breakpoint base;

    // trivial fields here
  };

  // first member is pointer-interconvertible.
  breakpoint *bp = (breakpoint *) new syscall_catchpoint ();

  // this calls ~breakpoint(), not ~syscall_catchpoint()...
  delete bp;  // in delete_breakpoint

 So if we add any non-trivially destructible field to
 syscall_catchpoint, it won't be properly destructed...
~~~

> You're right, it would be confusing and ugly to leave it with a
> half-baked-dual-hybrid system with C++ destructors and dtor ops.  I'll
> remove the dtor op, it shouldn't be much work, as you said.

Thanks much!

-- 
Pedro Alves


  reply	other threads:[~2017-05-03 15:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 19:19 Simon Marchi
2017-05-03 10:17 ` Pedro Alves
2017-05-03 14:36   ` Simon Marchi
2017-05-03 15:08     ` Pedro Alves [this message]
2017-05-03 15:23       ` Simon Marchi
2017-05-03 15:27         ` Pedro Alves

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=a614f0fe-4895-e155-2d82-eff19ea6d678@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    --cc=simon.marchi@polymtl.ca \
    /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