From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by sourceware.org (Postfix) with ESMTPS id 966513858C52 for ; Thu, 21 Sep 2023 14:07:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 966513858C52 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-wm1-f54.google.com with SMTP id 5b1f17b1804b1-402d499580dso11831615e9.1 for ; Thu, 21 Sep 2023 07:07:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695305240; x=1695910040; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=y+Dfkc14liMBwKC89BgjVMMQ0KFYZa7C1k3NmygUWAA=; b=Dcmim0AcWC1qrMPG8SOTNaCZWcOBOB2sTLg07inifbsfmFBruCmLuHeUOJ/azEP3Qn 6LrcxKGn1kgWKRzAAeBEYINqw4/+H6mh3LoE9ZPPCzLXy0KzfOBwUTqctrSyyMF+IZ4S bXNDV7dy1bv2O1hnaqhOfbbw0EHpSAc6mEJL/vhRjj99bD8i6Y/1dpOgt1EfROxK6pOm B+547Fs6j+8IBB0+88jsxtUWofeHWMBT7mLHceIcfRTb94Ql9LmpN7tx37pWD2ABhrpO V+hjpPl4xK7UluK0Jsuo9k7Go4liDucgax2InACLxrDsIHif2PNgwcgpKCgc3ozwEQMI CgFQ== X-Gm-Message-State: AOJu0YwocFJ1rufHZt1pAeBTjz9s/kcGttn1C58wk99sOygDfpmDtd0M P/YqFw0M1JuN3Lv0TN1WhQo= X-Google-Smtp-Source: AGHT+IE5++hj+VUt5CUyNjhrQ+W50MtO2JDzQe0RQ9nqT4HYfZWjb3KMR5u/R6srW2iPepuN/16VGw== X-Received: by 2002:adf:e945:0:b0:316:ee7f:f9bb with SMTP id m5-20020adfe945000000b00316ee7ff9bbmr4954605wrn.65.1695305240266; Thu, 21 Sep 2023 07:07:20 -0700 (PDT) Received: from [10.121.111.136] ([213.58.148.146]) by smtp.gmail.com with ESMTPSA id r17-20020a5d4951000000b0031f8a59dbeasm1861978wrs.62.2023.09.21.07.07.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Sep 2023 07:07:19 -0700 (PDT) Message-ID: Date: Thu, 21 Sep 2023 15:07:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 1/1] gdb, gdbserver: replace PBUFSIZ with a target op Content-Language: en-US To: "Gerlicher, Klaus" , Andrew Burgess , Simon Marchi , "gdb-patches@sourceware.org" References: <20230919054511.17998-1-klaus.gerlicher@intel.com> <20230919054511.17998-2-klaus.gerlicher@intel.com> <3d0d3efc-f802-4a3a-a602-dc3e59c99c94@polymtl.ca> <87sf79xanx.fsf@redhat.com> <24534cd7-9c80-19da-5a9c-17962ae46fb3@palves.net> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! I am not sure who you are replying to. It would be great if you please avoided top posting. On 2023-09-21 07:02, Gerlicher, Klaus wrote: > Hi, > > I'm unsure why I'm confusing you about what this does. This is a patch for remote target packet buffer, so for gdbserver. I had said: > I don't understand why the patch added a target method on the gdb side. Is this what you are replying to? You are describing this as a gdbserver patch, but the patch touches the gdb side as well. That's what I was asking about. Why are these changes needed: gdb/remote.h | 8 +++--- gdb/target-delegates.c | 31 +++++++++++++++++++++-- gdb/target.h | 7 ++++++ I then had another separate question. Pedro Alves > > From original gdbserver/server.h: > > /* Buffer sizes for transferring memory, registers, etc. The target decides > how big this needs to be but this value must be at least as large as the > largest register set supported by gdbserver. */ > > PBUFSIZ is defined as a constant( #define) and is used for allocating the buffer that gdbserver writes into for communication with GDB. > > This will remain the same size for targets not aware of the process_stratum_pbufsiz::query_pbuf_size override. I called this a target op but maybe that's the wrong term and that is the source of confusion? > > Targets can override this to any size they see fit for what register size or memory transfer sizes they require. It doesn't make sense to have big allocation for targets that don't need that much but some newer accelerator/SIMD/GPU device (for a lack of a better term) targets need a much bigger buffer. > > Thanks > Klaus > > -----Original Message----- > From: Pedro Alves > Sent: Wednesday, September 20, 2023 6:32 PM > To: Andrew Burgess ; Gerlicher, Klaus ; Simon Marchi ; gdb-patches@sourceware.org > Subject: Re: [PATCH 1/1] gdb, gdbserver: replace PBUFSIZ with a target op > > Hi! > > On 2023-09-20 13:59, Andrew Burgess via Gdb-patches wrote: >> "Gerlicher, Klaus via Gdb-patches" writes: >> >>> Hi Simon, >>> >>> Thanks for the quick response. >>> >>> At least the initial buffer size needs to be fixed since now most >>> clients aren't aware of any dynamic behavior here and therefore we >>> need at least something pre-allocated for these clients. >> >> I don't understand your concerns here. For this patch we're only >> talking about the gdbserver client, right? And your patch (rightly) >> doesn't change things on the GDB side. > > The client is the GDB side, the server side is, well, gdbserver. :-) > >> >> GDB already uses a dynamic packet buffer size. > > It is dynamic, but not in the sense that we just append to the buffer with push_back and let the buffer grow unbounded. Instead, GDB tries to guess a sufficient packet size, but if the server tells it explicitly what packet size it supports, then GDB will grow its buffer to that size, no questions asked. > > /* If we increased the packet size, make sure to increase the global > buffer size also. We delay this until after parsing the entire > qSupported packet, because this is the same buffer we were > parsing. */ > if (rs->buf.size () < rs->explicit_packet_size) > rs->buf.resize (rs->explicit_packet_size); > > >> So the only initial >> buffer I think you can be talking about here is the gdbserver buffer, >> which I think could be made dynamic, just as GDB's is. > > I think he was really talking about the GDB side. Or even other clients, like LLDB, etc. > >> >> We could hard-code gdbserver to return some stupidly large number for >> the PacketSize in the qSupported reply, say MAX_INT? Or (MAX_INT / >> 4), you pick, this could be anything really, just something huge. > > I don't think it can, due to the immediate resize mentioned above. > > I don't understand why the patch added a target method on the gdb side. > > Also, do we really need the new target method on the gdbserver side? > We assert that the buffer size is bigger than the tdesc's register size plus a slack, but how about flipping that around and make the buffer size be dependent on the register size? Maybe the packet size decision is done earlier than we know which tdesc we are using, though, that's something to check. > > Pedro Alves > > Intel Deutschland GmbH > Registered Address: Am Campeon 10, 85579 Neubiberg, Germany > Tel: +49 89 99 8853-0, www.intel.de > Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva > Chairperson of the Supervisory Board: Nicole Lau > Registered Office: Munich > Commercial Register: Amtsgericht Muenchen HRB 186928