From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by sourceware.org (Postfix) with ESMTPS id 2DC873851C21 for ; Thu, 25 Jun 2020 18:09:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2DC873851C21 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wr1-f66.google.com with SMTP id f7so3843913wrw.1 for ; Thu, 25 Jun 2020 11:09:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xX0RLZcMnnVhcHeIhjHqlJUiov7gJOG/ZiLJinHkpZw=; b=k6dtvtA1X1OIdw7883667f99BUDX7F6PJca8s8kEbwncPz1L9h/Vz8cXLPj1rGK8t+ +0I6tauC+kkKbNibBk7SGSFnMs0rcMRjP/PiynkvYE2eCkyXeAGhRB9KDCOKu2ZaaxNz /UonmzcW5fDnYQflXTgXzkowzVPwSktFwaFB+vR8mW5K4oZ7ldQQ2aTxSBZZiq5pv1rF IpIPNYdlKBU7b7F1RrrzYkGFBgFwrtU4NTc5r5QjKBrwAea9Cyhp/7JgFBnD+eZqjkQ9 eFwcjxIzWZ66j58y8cwazkQC3z4OYU/t2Iu3YUDfMTTjlSP8lW6uupqi0BEeqZs0sIp1 BzbQ== X-Gm-Message-State: AOAM531C24CUGXc/i9XrLhOoUD8MBhx+sI2MOav+/+jvybU5iy1+OZ0O Gq8YxXwut+K2lbGIAvBzEN4FTjMF26w= X-Google-Smtp-Source: ABdhPJwdXZFCDDWrgR+dXy06PkWrUem5pto1/rVfwufhBxqQTzgZ8zZRS1jVC9PQ6syx7CxqI+nLcw== X-Received: by 2002:a5d:4e48:: with SMTP id r8mr18726603wrt.309.1593108546787; Thu, 25 Jun 2020 11:09:06 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id 65sm13608350wma.48.2020.06.25.11.09.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Jun 2020 11:09:05 -0700 (PDT) Subject: Re: [PATCH] gdb: make inferior::terminal a unique ptr To: Luis Machado , Christian Biesinger , Simon Marchi References: <20200625155517.32173-1-simon.marchi@efficios.com> <5b6a39ca-b29e-262b-1f0c-04fbd21a0c31@palves.net> <7ae6c907-4507-e0c3-3a52-6416a8203987@linaro.org> Cc: gdb-patches From: Pedro Alves Message-ID: <04581d9f-2d9b-304c-e223-657f312c4549@palves.net> Date: Thu, 25 Jun 2020 19:09:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <7ae6c907-4507-e0c3-3a52-6416a8203987@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2020 18:09:09 -0000 On 6/25/20 6:59 PM, Luis Machado wrote: > On 6/25/20 2:28 PM, Pedro Alves wrote: >> On 6/25/20 6:18 PM, Christian Biesinger via Gdb-patches wrote: >>> On Thu, Jun 25, 2020 at 10:55 AM Simon Marchi via Gdb-patches >>> wrote: >>>> -    current_inferior ()->terminal = xstrdup (terminal_name); >>>> +    current_inferior ()->terminal.reset (xstrdup (terminal_name)); >>> >>> Perhaps it really should be a std::string? >> >> I think there's no good reason for that.  It's a string that doesn't >> ever need to grow/shrink.  And then its use is to pass down to >> a syscall that accepts C-style null-terminated strings: > > I tend to agree with Christian. I suppose one positive outcome is to make the code less cumbersome. It's not like xstrdup is great to read anyway. > > Are we worried about performance implications of passing std::string's around like this? It's more like -- why store a fat 32 bytes object in the inferior when a pointer does just as well. There's no code that would benefit from making this a string, like, there's no strlen call that that would avoid. The code that wants to consume this wants a pointer. A method-based interface like I pointed at in that github commit exposes a pointer. So it would just be implementation detail. Thanks, Pedro Alves