From patchwork Thu Jan 17 02:50:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31085 Received: (qmail 98229 invoked by alias); 17 Jan 2019 02:50:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 98011 invoked by uid 89); 17 Jan 2019 02:50:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (50.116.127.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Jan 2019 02:50:37 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id EE1522CFA for ; Wed, 16 Jan 2019 20:50:35 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id jxlLgCJJr90onjxlLgeubS; Wed, 16 Jan 2019 20:50:35 -0600 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=EGTrU4Fg8/oTDifdTCr3ta0Q6zadyE9r07YuLjA6Ddw=; b=nAgVOCbIXEGFFlYOi8W0ajYNdN PczZSWyWfMmdlFO+OPLM4QTNW3WIwRUzTx2OZ2eKCtMi7jG3C4mOHqkSXmPFqp/O3FlyMSse5p+h6 LnhUJRNnNddDZF1X+IPJja2yd; Received: from 75-166-72-210.hlrn.qwest.net ([75.166.72.210]:41222 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gjxlL-0045Wd-Me; Wed, 16 Jan 2019 20:50:35 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 5/6] Simplify minsym iteration Date: Wed, 16 Jan 2019 19:50:31 -0700 Message-Id: <20190117025032.9265-6-tom@tromey.com> In-Reply-To: <20190117025032.9265-1-tom@tromey.com> References: <20190117025032.9265-1-tom@tromey.com> This simplifies the minimal symbol iterator, by using minimal_symbol_count and just doing a somewhat ordinary array-like iteration. array_view is nearly usable, except that this iterator must return pointers rather than references. 2019-01-16 Tom Tromey * objfiles.h (class objfile_msymbols) : Change argument type. Remove no-argument constructor. : Simplify. : Update. : Use minimal_symbol_count. --- gdb/ChangeLog | 8 ++++++++ gdb/objfiles.h | 25 ++++++------------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 4c68430975..f666d558c2 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -591,20 +591,11 @@ public: typedef std::forward_iterator_tag iterator_category; typedef int difference_type; - explicit iterator (struct objfile *objfile) - : m_msym (objfile->per_bfd->msymbols) + explicit iterator (struct minimal_symbol *msym) + : m_msym (msym) { - /* Make sure to properly handle the case where there are no - minsyms. */ - if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr) - m_msym = nullptr; } - iterator () - : m_msym (nullptr) - { - } - value_type operator* () const { return m_msym; @@ -622,12 +613,7 @@ public: self_type &operator++ () { - if (m_msym != nullptr) - { - ++m_msym; - if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr) - m_msym = nullptr; - } + ++m_msym; return *this; } @@ -637,12 +623,13 @@ public: iterator begin () const { - return iterator (m_objfile); + return iterator (m_objfile->per_bfd->msymbols); } iterator end () const { - return iterator (); + return iterator (m_objfile->per_bfd->msymbols + + m_objfile->per_bfd->minimal_symbol_count); } private: