From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id B6E863858D1E for ; Mon, 18 Apr 2022 20:09:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6E863858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f41.google.com with SMTP id b19so19735443wrh.11 for ; Mon, 18 Apr 2022 13:09:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=LJobY96hdOEMsMEZD80xwIH++nhxevUxWp2udi8cscI=; b=kVNjHsHSFOFQqMNxk1IToX8aC+0/7qZG9yiR8VmV33koNzBfkHFYsQpR8eM7uUU5qj LPaj4NjH8c1wANSUwmCK1ftdN/I7FxoQ29hXEp4tV3k8VwG3uDAALebRLh08DlUnRnXe 34W+/asVTJ9ZKDyFXNAam/1546lH3Iv1/bATp+yx2+6Cp8B9uejbOyp8skVtkEeCBQLW ZsojMhg5LUbJXar0HgWL4ruNcZH4miFz7Mk0jYs87lL2Fh+YTQsSK6phJHhCsy/CFfoM zIqmdS5tBaOpfol6vJdenFEgfJYKJE7YMXi0aZnQZ3BAyE76IaxWshgm42eO7h7EADWI ifvQ== X-Gm-Message-State: AOAM532A52SBG8fU60YCqYHkOXe7/fVt0NnHDGOIzsmHUM9nVmFRGVFD tkogod/b88/z5z+SMNxCy+c= X-Google-Smtp-Source: ABdhPJxpG8nTBOjlEUVTEwncOZabvrPaff6ppxyowmIPiEYeoW+oA41ZF04MS06Jr2u0xk+rRv8IYQ== X-Received: by 2002:a5d:64a3:0:b0:20a:7931:5b91 with SMTP id m3-20020a5d64a3000000b0020a79315b91mr9466546wrp.388.1650312591725; Mon, 18 Apr 2022 13:09:51 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id a16-20020a056000051000b00207b5d9f51fsm11079232wrf.41.2022.04.18.13.09.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 13:09:50 -0700 (PDT) Message-ID: <7600d515-bb50-3112-272b-d52745148473@palves.net> Date: Mon, 18 Apr 2022 21:09:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 2/5] gdbsupport: make gdb_abspath return an std::string Content-Language: en-US To: Tom Tromey , Simon Marchi via Gdb-patches Cc: Simon Marchi References: <20220414200137.3479373-1-simon.marchi@polymtl.ca> <20220414200137.3479373-2-simon.marchi@polymtl.ca> <8735iauql1.fsf@tromey.com> From: Pedro Alves In-Reply-To: <8735iauql1.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 18 Apr 2022 20:09:54 -0000 On 2022-04-18 20:41, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi via Gdb-patches writes: > > Simon> From: Simon Marchi > Simon> I'm trying to switch these functions to use std::string instead of char > Simon> arrays, as much as possible. Some callers benefit from it (can avoid > Simon> doing a copy of the result), while others suffer (have to make one more > Simon> copy). > > I hate copies but the main thing is to make sure none of them are in hot > paths. This seems fine on that front. > > Sometimes I wonder if gdb would be better off with its own string type > -- say a combination of gdb::unique_xmalloc_ptr and string_view. > This would interact more nicely with legacy code without sacrificing C++ > string methods. We could stick the string length in there as well if we > thought that was worthwhile. That'd be something like cstring_view, and a corresponding cstring type, I suppose: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1402r0.pdf https://github.com/breyerml/cstring_view I've seen other projects and public discussions on the interwebs adding or reporting use of such types.