From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id V1eLNyleaWoriDIAWB0awg (envelope-from ) for ; Tue, 28 Jul 2026 21:58:01 -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=F6WW3ol1; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CE2F21E033; Tue, 28 Jul 2026 21:58:01 -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 [38.145.34.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 079251E033 for ; Tue, 28 Jul 2026 21:58:01 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29F1A4BB3BF5 for ; Wed, 29 Jul 2026 01:58:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29F1A4BB3BF5 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=F6WW3ol1 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id A94ED4BB3BBA for ; Wed, 29 Jul 2026 01:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A94ED4BB3BBA 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 A94ED4BB3BBA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785290254; cv=none; b=QcEJiWzoC9B/jahL2YnzrX0qs457wDwDhgg39uFbX3sTntkH71VtnOSeonb8+SF+SR1BOW9biQeNkPvhXwsWyvft2E2HYxeJ+41Y013mSVlpG7Mvl/v2NC6GK3EaRWMJCYeY6GigZTFkmBX+/mdWHd8OAZ67nImMdggUI4FR7kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785290254; c=relaxed/simple; bh=n3qCw7omNcLSfPP0ovSIKO6caPGj8JsboH4WbIZWses=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=n60Jtfq4lF1+sOb7vB5HBTdCtCRMJmQOtuCjR8nB0T9Ettgw3tw5Vo/QGsexUWqbAOjk4QUABNfOQ0qyqYli+lG9dR+0g7ejoJg2jG7neUdk3i2U1K/UK3MeeSfJJbYmO77EPydBpNU8PWf7XoOIH5GAWIQ60KCwzY2j5gi6sE0= 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=F6WW3ol1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A94ED4BB3BBA Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-3810c5d691bso385456a91.1 for ; Tue, 28 Jul 2026 18:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1785290254; x=1785895054; 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=Zs3d8y02eh0rucSXhfzdMpdQbVmo8YyLV46aE9/TUYQ=; b=F6WW3ol1/w6jktXesrI4FpNOPu2t027B4czVFX15SLyTWjHBqWqwwtppGm6AwdiJRy jfjQ5wDT2j4ogKI0RbZ+74eAFZ07XBDDAQ9+emYCMnSF9Jaw+TNhMyDHiVcmRezyixRC sH5pZH6RQqMlNkOT0snmumcxL643mvK4EOdymq9048GYDS0RLxSY3VNzQF2+jlVRw/FP cSdSlVUmIPiqtJdGSeQJDwjTQft1ZiV/fP6d8KU74E1qCCZLk70iJlsi9P5m7uRHgOY8 IgZrJe8YJ2eDe3cuwUhusdASh0sZSVDVhWsm588pZdtCTRjID2yNLKlUWvaS6lZRdjxa mzEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785290254; x=1785895054; 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=Zs3d8y02eh0rucSXhfzdMpdQbVmo8YyLV46aE9/TUYQ=; b=DQwSCKXFQtLDHDunKSNJ92lN8+Mm2E9ND4tGWyeifTjwRMAlo8p+IYSQ4nFo0InT+n ea9uErmWHcxiZXF04tLf42oWkh3lUZbwD6qPMV7QLv8fTVLpn0lDQ/HbsTQ/4UuorO85 tuxYkdHt6ozTO7nmimY7m2p7pnUZRHIumSp8j6JmoOFtc2uefB8gMAWr5Q+F8aCg2xCT 5AO9yNgH2TVVgmm+4VCJOgvdo92qoKMXm5Xsmgc/pNlyzo6o63zkidqIPm7iE5mlGmSU M+QsGpR0nChM13+kbkoqTCpeYGriAryzRLS9J7aQDSV7v0NyvePyh4cTckIpcJNs9K/W Jyug== X-Gm-Message-State: AOJu0YzJvOHM7rmW5UnNPfX3LWXco0Yxi6/mu4sIOeY66O4KsoyNBpOQ 472eoF5qndSSxYLAswlmMO3ODy97WK+f9xVtQJFzH1WmdzUIV2HrWmj+jkIYM0Tfj6A= X-Gm-Gg: AR+sD121wGILi31PChSME0pcuC1yKLkqXsruHupVRB3fxJLwkn2CgVY1MckTjaBjMnC uFiSWsFEjz75YGOEpCc9SbkLaz2ou1lNx9LPoije6KcWVMacADGo6safVL6royI+JAPnhsbYqt0 o5SHod3cuJgHe3Asuig/GQ1tb5Efm70Bb0DWsYWmOnTiwlBLe2cJ9UcFIJwKfrK4RYdgC09n971 QLpRc5ZGpxr8VfkG1bNq/fCwlUZ7vyy1oKgsPBQhV8d4asdpJ4NnIkRKE5OAS9rpdAJlDjCwY2F 3xOM4mNl6AAgp4mvT6Xz4Xfvw1mc3XGh/QsKYDucQsQMIRFR2YN1b5sNkS5WD4gwaGW4m5pLf10 XACxGpZjz9v+ChgYbchsCXDgm9aMKIE4RvIUlGNDchq8vUIW3E+hF0jvr+f3NnKC7SquV3WR7t0 0CAzCOQca+iykGSOse4OdMWuML8EPmUhArcOCVk3O8eluEDOjbnJ3gLf4SSARbiknaCctWGXM= X-Received: by 2002:a17:90a:c2cf:b0:38d:f94d:4c6e with SMTP id 98e67ed59e1d1-38f6a37358emr5238914a91.17.1785290253557; Tue, 28 Jul 2026 18:57:33 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31504dab0f3sm3370643eec.27.2026.07.28.18.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 18:57:33 -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: <98d3b55e-4632-414c-8014-c4962c02984a@arm.com> (Matthieu Longo's message of "Mon, 27 Jul 2026 15:52:28 +0100") References: <20260707154900.94542-1-matthieu.longo@arm.com> <20260707154900.94542-4-matthieu.longo@arm.com> <87jyr41xqc.fsf@linaro.org> <87cxwdf6de.fsf@linaro.org> <98d3b55e-4632-414c-8014-c4962c02984a@arm.com> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Wed, 29 Jul 2026 01:57:30 +0000 Message-ID: <87v79ymub9.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 24/07/2026 03:50, Thiago Jung Bauermann wrote: >> 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. >> > > I don't remember having seen usages of nullptr inside the documentation comments. > Have you a previous example for this ? Yes, there are a number of examples: gdb/block.h: /* Return the compunit over whose static or global block the iterator currently iterates. Return nullptr if the iteration is finished. */ struct compunit_symtab *compunit_symtab () const; gdb/breakpoint.h: /* Reevaluate a breakpoint. This is necessary after symbols change (e.g., an executable or DSO was loaded, or the inferior just started). If not nullptr, then FILTER_PSPACE is the program space in which symbols may have changed, we only need to add new locations in FILTER_PSPACE. If FILTER_PSPACE is nullptr then all program spaces may have changed, new locations need to be searched for in every program space. This is pure virtual as, at a minimum, each sub-class must recompute any cached condition expressions based off of the cond_string member variable. */ virtual void re_set (program_space *filter_pspace) = 0; gdb/gdbcore.h: /* Constructor. BUILD_ID is not nullptr, and is the build-id for the mapped file. FILENAME is the location of the file that GDB loaded to provide the mapped file. This might be different from the name of the mapped file mentioned in the core file, e.g. if GDB downloads a file from debuginfod then FILENAME would point into the debuginfod client cache. The FILENAME can be the empty string if GDB was unable to find a file to provide the mapped file. */ core_target_mapped_file_info (const bfd_build_id *build_id, const std::string filename) gdb/language.h: /* Set the default boolean type to be TYPE. If NAME is not nullptr then before using TYPE a symbol called NAME will be looked up, and the type of this symbol will be used instead. Should only be called once when performing setup for a particular language in combination with a particular gdbarch. */ void set_bool_type (struct type *type, const char *name = nullptr) And others as well. -- Thiago (he/him)