From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id O7lZEB3TYmoHyioAWB0awg (envelope-from ) for ; Thu, 23 Jul 2026 22:51:09 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aiTiI7qz; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 316741E033; Thu, 23 Jul 2026 22:51:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 1E6161E033 for ; Thu, 23 Jul 2026 22:51:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC0984BA23FC for ; Fri, 24 Jul 2026 02:51:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC0984BA23FC Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aiTiI7qz Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id A24764BA2E0B for ; Fri, 24 Jul 2026 02:50:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A24764BA2E0B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A24764BA2E0B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1029 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784861441; cv=none; b=VQgaRqxcpBywT8uOPqnAEb4VrbM65MmiCtZ5Jsvm6sQUaetoNOLQkqLcaTKWPGokDaYfZxM2WGD/VhCFAoA2o+7fgDPljcmWgJ2qNWV2V5Z++26T8QijvDxxymx1LZGHe4OICswNzQ6KsdE1Nzeqyy/2pf6KOKOeDcCs4C0OGz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784861441; c=relaxed/simple; bh=oOXJmKMpl5S9HRVNqvcKpPW5YBUvNHG42TSv9d1zASA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hqfTRyi5KFppjxFPcZz4YqRxXSJ7Fs4PuD/apWnik18yJuTN/wJ8V158NGEgY9p8r755o9vCIr2NBAggo7PpI73ZsDe2WR9OK96D4fTj2ALCmOrimPr80p9Og8WWSkS5JHUnK7GWNHuhyKBLAPTMNYDD7T/6K09kZG/9n2i9H20= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=aiTiI7qz DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A24764BA2E0B Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-38e071ed6aeso1009168a91.0 for ; Thu, 23 Jul 2026 19:50:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1784861440; x=1785466240; darn=sourceware.org; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Wg5Pgspcd6gTS1UdLGJ+5bDAXApHJLS9h11DBcVtaDM=; b=aiTiI7qzpwxrXCAd6t5cOLbrsdjAVxTjz929TnJET0XPZ09HiweEptJqWFymtdv4gC Wl/abLz2htO5Vr0KcalD2SLfINj53pFIMwKSiCPC9k6h0q9daflVSZi1iCJp92NlBxAD TSLFwEihOMxfB4kF/QYZvjacic3T4r7s3PEur9VAGKwAXGAAJnCvNfL9d3vLR6hotuUD Nqeh+J23UTxNIP/3PNDl8xyDscXlJAYfenLM7W5MsR+8RHXisEzsfq/ACUcjYcJYxAB7 oIWlLfeY6lBidWZCKr/Pks4Elz+JwSv2a4al7/iGWqHz6e5yCnOiZeareXZvPpOdL+pA eJrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784861440; x=1785466240; h=content-type:mime-version:message-id:date:user-agent:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=Wg5Pgspcd6gTS1UdLGJ+5bDAXApHJLS9h11DBcVtaDM=; b=gCLGHXCh4DpCHZPtQiArDFKysb962c6Z4IEzVqP2/Rk/vsxBOvj9NOPwWlTxq/HYxC jcNHojxfLX5YGSRaXv2eEH681yaCvFzSlMXv55tveh6JmYjIkb61yswbKFYm1kAYerlK k3DIJMBgQX1xImmcJT6rdelqFkihACtKynrw44DN6rFIgA1zLin3NMeXSrmW4z7iA4aA CRBakchzGA1VbMtX0QUW6tf2MN7B0UlQrMPi64OfIL8xsyK8EsX94XUnJZ83y7/2/IhF H7FEQuGc27strveAzd6Qu3/NhYceItDF9YWpSQpFNgWkglc+5E/RUmMWjTGQaFpK1rs9 cu4g== X-Gm-Message-State: AOJu0YyTG3EDRDOM+sOID8irl+gM2HTVb/R+uzSG14zWiaMQ202Df+TE e9kr8g870mLmCrDa9KgLfn1reGhuY8aZ68a+YLcMeaDNcXTM0WFcxH3DRLEPe2dZHc8= X-Gm-Gg: AR+sD11E5K+avTmUjxxBIw1jnu8AIn2RoY4kQghfygutKNdJg/WnnRqup8BQMD0cFjD R0kIwwg9A11+1ZparBJ1An+vtiXB291LvaNEdKUkB8Dxfl+16alZSD/3KPOmGd1C14RRrLsg9bw vjpN9jsMwJoIrz48lCmFJRxZOT/HQ38JdLA5qj0U6YM+7rtghksjm6MO4UMikWwTIHPYRVhHn0F LTni82yzxmLBh0Dk3av/HSY7J2Sl7mRiyApfsGkfOnt69UiYOPWoIBsdEyfGRPPGE0lgvQMnaQi Ee3HQDAh/xcOfKbRxo4ekUYtw3pjuWc1LH+xvRt6bgTORhosraMK3JrHNa/Bh8a7cDuh4NS8vJv +ZpYwwASZfDKb2bAUzorfHfTn9SaJsaDNpIQqcssa5qxbZUVnSt/2uMAevnT/JsgjfuVvbj7pLV hBMIOozhMbauTf X-Received: by 2002:a17:90b:2d46:b0:381:a766:efc9 with SMTP id 98e67ed59e1d1-38ec6453ea7mr5754017a91.7.1784861439553; Thu, 23 Jul 2026 19:50:39 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13d130a87e9sm19343557c88.11.2026.07.23.19.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 19:50:39 -0700 (PDT) From: Thiago Jung Bauermann To: Matthieu Longo Cc: gdb-patches@sourceware.org, Luis Machado , Luis Machado , Andrew Burgess , Yury Khrustalev , Pedro Alves , Tom Tromey Subject: Re: [PATCH v1 03/10] target_fileio_read_stralloc: add an optional length parameter In-Reply-To: (Matthieu Longo's message of "Mon, 13 Jul 2026 16:26:12 +0100") References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-4-matthieu.longo@arm.com> <87jyr41xqc.fsf@linaro.org> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Fri, 24 Jul 2026 02:50:37 +0000 Message-ID: <87cxwdf6de.fsf@linaro.org> MIME-Version: 1.0 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 Matthieu Longo writes: > On 09/07/2026 07:30, Thiago Jung Bauermann wrote: >> Matthieu Longo writes: >> >>> diff --git a/gdb/target.h b/gdb/target.h >>> index 22653138491..4215553033c 100644 >>> --- a/gdb/target.h >>> +++ b/gdb/target.h >>> @@ -2336,7 +2336,7 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, >>> are returned as allocated but empty strings. A warning is issued >>> if the result contains any embedded NUL bytes. */ >>> extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc >>> - (struct inferior *inf, const char *filename); >>> + (struct inferior *inf, const char *filename, size_t *len = nullptr); >> >> It's worth updating the documentation comment to mention the new parameter. > > See the updated diff in gdb/target.h > > diff --git a/gdb/target.h b/gdb/target.h > index 22653138491..0df5a654f75 100644 > --- a/gdb/target.h > +++ b/gdb/target.h > @@ -2328,15 +2328,19 @@ extern LONGEST target_fileio_read_alloc (struct inferior *inf, > const char *filename, > gdb_byte **buf_p); > > -/* Read target file FILENAME, in the filesystem as seen by INF. If > - INF is NULL, use the filesystem seen by the debugger (GDB or, for > - remote targets, the remote stub). The result is NUL-terminated and > - returned as a string, allocated using xmalloc. If an error occurs > - or the transfer is unsupported, NULL is returned. Empty objects > - are returned as allocated but empty strings. A warning is issued > - if the result contains any embedded NUL bytes. */ > +/* Read the content of the target file FILENAME from the filesystem as > + seen by INF. If INF is NULL, use the filesystem seen by the debugger > + (GDB or, for remote targets, the remote stub). > + > + If LEN is not NULL, store the number of bytes read, excluding the > + terminating NUL byte. > + > + The returned buffer is NUL-terminated and allocated using xmalloc. > + On error, or if the transfer is unsupported, return NULL. Empty > + files are returned as allocated but empty strings. A warning is > + issued if the file content contains embedded NUL bytes. */ > extern gdb::unique_xmalloc_ptr target_fileio_read_stralloc > - (struct inferior *inf, const char *filename); > + (struct inferior *inf, const char *filename, size_t *len = nullptr); > > /* Invalidate the target associated with open handles that were open > on target TARG, since we're about to close (and maybe destroy) the Looks great, thanks! My only suggestion is to take the opportunity to do s/NULL/nullptr/ in the comment. -- Thiago (he/him)