From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94313 invoked by alias); 22 Nov 2019 16:52:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 94300 invoked by uid 89); 22 Nov 2019 16:52:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=*symbol_regexp, 2102, symbol_regexp X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Nov 2019 16:52:04 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 13D5220393; Fri, 22 Nov 2019 11:52:01 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 5A43220249; Fri, 22 Nov 2019 11:51:58 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 3559F2816F; Fri, 22 Nov 2019 11:51:58 -0500 (EST) X-Gerrit-PatchSet: 4 Date: Fri, 22 Nov 2019 16:52:00 -0000 From: "Andrew Burgess (Code Review)" To: gdb-patches@sourceware.org Cc: Simon Marchi , Joel Brobecker , Christian Biesinger , Tom Tromey Auto-Submitted: auto-generated X-Gerrit-MessageType: comment Subject: [review v4] gdb: Introduce global_symbol_searcher X-Gerrit-Change-Id: I488ab292a892d9e9e84775c632c5f198b6ad3710 X-Gerrit-Change-Number: 264 X-Gerrit-ChangeURL: X-Gerrit-Commit: 430d88fa4ca7aea66fce1c570d6f8e81d8a6b499 In-Reply-To: References: X-Gerrit-Comment-Date: Fri, 22 Nov 2019 11:51:57 -0500 Reply-To: gnutoolchain-gerrit@osci.io MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Content-Type: text/plain; charset=UTF-8 Message-Id: <20191122165158.3559F2816F@gnutoolchain-gerrit.osci.io> X-SW-Source: 2019-11/txt/msg00717.txt.bz2 Andrew Burgess has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/264 ...................................................................... Patch Set 4: (4 comments) Updated and addressed most of the comments, but I realise I missed one. | --- gdb/symtab.c | +++ gdb/symtab.c | @@ -4355,8 +4342,11 @@ file_matches (const char *file, const char *files[], int nfiles, int basenames) | - ? lbasename (files[i]) | - : files[i]))) | - return 1; | - } | - } | - else if (nfiles == 0) | - return 1; | - return 0; | +/* Compare FILE against all the entries of FILENAMES. If BASENAMES is | + non-zero compare only lbasename of FILENAMES. */ PS3, Line 4343: Done. | + | +static bool | +file_matches (const char *file, const std::vector &filenames, | + bool basenames) | +{ | + if (filenames.empty ()) | + return true; | + | + for (const char *name : filenames) ... | @@ -4837,17 +4822,16 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms, | {"variable", "function", "type", "module"}; | const char *last_filename = ""; | int first = 1; | | gdb_assert (kind != ALL_DOMAIN); | | if (regexp != nullptr && *regexp == '\0') | regexp = nullptr; | | /* Must make sure that if we're interrupted, symbols gets freed. */ PS3, Line 4831: Done. | - std::vector symbols = search_symbols (regexp, kind, | - t_regexp, 0, NULL, | - exclude_minsyms); | + global_symbol_searcher spec (kind, regexp, t_regexp, exclude_minsyms); | + std::vector symbols = spec.search (); | | if (!quiet) | { | if (regexp != NULL) | --- gdb/symtab.h | +++ gdb/symtab.h | @@ -2088,0 +2080,32 @@ extern std::vector search_symbols (const char *, | +/* In order to search for global symbols of a particular kind matching | + particular regular expressions, create an instance of this structure and | + call the SEARCH member function. */ | +class global_symbol_searcher | +{ | +public: | + | + /* Constructor. */ | + global_symbol_searcher (enum search_domain kind, | + const char *symbol_regexp = nullptr, | + const char *type_regexp = nullptr, | + bool exclude_minsyms = false, | + std::vector filename = {}) PS3, Line 2092: Done. | + : m_kind (kind), | + m_symbol_regexp (symbol_regexp), | + m_type_regexp (type_regexp), | + m_exclude_minsyms (exclude_minsyms) | + { | + /* The symbol searching is designed to only find one kind of thing. */ | + gdb_assert (m_kind != ALL_DOMAIN); | + } | + | + /* Search the symbol table for matches as defined by SEARCH_SPEC. PS3, Line 2102: Updated. | + | + Within each file the results are sorted locally; each symtab's global | + and static blocks are separately alphabetized. Duplicate entries are | + removed. */ | + std::vector search () const; | + | + /* The set of source files to search in for matching symbols. This is | + currently public so that it can be populated after this object has | + been constructed. */ -- Gerrit-Project: binutils-gdb Gerrit-Branch: master Gerrit-Change-Id: I488ab292a892d9e9e84775c632c5f198b6ad3710 Gerrit-Change-Number: 264 Gerrit-PatchSet: 4 Gerrit-Owner: Andrew Burgess Gerrit-Reviewer: Andrew Burgess Gerrit-Reviewer: Simon Marchi Gerrit-Reviewer: Tom Tromey Gerrit-CC: Christian Biesinger Gerrit-CC: Joel Brobecker Gerrit-Comment-Date: Fri, 22 Nov 2019 16:51:57 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: Simon Marchi Gerrit-MessageType: comment