[PATCH v3] gdb: c++ify btrace_target_info

Andrew Burgess aburgess@redhat.com
Mon Sep 11 09:17:15 GMT 2023


"Metzger, Markus T via Gdb-patches" <gdb-patches@sourceware.org> writes:

> Hello Simon,
>
>>> -  gdb::unique_xmalloc_ptr<btrace_target_info> tinfo
>>> -    (XCNEW (btrace_target_info));
>>> -  tinfo->ptid = ptid;
>>> +  std::unique_ptr<linux_btrace_target_info> tinfo
>>> +    { new linux_btrace_target_info { ptid } };
>>
>>We recently added a gdb::make_unique function, it would make sense to
>>you use it here (it will eventually become std::make_unique once we
>>migrate to C++ 14).
>>
>>So this could be written as:
>>
>>  auto tinfo = gdb::make_unique<linux_btrace_target_info> (ptid);
>
> I'm not a fan of 'auto'.  So this becomes
>
>   std::unique_ptr<linux_btrace_target_info> tinfo
>     { gdb::make_unique<linux_btrace_target_info> (ptid) };

This really doesn't feel like an improvement.

I also try to avoid excessive use of auto, so I dislike things like:

  auto var = some_function (....);

because there's no hint what the type of var actually is (without
looking at `some_function`).  But in the case of:

  auto var = gdb::make_unique<type> (...);

The type of var is right there on the line, so duplicating the type
information is just noise.  For me this is a perfect use of auto.

Just my $0.02 worth.

Thanks,
Andrew


>
>>Approved-By: Simon Marchi <simon.marchi@efficios.com>
>
> Pushed.
>
> thanks,
> markus.
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list