From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.184.48]) by sourceware.org (Postfix) with ESMTPS id 87C5A3858D35 for ; Mon, 24 Aug 2020 20:31:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87C5A3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway30.websitewelcome.com (Postfix) with ESMTP id F3C08135E for ; Mon, 24 Aug 2020 15:31:17 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id AJ7dkiXlHXp2AAJ7dkywMb; Mon, 24 Aug 2020 15:31:17 -0500 X-Authority-Reason: nr=8 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:In-Reply-To:Date: References: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-Subscribe:List-Post:List-Owner:List-Archive; bh=89OswQGLVB6ZsDJB0P1nPjfott7hA+ho2peZjEjq8M4=; b=s5KkR5fwO7PHcTRktxDBOp19R/ KNI1Zpm7onkR5ii8T41HqKG7g4haK2WmYPU4VVnyyr8ickBGTnKeXwEtU2PBw6EdRwB3ta8adk8yf 2g/ggOQKWYfyHCFeJuiKTkaXL; Received: from 75-166-101-103.hlrn.qwest.net ([75.166.101.103]:37266 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kAJ7d-003U2n-LH; Mon, 24 Aug 2020 14:31:17 -0600 From: Tom Tromey To: Simon Marchi via Gdb-patches Subject: Re: [PATCH] gdb: add gdb_bfd_all_sections for range-based iteration References: <20200824194333.196744-1-simon.marchi@polymtl.ca> X-Attribution: Tom Date: Mon, 24 Aug 2020 14:31:16 -0600 In-Reply-To: <20200824194333.196744-1-simon.marchi@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Mon, 24 Aug 2020 15:43:33 -0400") Message-ID: <87a6yjbxbf.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) 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: 75.166.101.103 X-Source-L: No X-Exim-ID: 1kAJ7d-003U2n-LH X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-101-103.hlrn.qwest.net (murgatroyd) [75.166.101.103]:37266 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 24 Aug 2020 20:31:20 -0000 >>>>> "Simon" == Simon Marchi via Gdb-patches writes: Simon> I wanted to make a nicer / type-safe interface for Simon> bfd_map_over_sections, avoiding the `void *` data parameter. Simon> My first shot was to make a wrapper for bfd_map_over_sections, Simon> gdb_bfd_map_over_sections that took a gdb::function_view. Simon> However, I think that a range adapter gives nicer and simpler code, as a Simon> simple for loop is easier to read than a callback / lambda function. So Simon> here it is, it uses next_iterator and next_adapter, so it's not much Simon> code. Simon> As an example, I ported maintenance_info_sections and friends to use it. Simon> The maint_print_section_data type could probably be removed now, but I Simon> didn't want to do too much in one patch. I also did this kind of thing -- I have some patches to remove many uses of bfd_map_over_sections, though not all of them, since some seem hard to test. Simon> * gdb_bfd.h (gdb_bfd_section_iterator, gdb_bfd_section_range, Simon> gdb_bfd_all_sections): New. Simon> * maint.c (print_bfd_section_info): Change param type to Simon> maint_print_section_data. Simon> (print_objfile_section_info): Likewise. Simon> (print_bfd_section_info_maybe_relocated): Likewise. Simon> (maintenance_info_sections): Use gdb_bfd_all_sections. Looks good. Thanks. Tom