From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YIIuF4l0BmfTXQcAWB0awg (envelope-from ) for ; Wed, 09 Oct 2024 08:18:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XDSl0Q15; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 56FFB1E356; Wed, 9 Oct 2024 08:18:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=unavailable autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 70E081E354 for ; Wed, 9 Oct 2024 08:18:16 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACEE9385020B for ; Wed, 9 Oct 2024 12:18:15 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 9F056385DDC3 for ; Wed, 9 Oct 2024 12:17:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F056385DDC3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9F056385DDC3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728476276; cv=none; b=rYvMCdNWuVqUynLxcFR2DsrIGExVH9qjYiPq1XgU8Sc1oGyBdn7Eba4Owt3dGM5nkmvyg0q4uwqBPjDj7DbrzuHkRwjE9kHG8JaalciEI38nWJFqMAhIx8W0LR/uv4lPG/z25RWuxjlBk7Ziqufe7P1Vn86xbjlOgZxW8yoGSSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728476276; c=relaxed/simple; bh=QqeY6AdqsTFPkhDP3mP9yp9u9MhAVMKK8YH46iK4Y7Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ByvDLtitsM3MjF6sfYIdZRSZ6g94XUUc8ENDauzuxhCS7BmAGZaW7cDV5jDjpq83qckHlFq5Gcl+zXzHL2UwTkE9Jq6L2ggdkFRWGIHtDXA4hkANxq6cF+3G8CKxPHA4JGi9YaFTWRuKWv9hT+FlkdkuEWJpTVx7vPjMLNQg9dM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728476274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/i6gzlXlcjAM/0xmSoCGI0Fwx+dsEIfMbC8znK9Bq1s=; b=XDSl0Q15CTWTeSzFXhxPATfONVkR06m6WJK/bXBcU74nPBXLJ5N7hezkCGN7MMbWBi9stX kTMT/k/2zyBK0LonxfzGmr8EqnWEkoP3I8wm1BNszX5Vwgxcua5PHUArOHGVqPLZ64W+Ds 2gNlBvlmQ4qb+xTvCqV2UebILUp1TkA= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-PjexbjEEM7WG3bRmGPYqGA-1; Wed, 09 Oct 2024 08:17:53 -0400 X-MC-Unique: PjexbjEEM7WG3bRmGPYqGA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb1c04af0bso3803711fa.1 for ; Wed, 09 Oct 2024 05:17:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728476271; x=1729081071; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/i6gzlXlcjAM/0xmSoCGI0Fwx+dsEIfMbC8znK9Bq1s=; b=AdnVZJ5/UcJ/12A+pT5rL969Job5juI8RbRha/37jInKrgQg2GaRNw/q1oS66kW3wB 9jMrMUdb5VhPo49GxtYsDla6Hz62h89oM0qbgRJOchdFXW+96muazjwUA6bC6m0NELe0 et2Dxan8L4rMeOfB2hSuCa5f1sjw16+6c43c0KoIFpIu9IFmVESZlINXBtH3Usjb16Sx xlKQ41MB2hMJoTnIUgt7UHEfm/QjB0SBeHUUVc4weq6PE1cC3FmY8QUfgVOtKdLUXbsh 6rNxTn+bUodnhF9SXHwEKOpKm0RI+fkL1SKWA8RvW0wZ1Y3wTNGhSUTiNC24nUJTQ002 Jv9w== X-Forwarded-Encrypted: i=1; AJvYcCV+Yrkd56IAHSzc37AoJeSVzHOMkMRpjv+biZQJjPZwcg5bIvhArxsdbLVLlvhAQM7zPKR/H5fLeNWfjg==@sourceware.org X-Gm-Message-State: AOJu0Yype+zU/I79rV1a1zIC2RxRT/mVMSK/qAMDSQ7z45NkS2+erUrB gH5hQLnmkrlRQ+tG9aTEjPQ0CVkuADOyyh7i3J7e2Bm9FoxDfo3TxJDvqAMJKig5y6j5zfKkotL an6eaaaq8PzkgT9ar9fQmppcAlXI95RPvu27OUdJawT38N29e3WQCkPiJmQVdejFsVls= X-Received: by 2002:a2e:bea3:0:b0:2fa:e658:27b4 with SMTP id 38308e7fff4ca-2fb18720a67mr15305241fa.4.1728476271481; Wed, 09 Oct 2024 05:17:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDxeQxzJT8Q1FPH+OcqSYV5l0Fw+0xGB+iqrpnVZ4YnHsRo22Amx/sJqC/er5UZf0iQj6F/g== X-Received: by 2002:a2e:bea3:0:b0:2fa:e658:27b4 with SMTP id 38308e7fff4ca-2fb18720a67mr15304981fa.4.1728476270994; Wed, 09 Oct 2024 05:17:50 -0700 (PDT) Received: from localhost ([195.213.152.26]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e0594eb0sm5418870a12.6.2024.10.09.05.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 05:17:50 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH 1/3] gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr In-Reply-To: <952e0e55-b99c-4c24-ae1c-7f3c502bb826@simark.ca> References: <87msjdbklm.fsf@redhat.com> <952e0e55-b99c-4c24-ae1c-7f3c502bb826@simark.ca> Date: Wed, 09 Oct 2024 13:17:50 +0100 Message-ID: <87ed4pbhch.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Simon Marchi writes: > On 2024-10-09 07:07, Andrew Burgess wrote: >> Simon Marchi writes: >> >>> On 2024-10-06 14:37, Andrew Burgess wrote: >>>> Convert target_desc::arch and target_desc::osabi from 'const char*' to >>>> gdb::unique_xmalloc_ptr. This also allows us to remove the user >>>> defined ~target_desc destructor. >>>> >>>> I doubt it ever actually occurred, but in theory at least, there was a >>>> memory leak in set_tdesc_architecture and set_tdesc_osabi where the >>>> member variables were assigned without freeing any previous >>>> value... but I suspect that usually these fields are only set once. >>>> >>>> There should be no user visible changes after this commit. >>> >>> Could they be std::string instead? >> >> I considered this, but that would, I think, require wider reaching >> changes as the API to add the osabi to the returned tdesc passes the >> information via 'const char *'. This approach added the memory safety >> without requiring any further changes. >> >> If you'd prefer std::string be used then let me know and I'll update >> things. > > Up to you, I don't mind, it can be done later. I'll leave it then if that's OK. My reason is that, if the osbi member variable changes to std::string then it makes sense that tdesc_osabi_name return 'const std::string &'. Which means that tdesc_osabi_name in GDB will also need to return 'const std::string &', but on the GDB side we store 'enum gdb_osabi' rather than the actual string ... so now that code needs updating too. I only wanted to fix this so that I could call set_tdesc_osbi without leaking memory, and gdb::unique_xmalloc_ptr, which we use in loads of places, achieves that, and leaves the API untouched. But I'm not against changing to std::string if someone's keen :) Thanks, Andrew