From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.152.11]) by sourceware.org (Postfix) with ESMTPS id E92CC394D833 for ; Fri, 28 Aug 2020 16:23:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E92CC394D833 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 cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id ECDA6D0F5 for ; Fri, 28 Aug 2020 11:23:56 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id BhASkx0ekCjCVBhASkhT9O; Fri, 28 Aug 2020 11:23:56 -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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type: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=Rbz1wmnoUyO/fhYBWYd/7hFzvczhUkbUevDABdUnzE0=; b=I1JLoHQFNf7V8VqSFMZKAT1/Uh AfVCpbsxeRIiCZBSLPi95w9/CKgaK8ipURFgBnFQIeBI4YOBNIe/XHRv8LIJySrIQKkeFWR1SzzJs OfNS5mficys6ymHvGt6BnkOO9; Received: from 71-218-12-75.hlrn.qwest.net ([71.218.12.75]:33904 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kBhAR-002WJo-TV; Fri, 28 Aug 2020 10:23:55 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 13/13] Use gdb_bfd_sections in generic_load Date: Fri, 28 Aug 2020 10:23:49 -0600 Message-Id: <20200828162349.987-14-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200828162349.987-1-tom@tromey.com> References: <20200828162349.987-1-tom@tromey.com> 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: 71.218.12.75 X-Source-L: No X-Exim-ID: 1kBhAR-002WJo-TV X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-12-75.hlrn.qwest.net (bapiya.Home) [71.218.12.75]:33904 X-Source-Auth: tom+tromey.com X-Email-Count: 14 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3035.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham 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: Fri, 28 Aug 2020 16:23:59 -0000 This changes generic_load to avoid bfd_map_over_sections, in favor of iteration. gdb/ChangeLog 2020-08-28 Tom Tromey * symfile.c (add_section_size_callback): Remove. (load_one_section): Rename from load_section_callback. Change parameters. (generic_load): Use foreach. --- gdb/ChangeLog | 7 +++++++ gdb/symfile.c | 23 +++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/gdb/symfile.c b/gdb/symfile.c index 96d8b3f0b52..1c22d8582c0 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1842,16 +1842,6 @@ load_command (const char *arg, int from_tty) static int validate_download = 0; -/* Callback service function for generic_load (bfd_map_over_sections). */ - -static void -add_section_size_callback (bfd *abfd, asection *asec, void *data) -{ - bfd_size_type *sum = (bfd_size_type *) data; - - *sum += bfd_section_size (asec); -} - /* Opaque data for load_progress. */ struct load_progress_data { @@ -1966,12 +1956,12 @@ load_progress (ULONGEST bytes, void *untyped_arg) totals->total_size); } -/* Callback service function for generic_load (bfd_map_over_sections). */ +/* Service function for generic_load. */ static void -load_section_callback (bfd *abfd, asection *asec, void *data) +load_one_section (bfd *abfd, asection *asec, + struct load_section_data *args) { - struct load_section_data *args = (struct load_section_data *) data; bfd_size_type size = bfd_section_size (asec); const char *sect_name = bfd_section_name (asec); @@ -2040,10 +2030,11 @@ generic_load (const char *args, int from_tty) bfd_errmsg (bfd_get_error ())); } - bfd_map_over_sections (loadfile_bfd.get (), add_section_size_callback, - (void *) &total_progress.total_size); + for (asection *asec : gdb_bfd_sections (loadfile_bfd)) + total_progress.total_size += bfd_section_size (asec); - bfd_map_over_sections (loadfile_bfd.get (), load_section_callback, &cbdata); + for (asection *asec : gdb_bfd_sections (loadfile_bfd)) + load_one_section (loadfile_bfd.get (), asec, &cbdata); using namespace std::chrono; -- 2.17.2