From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QHzDEUemBmctkQcAWB0awg (envelope-from ) for ; Wed, 09 Oct 2024 11:50:31 -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=KkZ5pPgv; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 42D681E356; Wed, 9 Oct 2024 11:50:31 -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 A5F711E05C for ; Wed, 9 Oct 2024 11:50:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 418BA38650D4 for ; Wed, 9 Oct 2024 15:50:30 +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 73743385DDD7 for ; Wed, 9 Oct 2024 15:50:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73743385DDD7 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 73743385DDD7 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=1728489008; cv=none; b=cYBbtfY/ghl6gUIug6H7byMx7GyFPkPQCI8Rm3Tt3YJhN04JUNGL+O9idv4sV0cQPFBSIaCWe81GkJ5Dohus/CE1QRB78ErO1kzqM4UEPoYtV9ripPsoSxGem0L0/WpxTdgF9CIuIsT+hmKpBWaJPYeCR4icOM64y03NwP9d3es= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728489008; c=relaxed/simple; bh=p1xvopc5J59oy17kSd4zJNsw9rlbaPjuUZQTUpZAN1M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ppK8O3esxAjZvlc51N2+9l8RDyOCYxS3i+x+lhMTEJpVD0PWDBlWFhvrrok/lsDtCEX+cZJl6JUyiMdCo9uoQl/b43/TegjMFNEYykFT7cTat2EUEu9zIoYMcjkfqoNEd+Glsv2X1MtYnTn1n19FaHvuJScStgXK7BcPhfD/5P4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728489007; 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=MFqv9olRQ8AXMB9vUuJwdyaugd4nZxLZEjea1cyeJLc=; b=KkZ5pPgv7CPjHi/gP5366/wCQm5jCgmBzm/0AGE6apl5nzh3bW/rHYtlEQySCmxouugE/K z9IPnrouWKPi+OEsTHrP4DDVRqIFHWRASgQO8v1slxTHTvueFTG5ThxJzlHEY3x2C6f3jX wD7lJSyURNJkHiI+Nl1n8VsKzZGz0cQ= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-ibapxqIwP9qWmbBCJs-cUQ-1; Wed, 09 Oct 2024 11:50:06 -0400 X-MC-Unique: ibapxqIwP9qWmbBCJs-cUQ-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c8821bf089so5715966a12.0 for ; Wed, 09 Oct 2024 08:50:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728489005; x=1729093805; 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=MFqv9olRQ8AXMB9vUuJwdyaugd4nZxLZEjea1cyeJLc=; b=o+yL0p/+nCE7T/CLops9g6la8y/mj7E914yamFKR9HK9uy9mfsZs2vP91l22g/tzn4 lhGkYCS7OGyO9Vs6ULI325sIG0B0ApmvJ35kbjdZEoeGMTJMwrjJ1lO6UixwtN4tdtDg +GZs8aQEO0/VhSqh/NinLOFymZ+qwlMZ8akkuStzdRxFjcguF/zoAA1GRFDutf1TGXVj d15TpfsHlap5mPQVgph0D7feOb6hn1+5OBzUaKwUEFHR6Q8BxTuGuSNsc5iZ+TQjIlG8 Vi9UNluLpvPLyex4vTlBipg4cFnXRKkPxUQlelz37iMv9OnsI1EYREmqrsy4CKSXS/Lb Truw== X-Forwarded-Encrypted: i=1; AJvYcCW8LY9EUL9oB+Jq5e5iipumntgCVTLbAEMe+aYqgmxBFJO/r8v3CqO+IPLQ1CbxNIJGCfXrlTOPQnpyAA==@sourceware.org X-Gm-Message-State: AOJu0YzpcIewWW4FgKKOsDo3qTzj+Vi7vd7NSId1Unqp6T2qqMLfifXQ Oxy5UZGQtSUbrRL/YVZ9dgWY1abJLb/p/+iTbVTlHe7raQXzcRPdH240awCPyNPekgyFzZkv7CZ iiTVK3cB2dByaBR4jmQM13bZyG6GjwWANvkUWJ5E/Ik1qieqcfHQEWkHV+lkwt3o7MJs= X-Received: by 2002:a05:6402:35c5:b0:5c8:84d6:c995 with SMTP id 4fb4d7f45d1cf-5c932554b91mr224753a12.25.1728489004831; Wed, 09 Oct 2024 08:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF81WCo/4C04K0H3NrfaxP1jjGr80TKCqWsi2BghCRU3EwwKwFNP4LNrmheU8uIVJ/rplKjFA== X-Received: by 2002:a05:6402:35c5:b0:5c8:84d6:c995 with SMTP id 4fb4d7f45d1cf-5c932554b91mr224723a12.25.1728489004376; Wed, 09 Oct 2024 08:50:04 -0700 (PDT) Received: from localhost ([195.213.152.26]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c930c83850sm171646a12.74.2024.10.09.08.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 08:50:04 -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: <527e0c5d-5ac3-488a-a1ce-e8a1177f6a7e@simark.ca> References: <87msjdbklm.fsf@redhat.com> <952e0e55-b99c-4c24-ae1c-7f3c502bb826@simark.ca> <87ed4pbhch.fsf@redhat.com> <527e0c5d-5ac3-488a-a1ce-e8a1177f6a7e@simark.ca> Date: Wed, 09 Oct 2024 16:50:03 +0100 Message-ID: <87bjztb7is.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 08:17, Andrew Burgess wrote: >> 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 :) > > Yeah, it makes sense to take smaller, simpler steps. I might do it once > your series is merged, to scratch my itch :). Sounds good. I'll hold off merging until you've had a chance to check out v2 w.r.t the switch to use the 'enum gdb_osabi' instead of passing strings. Thanks, Andrew