From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60398 invoked by alias); 3 May 2017 15:08:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 60376 invoked by uid 89); 3 May 2017 15:08:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=crystal X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 May 2017 15:08:48 +0000 Received: by mail-wr0-f180.google.com with SMTP id l50so110415063wrc.3 for ; Wed, 03 May 2017 08:08:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=1F+PlkdM4mEcTwdK4cWOzkh1wcAuZcFr0T+KZnAlkDs=; b=X9N/RHXriyF6al0DoYzwL2pq3swj940H723gTmC9LXyzFGkwFWK/8EVr+0HO0kYQA/ aTVwcb0477hNe4bloFvgCGKJy00TP5eSAZNzj72LUr/QT4Emwaj9cib8LuWmdcmDImB2 5DksKbVDbLp5hLHUVpI6cYs24QqOFfZKC/nW0bfeOZ72Mp+zo2X1eXD4iXkpJ2PruYZB A3OU02mzaVH3Okp38lxEegu6Obwpr2FwoiKgy83WpdGt86J8UTr0XyA7/LnzfVsfVFD2 GMclhl1RWtVpTrUlVf49o/MRafBRodwgSQxYNOk1FkP2kdONilXu8xa8NouwCyz81Oon RQRg== X-Gm-Message-State: AN3rC/6g99qWcY8KnvDtVQXbQPYwHRgYWFfBUW4zgLw90yrH5BsvMRJw DyQtcsyHT2PpeN2R X-Received: by 10.223.131.130 with SMTP id 2mr24166459wre.104.1493824128424; Wed, 03 May 2017 08:08:48 -0700 (PDT) Received: from [192.168.0.102] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id r29sm19715016wra.18.2017.05.03.08.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 May 2017 08:08:47 -0700 (PDT) Subject: Re: [PATCH] Make breakpoint subclasses inherit from breakpoint, add virtual destructor To: Simon Marchi References: <20170502191811.32333-1-simon.marchi@ericsson.com> <0f7aaf0f-6498-2b2e-7cc9-e7656fbc6079@redhat.com> <647998f3cb9e763dd7da94e9c9d675ca@polymtl.ca> Cc: Simon Marchi , gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Wed, 03 May 2017 15:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <647998f3cb9e763dd7da94e9c9d675ca@polymtl.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-05/txt/msg00058.txt.bz2 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