From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 931D23856DE8 for ; Mon, 11 Sep 2023 14:25:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 931D23856DE8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694442315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7hpePVQLyIxwVNI2eF8uEKg/l5R3w0vuMbG2H58wVvg=; b=NRjaEPZH05w+HNvECo0iWY6HmlRzaDYv9tbmTai2xXAet9zKwdX3BlOaiU3h3bUvcTsCFJ WVpEuML9mWSH21eDaQU7//2PXsV8QmXYm1Rb43XiOm+Qj/fJHfCP5m1afOhE9vCcrRkawM egoNcaU0/dOqbMjIOAegI+CSHsxxlic= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-LevU_qg9Pk-AZpl3cztR1g-1; Mon, 11 Sep 2023 10:25:14 -0400 X-MC-Unique: LevU_qg9Pk-AZpl3cztR1g-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-31f46ccee0fso2197245f8f.1 for ; Mon, 11 Sep 2023 07:25:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694442312; x=1695047112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7hpePVQLyIxwVNI2eF8uEKg/l5R3w0vuMbG2H58wVvg=; b=NK4WYbclT0yAOmZX9um8H6pu4mjVeNHVclBGZveKhzZCadOuVzrlchnnl6MqkOe56o z7QvRIFwUPYhUpF5unfiLMuTHli+qiovPgz8V+7c4VeuUHExjpw6o4YOLg6U+SVa1r63 MVNVZSZCT5n5L3QzuU6D7wxG/OlU4GWV9GNGlK2O01uSS3qH2iExMzQ5hhDfUCQXZXi2 QnwJzfjUGVMx7PoPR01bLELwt7rEBfqfwvtFF/NzRTBEfYEjCNcTyQ5XjY7ENsNhdEue Gm1caOR1BGxJO5wMnHNDbPJC0lNsHRQZtsAGwcZtKyRoOpYvUcFG5uk1hKrNelyg8XVO 3A9g== X-Gm-Message-State: AOJu0Yy2ne2ENa8mqLZ3e5Xp3uZ8/6RQ1I5qCnIIpsNu6ZwRlslFgz07 487k7BOpQjrivWqFu67Ag7SzXp2VvvyUW4TKNuOPDz/xJ6S7AFL+muyup5zGGeimF3pc1prIPzE k2mz6b1X+L9cb+bYC5bF1wr/4TiMR0g== X-Received: by 2002:a5d:4486:0:b0:319:789f:fcda with SMTP id j6-20020a5d4486000000b00319789ffcdamr9790895wrq.9.1694442312707; Mon, 11 Sep 2023 07:25:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+ArHvlN6ICIgxwDe0RFa2qulHyKe9f9g++5dvQrn0RMu3RQ4hqD7Dl9q426p0qw9AcQSMIg== X-Received: by 2002:a5d:4486:0:b0:319:789f:fcda with SMTP id j6-20020a5d4486000000b00319789ffcdamr9790885wrq.9.1694442312396; Mon, 11 Sep 2023 07:25:12 -0700 (PDT) Received: from localhost (197.126.90.146.dyn.plus.net. [146.90.126.197]) by smtp.gmail.com with ESMTPSA id y13-20020adffa4d000000b0031f5f0d0be0sm10140426wrr.31.2023.09.11.07.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 07:25:11 -0700 (PDT) From: Andrew Burgess To: "Metzger, Markus T" , Simon Marchi Cc: "vries@gcc.gnu.org" , "gdb-patches@sourceware.org" Subject: RE: [PATCH v3] gdb: c++ify btrace_target_info In-Reply-To: References: <20230908105319.1963979-1-markus.t.metzger@intel.com> <0d7782da-940c-40da-a511-4f8a36b5455c@polymtl.ca> <87r0n5kr1g.fsf@redhat.com> Date: Mon, 11 Sep 2023 15:25:11 +0100 Message-ID: <87tts0kcs8.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: "Metzger, Markus T" writes: > Hello Andrew, > >>>>> - gdb::unique_xmalloc_ptr tinfo >>>>> - (XCNEW (btrace_target_info)); >>>>> - tinfo->ptid = ptid; >>>>> + std::unique_ptr 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 (ptid); >>> >>> I'm not a fan of 'auto'. So this becomes >>> >>> std::unique_ptr tinfo >>> { gdb::make_unique (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 (...); >> >>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. > > A related question is whether > > auto ptr { gdb::make_unique (...) } > > is really any better than > > std::unique_ptr ptr { new type (...) } Well std::make_unique<> exists, so I think like it or not, that's the preferred C++ approach. I thought (though I don't claim to be an expert) that, in general, direct calls to 'new' were to be avoided in C++ code. Thanks, Andrew