From patchwork Thu Nov 27 13:16:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 3972 Received: (qmail 2958 invoked by alias); 27 Nov 2014 13:16:20 -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 2934 invoked by uid 89); 27 Nov 2014 13:16:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, SPF_HELO_PASS, SPF_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; Thu, 27 Nov 2014 13:16:17 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sARDGDpK001196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Nov 2014 08:16:13 -0500 Received: from blade.nx (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sARDGBPG024974; Thu, 27 Nov 2014 08:16:12 -0500 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 0FC092629AA; Thu, 27 Nov 2014 13:16:11 +0000 (GMT) From: Gary Benson To: gdb-patches@sourceware.org Cc: Doug Evans , Eli Zaretskii Subject: [PATCH 1/3 v2] Add expansion_notify callback to expand_symtabs_matching Date: Thu, 27 Nov 2014 13:16:06 +0000 Message-Id: <1417094168-25868-2-git-send-email-gbenson@redhat.com> In-Reply-To: <1417094168-25868-1-git-send-email-gbenson@redhat.com> References: <1417094168-25868-1-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes This commit adds a new callback parameter, "expansion_notify", to the top-level expand_symtabs_matching function and to all the vectorized functions it defers to. If expansion_notify is non-NULL, it will be called every time a symbol table is expanded. gdb/ChangeLog: * symfile.h (expand_symtabs_exp_notify_ftype): New typedef. (struct quick_symbol_functions) : New argument expansion_notify. All uses updated. (expand_symtabs_matching): New argument expansion_notify. All uses updated. * symfile-debug.c (debug_qf_expand_symtabs_matching): Also print expansion notify. * symtab.c (expand_symtabs_matching_via_partial): Call expansion_notify whenever a partial symbol table is expanded. * dwarf2read.c (dw2_expand_symtabs_matching): Call expansion_notify whenever a symbol table is instantiated. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/ada-lang.c | 6 +++--- gdb/dwarf2read.c | 16 +++++++++++++++- gdb/linespec.c | 2 +- gdb/psymtab.c | 9 ++++++++- gdb/symfile-debug.c | 5 ++++- gdb/symfile.c | 4 +++- gdb/symfile.h | 8 ++++++++ gdb/symmisc.c | 2 +- gdb/symtab.c | 6 +++--- 10 files changed, 60 insertions(+), 12 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3a024d9..af5a4b3 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -6198,8 +6198,8 @@ ada_make_symbol_completion_list (const char *text0, const char *word, data.word = word; data.wild_match = wild_match_p; data.encoded = encoded_p; - expand_symtabs_matching (NULL, ada_complete_symbol_matcher, ALL_DOMAIN, - &data); + expand_symtabs_matching (NULL, ada_complete_symbol_matcher, NULL, + ALL_DOMAIN, &data); } /* At this point scan through the misc symbol vectors and add each @@ -12943,7 +12943,7 @@ ada_add_global_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions) struct objfile *objfile; struct compunit_symtab *s; - expand_symtabs_matching (NULL, ada_exc_search_name_matches, + expand_symtabs_matching (NULL, ada_exc_search_name_matches, NULL, VARIABLES_DOMAIN, preg); ALL_COMPUNITS (objfile, s) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 36cbbd9..1167aaa 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -3787,6 +3787,7 @@ dw2_expand_symtabs_matching (struct objfile *objfile, expand_symtabs_file_matcher_ftype *file_matcher, expand_symtabs_symbol_matcher_ftype *symbol_matcher, + expand_symtabs_exp_notify_ftype *expansion_notify, enum search_domain kind, void *data) { @@ -3958,7 +3959,20 @@ dw2_expand_symtabs_matching per_cu = dw2_get_cutu (cu_index); if (file_matcher == NULL || per_cu->v.quick->mark) - dw2_instantiate_symtab (per_cu); + { + int symtab_was_null = + (per_cu->v.quick->compunit_symtab == NULL); + + dw2_instantiate_symtab (per_cu); + + if (expansion_notify != NULL + && symtab_was_null + && per_cu->v.quick->compunit_symtab != NULL) + { + expansion_notify (per_cu->v.quick->compunit_symtab, + data); + } + } } } } diff --git a/gdb/linespec.c b/gdb/linespec.c index 82384ca..c3432ab 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1028,7 +1028,7 @@ iterate_over_all_matching_symtabs (struct linespec_state *state, if (objfile->sf) objfile->sf->qf->expand_symtabs_matching (objfile, NULL, iterate_name_matcher, - ALL_DOMAIN, + NULL, ALL_DOMAIN, &matcher_data); ALL_OBJFILE_COMPUNITS (objfile, cu) diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 2fc882f..17f5b11 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -1373,6 +1373,7 @@ expand_symtabs_matching_via_partial (struct objfile *objfile, expand_symtabs_file_matcher_ftype *file_matcher, expand_symtabs_symbol_matcher_ftype *symbol_matcher, + expand_symtabs_exp_notify_ftype *expansion_notify, enum search_domain kind, void *data) { @@ -1415,7 +1416,13 @@ expand_symtabs_matching_via_partial } if (recursively_search_psymtabs (ps, objfile, kind, symbol_matcher, data)) - psymtab_to_symtab (objfile, ps); + { + struct compunit_symtab *symtab = + psymtab_to_symtab (objfile, ps); + + if (expansion_notify != NULL) + expansion_notify (symtab, data); + } } } diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 8bca5b2..4dda9e6 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -289,22 +289,25 @@ debug_qf_expand_symtabs_matching (struct objfile *objfile, expand_symtabs_file_matcher_ftype *file_matcher, expand_symtabs_symbol_matcher_ftype *symbol_matcher, + expand_symtabs_exp_notify_ftype *expansion_notify, enum search_domain kind, void *data) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, - "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n", + "qf->expand_symtabs_matching (%s, %s, %s, %s, %s, %s)\n", debug_objfile_name (objfile), host_address_to_string (file_matcher), host_address_to_string (symbol_matcher), + host_address_to_string (expansion_notify), search_domain_name (kind), host_address_to_string (data)); debug_data->real_sf->qf->expand_symtabs_matching (objfile, file_matcher, symbol_matcher, + expansion_notify, kind, data); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 29877ec..6c3612f 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3941,6 +3941,7 @@ symfile_free_objfile (struct objfile *objfile) void expand_symtabs_matching (expand_symtabs_file_matcher_ftype *file_matcher, expand_symtabs_symbol_matcher_ftype *symbol_matcher, + expand_symtabs_exp_notify_ftype *expansion_notify, enum search_domain kind, void *data) { @@ -3950,7 +3951,8 @@ expand_symtabs_matching (expand_symtabs_file_matcher_ftype *file_matcher, { if (objfile->sf) objfile->sf->qf->expand_symtabs_matching (objfile, file_matcher, - symbol_matcher, kind, + symbol_matcher, + expansion_notify, kind, data); } } diff --git a/gdb/symfile.h b/gdb/symfile.h index 1e8c230..aa0bbcd 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -137,6 +137,12 @@ typedef int (expand_symtabs_file_matcher_ftype) (const char *filename, typedef int (expand_symtabs_symbol_matcher_ftype) (const char *name, void *data); +/* Callback for quick_symbol_functions->expand_symtabs_matching + to be called after a symtab has been expanded. */ + +typedef void (expand_symtabs_exp_notify_ftype) \ + (struct compunit_symtab *symtab, void *data); + /* The "quick" symbol functions exist so that symbol readers can avoiding an initial read of all the symbols. For example, symbol readers might choose to use the "partial symbol table" utilities, @@ -282,6 +288,7 @@ struct quick_symbol_functions (struct objfile *objfile, expand_symtabs_file_matcher_ftype *file_matcher, expand_symtabs_symbol_matcher_ftype *symbol_matcher, + expand_symtabs_exp_notify_ftype *expansion_notify, enum search_domain kind, void *data); @@ -569,6 +576,7 @@ extern struct cleanup *increment_reading_symtab (void); void expand_symtabs_matching (expand_symtabs_file_matcher_ftype *, expand_symtabs_symbol_matcher_ftype *, + expand_symtabs_exp_notify_ftype *, enum search_domain kind, void *data); void map_symbol_filenames (symbol_filename_ftype *fun, void *data, diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 5e0cc7a..e65ea54 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -922,7 +922,7 @@ maintenance_expand_symtabs (char *args, int from_tty) { objfile->sf->qf->expand_symtabs_matching (objfile, maintenance_expand_file_matcher, - maintenance_expand_name_matcher, ALL_DOMAIN, regexp); + maintenance_expand_name_matcher, NULL, ALL_DOMAIN, regexp); } } diff --git a/gdb/symtab.c b/gdb/symtab.c index 345c20d..3f137e2 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -3674,7 +3674,7 @@ search_symbols (const char *regexp, enum search_domain kind, ? NULL : search_symbols_file_matches), search_symbols_name_matches, - kind, &datum); + NULL, kind, &datum); /* Here, we search through the minimal symbol tables for functions and variables that match, and force their symbols to be read. @@ -4463,8 +4463,8 @@ default_make_symbol_completion_list_break_on (const char *text, /* Look through the partial symtabs for all symbols which begin by matching SYM_TEXT. Expand all CUs that you find to the list. The real names will get added by COMPLETION_LIST_ADD_SYMBOL below. */ - expand_symtabs_matching (NULL, symbol_completion_matcher, ALL_DOMAIN, - &datum); + expand_symtabs_matching (NULL, symbol_completion_matcher, NULL, + ALL_DOMAIN, &datum); /* At this point scan through the misc symbol vectors and add each symbol you find to the list. Eventually we want to ignore