From patchwork Thu Feb 5 03:28:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4923 Received: (qmail 20769 invoked by alias); 5 Feb 2015 03:29:11 -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 20746 invoked by uid 89); 5 Feb 2015 03:29:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 05 Feb 2015 03:29:09 +0000 Received: by mail-pa0-f51.google.com with SMTP id hz1so2355693pad.10 for ; Wed, 04 Feb 2015 19:29:07 -0800 (PST) X-Received: by 10.66.65.195 with SMTP id z3mr1543928pas.10.1423106947499; Wed, 04 Feb 2015 19:29:07 -0800 (PST) Received: from sspiff.org (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id si8sm3435009pbc.26.2015.02.04.19.29.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 19:29:06 -0800 (PST) Received: by sspiff.org (sSMTP sendmail emulation); Wed, 04 Feb 2015 19:28:19 -0800 From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] symbol cache: hash STRUCT_DOMAIN symbols as VAR_DOMAIN Date: Wed, 04 Feb 2015 19:28:19 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. While looking at the contents of the symbol cache after adding support for trying multiple slots I noticed structs occupying more than one slot. This is due to symbol_matches_domain support. This patch fixes it by treating STRUCT_DOMAIN as VAR_DOMAIN when computing the hash. I also added symbol domain names to debugging output as it was useful. 2015-02-04 Doug Evans * symtab.c (hash_symbol_entry): Hash STRUCT_DOMAIN symbols as VAR_DOMAIN. (symbol_cache_lookup): Clarify use of bsc_ptr, slot_ptr parameters. Include symbol domain in debugging output. diff --git a/gdb/symtab.c b/gdb/symtab.c index 84e2680..efa4f81 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1173,7 +1173,12 @@ hash_symbol_entry (const struct objfile *objfile_context, if (name != NULL) hash += htab_hash_string (name); - hash += domain; + /* Because of symbol_matches_domain we need VAR_DOMAIN and STRUCT_DOMAIN + to map to the same slot. */ + if (domain == STRUCT_DOMAIN) + hash += VAR_DOMAIN * 7; + else + hash += domain * 7; return hash; } @@ -1387,8 +1392,9 @@ set_symbol_cache_size_handler (char *args, int from_tty, The result is the symbol if found, SYMBOL_LOOKUP_FAILED if a previous lookup failed (and thus this one will too), or NULL if the symbol is not present in the cache. - *BSC_PTR, *SLOT_PTR are set to the cache and slot of the symbol, whether - found or not found. */ + If the symbol is not present in the cache, then *BSC_PTR and *SLOT_PTR are + set to the cache and slot of the symbol to save the result of a full lookup + attempt. */ static struct symbol * symbol_cache_lookup (struct symbol_cache *cache, @@ -1414,8 +1420,6 @@ symbol_cache_lookup (struct symbol_cache *cache, hash = hash_symbol_entry (objfile_context, name, domain); slot = bsc->symbols + hash % bsc->size; - *bsc_ptr = bsc; - *slot_ptr = slot; if (eq_symbol_entry (slot, objfile_context, name, domain)) { @@ -1432,6 +1436,11 @@ symbol_cache_lookup (struct symbol_cache *cache, return slot->value.found; } + /* Symbol is not present in the cache. */ + + *bsc_ptr = bsc; + *slot_ptr = slot; + if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, @@ -1580,14 +1589,16 @@ symbol_cache_dump (const struct symbol_cache *cache) case SYMBOL_SLOT_UNUSED: break; case SYMBOL_SLOT_NOT_FOUND: - printf_filtered (" [%-4u] = %s, %s (not found)\n", i, + printf_filtered (" [%4u] = %s, %s %s (not found)\n", i, host_address_to_string (slot->objfile_context), - slot->value.not_found.name); + slot->value.not_found.name, + domain_name (slot->value.not_found.domain)); break; case SYMBOL_SLOT_FOUND: - printf_filtered (" [%-4u] = %s, %s\n", i, + printf_filtered (" [%4u] = %s, %s %s\n", i, host_address_to_string (slot->objfile_context), - SYMBOL_PRINT_NAME (slot->value.found)); + SYMBOL_PRINT_NAME (slot->value.found), + domain_name (SYMBOL_DOMAIN (slot->value.found))); break; } }