From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
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:23:00 -0000 [thread overview]
Message-ID: <d4018e4d4ae0f148102b5aaaa6125fc5@polymtl.ca> (raw)
In-Reply-To: <a614f0fe-4895-e155-2d82-eff19ea6d678@redhat.com>
On 2017-05-03 11:08, Pedro Alves wrote:
> 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...
Ok, this should make it clear.
> ~~~
>
>> 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!
FYI, I just looked at it, and it looks like the
momentary_breakpoint/longjmp_breakpoint hierarchy will cause a bit of
trouble. longjmp_breakpoint has a dtor, but no struct/class of its own,
so nowhere to put the destructor. I think that to do it correctly, I'll
have to introduce structs/classes for them and have:
breakpoint
^
|
momentary_breakpoint
^
|
longjmp_breakpoint
To keep it clean, it might be better if I introduced the structs/classes
for momentary_breakpoint and longjmp_breakpoint first with the old-style
inheritance, and then converted them to "real" inheritance along with
the other types.
I'll try that tonight, but if you have ideas in the mean time, I'm all
ears.
Simon
next prev parent reply other threads:[~2017-05-03 15:23 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
2017-05-03 15:23 ` Simon Marchi [this message]
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=d4018e4d4ae0f148102b5aaaa6125fc5@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.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