From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 90BCC3858D20 for ; Thu, 7 Sep 2023 14:09:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90BCC3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 387E949m001922 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 7 Sep 2023 10:09:09 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 387E949m001922 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1694095749; bh=Pf/OkIuJhII8eSq3UEbhlWvB+pzbWKVtOgfUsYwTKno=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nByymhDU+/7pF0QLEXO8DZju/JaYi+hqCdz1THRB19xc/7MIQG1g97/If1d3PGgYd UKTOlLN+l5gml0FWtu6Dt1UulEgewtMEf/StQLjxWI+5qFe54WMFj40DEJaPbmn6U1 9eXG83dByLfL605eOXtRRGRNoUQUt0VU+uMGTt6E= Received: from [172.16.0.192] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 8AD9B1E092; Thu, 7 Sep 2023 10:09:04 -0400 (EDT) Message-ID: <6d2374cd-a3c2-439a-a3be-8af63ef7a299@polymtl.ca> Date: Thu, 7 Sep 2023 10:09:03 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb: c++ify btrace_target_info Content-Language: fr To: Markus Metzger , gdb-patches@sourceware.org Cc: vries@gcc.gnu.org References: <20230907104444.1281331-1-markus.t.metzger@intel.com> From: Simon Marchi In-Reply-To: <20230907104444.1281331-1-markus.t.metzger@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 7 Sep 2023 14:09:04 +0000 X-Spam-Status: No, score=-3037.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 9/7/23 06:44, Markus Metzger wrote: > Following the example of private_thread_info and private_inferior, turn > struct btrace_target_info into a small class hierarchy. > > Fixes PR gdb/30751. > --- > gdb/nat/linux-btrace.c | 50 ++++++++++++++++++++++++++----------- > gdb/nat/linux-btrace.h | 11 +++++++- > gdb/remote.c | 48 ++++++++++++++++++++++++++--------- > gdbsupport/btrace-common.cc | 2 ++ > gdbsupport/btrace-common.h | 5 +++- > 5 files changed, 87 insertions(+), 29 deletions(-) > > diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c > index c5b3f1c93cf..eefcabf509f 100644 > --- a/gdb/nat/linux-btrace.c > +++ b/gdb/nat/linux-btrace.c > @@ -277,7 +277,7 @@ perf_event_sample_ok (const struct perf_event_sample *sample) > part at the end and its upper part at the beginning of the buffer. */ > > static std::vector * > -perf_event_read_bts (struct btrace_target_info* tinfo, const uint8_t *begin, > +perf_event_read_bts (linux_btrace_target_info* tinfo, const uint8_t *begin, Could you fix the misplaced * while at it? > @@ -81,8 +82,16 @@ struct btrace_tinfo_pt > #endif /* HAVE_LINUX_PERF_EVENT_H */ > > /* Branch trace target information per thread. */ > -struct btrace_target_info > +struct linux_btrace_target_info final : public btrace_target_info > { > + linux_btrace_target_info (ptid_t ptid, const btrace_config &conf) > + : ptid (ptid), conf (conf), variant ({}) > + {} It seems like that this constructor is unused. > + > + linux_btrace_target_info (ptid_t ptid) > + : ptid (ptid), conf ({}), variant ({}) > + {} I read your reply about zero-initializing the conf and variant fields. I think that's fine, it's probably necessary since the users initialize the relevant fields right after, but it's on the safer side since we are replacing XCNEW. But I would suggest putting the {} in the member declaration directly (which we often do when C++ifying things): btrace_config conf {}; union { /* CONF.FORMAT == BTRACE_FORMAT_BTS. */ struct btrace_tinfo_bts bts; /* CONF.FORMAT == BTRACE_FORMAT_PT. */ struct btrace_tinfo_pt pt; } variant {}; With those fixed: Approved-By: Simon Marchi Simon