From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4YbsJmki3GNNXCgAWB0awg (envelope-from ) for ; Thu, 02 Feb 2023 15:51:53 -0500 Received: by simark.ca (Postfix, from userid 112) id 932311E128; Thu, 2 Feb 2023 15:51:53 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=a9WH0kPU; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 39D211E110 for ; Thu, 2 Feb 2023 15:51:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A18073858C74 for ; Thu, 2 Feb 2023 20:51:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A18073858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675371112; bh=zI/pfcYtDcYqVkU2G7Q08pTEl9qVvtoHpzkf7Hiv+LI=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=a9WH0kPUJAZTXUA9q7YNmW8MKepmf+8G5qEUUSj9DMNvhTNRWpqmGmtftrzvTTktZ YI4j+nBd9/n3W1YLd6KVjUPl9FfVTIxEXo1TWhyQIgWE9YKKvb2YQ4uPTxjlt6FKDU 2KudOXe4yPTAwi2o8rO1Qsk9XA53qePoICJvg954= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 163EE3858C52 for ; Thu, 2 Feb 2023 20:51:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 163EE3858C52 Received: from [10.0.0.11] (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id B6DAF1E110; Thu, 2 Feb 2023 15:51:30 -0500 (EST) Message-ID: <45bd55f5-d33b-58f7-0ac6-13d31c4d03f5@simark.ca> Date: Thu, 2 Feb 2023 15:51:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v3 5/8] gdbserver: Transmit target description ID in thread list and stop reply To: Thiago Jung Bauermann Cc: Andrew Burgess , Thiago Jung Bauermann via Gdb-patches , Simon Marchi References: <20230130044518.3322695-1-thiago.bauermann@linaro.org> <20230130044518.3322695-6-thiago.bauermann@linaro.org> <87bkmdtp4n.fsf@redhat.com> <502f0bd0-9b18-9a31-0094-7a9bd4778bd2@simark.ca> <87r0v7alq1.fsf@linaro.org> Content-Language: en-US In-Reply-To: <87r0v7alq1.fsf@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2/2/23 14:52, Thiago Jung Bauermann wrote: > > Simon Marchi writes: > >>> Having read some of the later patches, I have some additional thoughts >>> here: >>> >>> I think we should make it explicit here that IDs are connection wide, >>> not per-process. We should also make it clear that GDB might[1] cache >>> target descriptions per remote connection, and so a remote target should >>> not reuse a target description ID except where the target description is >>> identical. > > Ah, good point. I will make that clarification. > >>> [1] I say "GDB might" here because if we say "GDB will" then this would >>> imply each target description will only be asked for once. And I >>> figure, why be overly restrictive. >> >> Thanks for pointing this out, I had the same thought while reading the >> patch. >> >> In my original idea, I imagined that target description IDs could be >> some hashes computed from the XML content (a bit like git hashes or ELF >> build IDs), such that a given target description would always have the >> same ID. This would give clients the possibility to cache target >> descriptions locally, a bit like the index cache. It did sound nice, >> but perhaps it's not really important. > > Ah, sorry I misunderstood this part of your suggestion. I thought that > the caching was supposed to be limited to the duration of the connection, > and thus the m_tdescs map in struct remote state would be enough to > provide that functionality. Do you mean that the cache should be on > disk, so that it survives GDB quitting? I can look into that if you want > and implement it, if not complicated. To be clear, I'm not asking you to implement an on-disk cache, I'm just trying to think about what the limitations of the proposed solution are. Because mistakes or shortcomings introduced in the remote protocol (like any API / ABI meant to be stable) are difficult to fix afterwards. If there is a chance we want to do an on-disk cache (or share a cache between multiple concurrent connections), we should think about that now. On one hand, perhaps we consider that target descriptions are small enough that there's no point in having a persistent cache like that. The time to fetch each target description once per connection is probably insignificant. On the other hand, perhaps doing the hash approach is easy enough that we might as well do it, and that just leaves more doors open. In my mind, as a start, we could just pass the XML of the tdesc through a sha256 function, possibly doing something more sophisticated later (this means the hash of a given tdesc could change over time, but still two identical hashes mean identical tdescs). However, I don't think there are sha256 functions built in on the OSes we want to support, so we'd have to depend on some external library. And that complicates things quite a bit... We already have a CRC32 function in gdbserver, but I don't know if that's good enough to be confident there won't be collisions. > In this case, I think the tdesc ID should be of the format > :, so that can be “sha1”, “sha256” etc to > indicate that is a hash with the given algo, or even > “number” to indicate that it's a simple integer like it is today. > > Perhaps we can do the prefix thing even if not implementing the cache, > to leave the possibility of adding it in the future? I think I would choose between hash and number, but not do both, I don't see the need to have both. Simon