This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Make breakpoint subclasses inherit from breakpoint, add virtual destructor
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