From patchwork Sat Nov 29 12:11:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 4007 Received: (qmail 19689 invoked by alias); 29 Nov 2014 12:11:34 -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 19679 invoked by uid 89); 29 Nov 2014 12:11:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 29 Nov 2014 12:11:32 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sATCBS0V023481 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 29 Nov 2014 07:11:28 -0500 Received: from host2.jankratochvil.net (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sATCBPgh030304 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Sat, 29 Nov 2014 07:11:27 -0500 Date: Sat, 29 Nov 2014 13:11:24 +0100 From: Jan Kratochvil To: Doug Evans Cc: "gdb-patches@sourceware.org" Subject: [patchv3 2/2] Accelerate lookup_symbol_aux_objfile 85x Message-ID: <20141129121124.GA21606@host2.jankratochvil.net> References: <20141020214410.GA22011@host2.jankratochvil.net> <20141023182434.GA31412@host2.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Fri, 24 Oct 2014 09:16:01 +0200, Doug Evans wrote: > This breaks an abstraction boundary, IWBN to preserve it. > [IOW, I look at dict_* as being an implementation detail of blocks.] > > If we were to go this route (and apologies for the delay), can you > write a routine like lookup_block_symbol which does the above and call > that here instead? > > lookup_block_symbol should live in block.c, not symtab.c. > That's where this new routine should go too. Done. For the 'slow.C' test the performance gain is even higher; but I have not re-benchmarked the 'non-trivial app': Command execution time: 26.540344 (cpu), 26.575254 (wall) -> Command execution time: 0.310607 (cpu), 0.311062 (wall) = 85x OK for check-in? No regressions on {x86_64,x86_64-m32,i686}-fedora21-linux-gnu native and in DWZ and in -fdebug-types-section modes. Thanks, Jan gdb/ 2014-11-28 Jan Kratochvil * block.c (block_lookup_symbol_primary): New function. * block.h (block_lookup_symbol_primary): New declaration. * symtab.c (lookup_symbol_in_objfile_symtabs): Assert BLOCK_INDEX. Call block_lookup_symbol_primary. diff --git a/gdb/block.c b/gdb/block.c index 597d143..e791c73 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -746,3 +746,28 @@ block_lookup_symbol (const struct block *block, const char *name, return (sym_found); /* Will be NULL if not found. */ } } + +/* See block.h. */ + +struct symbol * +block_lookup_symbol_primary (const struct block *block, const char *name, + const domain_enum domain) +{ + struct symbol *sym; + struct dict_iterator dict_iter; + + /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */ + gdb_assert (BLOCK_SUPERBLOCK (block) == NULL + || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL); + + for (sym = dict_iter_name_first (block->dict, name, &dict_iter); + sym != NULL; + sym = dict_iter_name_next (name, &dict_iter)) + { + if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), + SYMBOL_DOMAIN (sym), domain)) + return sym; + } + + return NULL; +} diff --git a/gdb/block.h b/gdb/block.h index bd358d6..409a5c7 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -276,6 +276,14 @@ extern struct symbol *block_lookup_symbol (const struct block *block, const char *name, const domain_enum domain); +/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of + BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if + one iterates all global/static blocks of an objfile. */ + +extern struct symbol *block_lookup_symbol_primary (const struct block *block, + const char *name, + const domain_enum domain); + /* Macro to loop through all symbols in BLOCK, in no particular order. ITER helps keep track of the iteration, and must be a struct block_iterator. SYM points to the current symbol. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 345c20d..fd93fb8 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1618,6 +1618,8 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index, { struct compunit_symtab *cust; + gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); + ALL_OBJFILE_COMPUNITS (objfile, cust) { const struct blockvector *bv; @@ -1626,7 +1628,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index, bv = COMPUNIT_BLOCKVECTOR (cust); block = BLOCKVECTOR_BLOCK (bv, block_index); - sym = block_lookup_symbol (block, name, domain); + sym = block_lookup_symbol_primary (block, name, domain); if (sym) { block_found = block;