From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17197 invoked by alias); 11 Aug 2017 20:13:22 -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 17186 invoked by uid 89); 11 Aug 2017 20:13:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=lay, Hx-languages-length:2378 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Aug 2017 20:13:18 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0204C72FC8; Fri, 11 Aug 2017 20:13:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0204C72FC8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F51617D2A; Fri, 11 Aug 2017 20:13:16 +0000 (UTC) Subject: Re: [PATCH 0/3] Create arch_lwp_info class hierarchy To: Simon Marchi , gdb-patches@sourceware.org References: <1500892797-7523-1-git-send-email-simon.marchi@ericsson.com> From: Pedro Alves Message-ID: <22f9058d-52de-293a-eef8-6af1572955d0@redhat.com> Date: Fri, 11 Aug 2017 20:13: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: <1500892797-7523-1-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-08/txt/msg00255.txt.bz2 On 07/24/2017 11:39 AM, Simon Marchi wrote: > I have the goal of "poisoning" the XNEW/xfree-family of functions, so > that we catch their usages with non-POD types. A few things need to be > fixed in the mean time, this is one. > > The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the > private lwp data of type arch_lwp_info. However, that type is opaque > from its point of view, as its defined differently in each arch-specific > implementation. This trips on the std::is_pod check, since the > compiler can't tell whether the type is POD or not if it doesn't know > about it. > > I think the right fix going forward is to make a hierachy out of these > structs, so that they all inherit from a common base. That's what patch > 3 does. Patches 1 and 2 simply C++ify the GDB and GDBserver lwp_info > structures so that it's possible to use unique_ptr fields. > > Simon Marchi (3): > gdb lwp_info: Add destructor, initialize fields, use new/delete > gdbserver lwp_info: Initialize fields, use new/delete > Create arch_lwp_info class hierarchy Looks fine to me as well. Let me just lay down some thoughts: We don't really need to make these types have vtable pointers / don't really need to polymorphic, since there's only ever going to be one arch type in a build. So we could instead move the arch-specific definitions to arch-specific headers, still name the arch-specific types and then have linux-low.c etc. include it. That way, we'd use arch_lwp_info throughout just like today. arch_lwp_info would just be different types defined in different headers depending on arch. I.e., e.g., in a linux-arm-low.h: struct arch_lwp_info : public arch_lwp_info_base { // arm bits. }; and then in linux-low.h we'd have #ifdef __arm__ # include "linux-arm-low.h" #elif defined __i686__ # include "linux-x86-low.h" #elif ... ... #endif A follow up thing that we could do is have arch_lwp_info inherit from lwp_info and always allocate arch_lwp_info objects. Or for clarity, rename lwp_info to lwp_info_base and make the arch version be The lwp_info type. I.e., e.g., in linux-arm-low.h: struct lwp_info : public lwp_info_base { // arm bits. }; This would avoid the double/separate allocation of lwp_info + arch_lwp_info. Anyway, just ideas. I'm really fine with what you have. Thanks, Pedro Alves