From patchwork Fri Jun 2 12:22:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20728 Received: (qmail 29392 invoked by alias); 2 Jun 2017 12:30:00 -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 29216 invoked by uid 89); 2 Jun 2017 12:30:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Fri, 02 Jun 2017 12:29:54 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A55277EBAE for ; Fri, 2 Jun 2017 12:23:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A55277EBAE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A55277EBAE Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BBC64DA6B for ; Fri, 2 Jun 2017 12:23:10 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 30/40] Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints Date: Fri, 2 Jun 2017 13:22:28 +0100 Message-Id: <1496406158-12663-31-git-send-email-palves@redhat.com> In-Reply-To: <1496406158-12663-1-git-send-email-palves@redhat.com> References: <1496406158-12663-1-git-send-email-palves@redhat.com> While working on C++ support for wild matching, I noticed that attaching to my system's Firefox (which uses .gdb_index), setting a break at main and bailing, like: $ gdb --batch -q -p `pidof firefox` -ex "b main" would get substancially slower. It'd take around 20s when currently it takes 3s. The problem is that gdb would expand more symtabs than currently, because Firefox has symbols named like "nsHtml5Atoms::main", "nsGkAtoms::main", etc., which given wild matching, match. However, these are not function symbols, [they're "(nsIAtom *)"], so it seems silly that they'd cause expansion in the first place. The .gdb_index code (dwarf2read.c:dw2_expand_marked_cus) filters out symbols matches based on search_domain: case VARIABLES_DOMAIN: if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE) continue; break; case FUNCTIONS_DOMAIN: if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION) continue; break; case TYPES_DOMAIN: if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) continue; break; default: break; however, we're currently passing down search_domain::ALL_DOMAIN when we know we're looking for functions, for no good reason. This patch fixes that. It seems like search_domain is underutilized throughout, but I'll leave using it more for another pass. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * linespec.c (iterate_over_all_matching_symtabs): Add search_domain parameter. Pass it down to expand_symtabs_matching. (decode_objc): Request FUNCTIONS_DOMAIN symbols only. (lookup_prefix_sym): Adjust by passing ALL_DOMAIN as search_domain. (add_all_symbol_names_from_pspace): Add search_domain parameter. Pass it down. (find_method, find_function_symbols): Request FUNCTIONS_DOMAIN symbols. (add_matching_symbols_to_info): Add search_domain parameter. Pass it down. --- gdb/linespec.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index fa07534..5d95308 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -363,12 +363,14 @@ static int symbol_to_sal (struct symtab_and_line *result, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, + enum search_domain search_domain, struct collect_info *info, struct program_space *pspace); static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, - VEC (const_char_ptr) *names); + VEC (const_char_ptr) *names, + enum search_domain search_domain); static VEC (symtab_ptr) * collect_symtabs_from_filename (const char *file, @@ -1107,6 +1109,7 @@ iterate_over_all_matching_symtabs (struct linespec_state *state, const lookup_name_info &lookup_name, const domain_enum name_domain, + enum search_domain search_domain, struct program_space *search_pspace, bool include_inline, gdb::function_view callback) { @@ -1131,7 +1134,7 @@ iterate_over_all_matching_symtabs NULL, lookup_name, NULL, NULL, - ALL_DOMAIN); + search_domain); ALL_OBJFILE_COMPUNITS (objfile, cu) { @@ -3461,7 +3464,8 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) return values; } - add_all_symbol_names_from_pspace (&info, NULL, symbol_names); + add_all_symbol_names_from_pspace (&info, NULL, symbol_names, + FUNCTIONS_DOMAIN); if (!VEC_empty (symbolp, info.result.symbols) || !VEC_empty (bound_minimal_symbol_d, info.result.minimal_symbols)) @@ -3588,11 +3592,11 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_ptr) *file_symtabs, if (elt == NULL) { iterate_over_all_matching_symtabs (state, lookup_name, - STRUCT_DOMAIN, NULL, false, - collector); + STRUCT_DOMAIN, ALL_DOMAIN, + NULL, false, collector); iterate_over_all_matching_symtabs (state, lookup_name, - VAR_DOMAIN, NULL, false, - collector); + VAR_DOMAIN, ALL_DOMAIN, + NULL, false, collector); } else { @@ -3676,7 +3680,8 @@ compare_msymbols (const void *a, const void *b) static void add_all_symbol_names_from_pspace (struct collect_info *info, struct program_space *pspace, - VEC (const_char_ptr) *names) + VEC (const_char_ptr) *names, + enum search_domain search_domain) { int ix; const char *iter; @@ -3684,7 +3689,7 @@ add_all_symbol_names_from_pspace (struct collect_info *info, for (ix = 0; VEC_iterate (const_char_ptr, names, ix, iter); ++ix) add_matching_symbols_to_info (iter, symbol_name_match_type::FULL, - info, pspace); + search_domain, info, pspace); } static void @@ -3791,7 +3796,8 @@ find_method (struct linespec_state *self, VEC (symtab_ptr) *file_symtabs, /* We have a list of candidate symbol names, so now we iterate over the symbol tables looking for all matches in this pspace. */ - add_all_symbol_names_from_pspace (&info, pspace, result_names); + add_all_symbol_names_from_pspace (&info, pspace, result_names, + FUNCTIONS_DOMAIN); VEC_truncate (typep, superclass_vec, 0); last_result_len = VEC_length (const_char_ptr, result_names); @@ -3951,9 +3957,10 @@ find_function_symbols (struct linespec_state *state, find_imps (name, &symbol_names); if (!VEC_empty (const_char_ptr, symbol_names)) add_all_symbol_names_from_pspace (&info, state->search_pspace, - symbol_names); + symbol_names, FUNCTIONS_DOMAIN); else add_matching_symbols_to_info (name, symbol_name_match_type::WILD, + FUNCTIONS_DOMAIN, &info, state->search_pspace); do_cleanups (cleanup); @@ -4550,6 +4557,7 @@ search_minsyms_for_name (struct collect_info *info, static void add_matching_symbols_to_info (const char *name, symbol_name_match_type name_match_type, + enum search_domain search_domain, struct collect_info *info, struct program_space *pspace) { @@ -4563,7 +4571,7 @@ add_matching_symbols_to_info (const char *name, if (elt == NULL) { iterate_over_all_matching_symtabs (info->state, lookup_name, - VAR_DOMAIN, + VAR_DOMAIN, search_domain, pspace, true, [&] (symbol *sym) { return info->add_symbol (sym); }); search_minsyms_for_name (info, lookup_name, pspace, NULL);