From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 54nvDFvy7Gog+CIAWB0awg (envelope-from ) for ; Thu, 05 Nov 2026 16:17:15 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=dUoU6sm/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 1F2061E043; Thu, 05 Nov 2026 16:17:15 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 821501E043 for ; Thu, 05 Nov 2026 16:17:14 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A2794BA2E30 for ; Thu, 5 Nov 2026 21:17:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A2794BA2E30 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=dUoU6sm/ Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id EEBDB4BA2E13 for ; Thu, 5 Nov 2026 21:16:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEBDB4BA2E13 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EEBDB4BA2E13 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793913409; cv=none; b=a8YlhucoWsTusnt+ETA30oIzCzGMz/MohFKtK04j4oERxN5pvZ1Dzsm4rUFVt5jDGi4yQyenO8hsONqNh6nsiKTr+v2ai09Nha9ixh43r9t0SiKm4VAGC/oAZBi7tRSZ5olcZ6J+Cu9+CZugflSFmRC+goWSWIek1WZEusYZCvI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793913409; c=relaxed/simple; bh=SmTBcxHdppBsYGh11FTwvl3qXK5l9k5D5Vtx0QkRgHs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dtYh2Wg3f8VkpX/68rbaqfw+P+1yoWtC8Eeg4ctRrEmGY1cScSChgxaeSFwEBsU8EjD3V2KR/bCOy3L0abBZJGwR5ZCad8SuNCexZg0LZjIjZ8Eg4+k7pemPj26uTQYlprY5w6YjsAaUMJf5yoUdLOE5MoaGY0X1x9PzcWWMKp4= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=dUoU6sm/ reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEBDB4BA2E13 Received: from eig-obgw-6002b.ext.cloudfilter.net ([10.0.30.203]) by cmsmtp with ESMTPS id P4Z4xqhTdOOJnP4pExeFXQ; Thu, 05 Nov 2026 21:16:48 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id P4pCx5rpmPdvCP4pCxazoO; Thu, 05 Nov 2026 21:16:46 +0000 X-Authority-Analysis: v=2.4 cv=ZYIdNtVA c=1 sm=1 tr=0 ts=6aecf23e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=zJRp6_cAMcgA:10 a=ItBw4LHWJt0A:10 a=7CQSdrXTAAAA:8 a=k0-l9VHSGwhbmO2smLEA:9 a=a-qgeE7W1pNrGK8U0ZQC:22 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4mH3nfvgZiHZdMc2DC3C/8Ex6AkcT0930zExcwaxZ2o=; b=dUoU6sm/V90fHwmidOu+32SHqe GzvEuD5k4HqrvkTy0KcjzGjrlLkf5IUEYZ98txHrdA92lpD78+RQv7C7eCfbw4LejbvDFL6k16ZSD G10w8PKqghcWgYQAWlp/cb3lj; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:37332 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xP4pB-00000000WJr-2ua3; Thu, 05 Nov 2026 14:16:45 -0700 From: Tom Tromey To: Matthieu Longo Cc: , Andrew Burgess , Tom Tromey , Thiago Jung Bauermann , Christina Joos Subject: Re: [PATCH v3 6/8] gdb: introduce helper class target_file_reader In-Reply-To: <20260922135050.236941-7-matthieu.longo@arm.com> (Matthieu Longo's message of "Tue, 22 Sep 2026 14:50:48 +0100") References: <20260922135050.236941-1-matthieu.longo@arm.com> <20260922135050.236941-7-matthieu.longo@arm.com> X-Attribution: Tom Date: Thu, 05 Nov 2026 14:16:44 -0700 Message-ID: <87se1fvv0j.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xP4pB-00000000WJr-2ua3 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net (bapiya) [97.122.110.129]:37332 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGWClr6xyCSllDm5mpN7TF+0F2o7L+H++T9s451sVpyUl1XhZeYDjEPvqAOxgXPSQ6rtU9ZZkJXEC7x5ElWFZugE1H1bt+noix12quJ1hCOadnwoTVm/ yV8aQzX0ew1bGfLXnaB5kguGRXzAbt87FELsvxzT9Ew24zUeeyX15Rg4pD1xH+5I3pSEoIbELRnbHGeT63UNy0N9rO75sjFA0UY= 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: > Wrap all the boilerplate code required to read a file in a new helper > class: target_file_reader. The class owns the file contents together with > the file path, and provides convenient accessors for the data, size and > typed views. It supports both null-terminated text files and binary files. > This helper eliminates repeated calls to target_fileio_read_stralloc > and target_fileio_read_alloc, removes explicit memory management with > gdb::unique_xmalloc_ptr, and simplifies the casting logic when working > with binary data. > The patch converts some of the existing Linux, AMD64, and SPARC code that > reads files from /proc to use target_file_reader. As a side effect, > amd64_linux_lam_untag_mask and linux_process_address_in_memtag_page > may now return earlier in case the file is empty. Thanks. > + target_file_reader proc_status > + (string_printf ("/proc/%d/status", inf->pid)); > +public: > + /* Read the content of the file associated to PATH 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). */ > + target_file_reader (const std::string &path, struct inferior *inf = nullptr) > + : m_path (path) > + , m_size (0) > + { Two notes here. The ", m_size" thing isn't really gdb style. (I like this style but haven't pushed for it at all.) But it's moot here because in gdb it's more normal to inline-initialize a member like this. Also, accepting a "std::string &&" here and moving it into place would avoid copying. I think this patch explains why you used array_view previously. Tom