From: Simon Marchi <simon.marchi@polymtl.ca>
To: Markus Metzger <markus.t.metzger@intel.com>, gdb-patches@sourceware.org
Cc: vries@gcc.gnu.org
Subject: Re: [PATCH v2] gdb: c++ify btrace_target_info
Date: Thu, 7 Sep 2023 10:09:03 -0400 [thread overview]
Message-ID: <6d2374cd-a3c2-439a-a3be-8af63ef7a299@polymtl.ca> (raw)
In-Reply-To: <20230907104444.1281331-1-markus.t.metzger@intel.com>
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<btrace_block> *
> -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.marchi@efficios.com>
Simon
next prev parent reply other threads:[~2023-09-07 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 10:44 Markus Metzger
2023-09-07 14:09 ` Simon Marchi [this message]
2023-09-08 10:53 ` Metzger, Markus T
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=6d2374cd-a3c2-439a-a3be-8af63ef7a299@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=vries@gcc.gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).