new callback parameter expansion_notify for expand_symtabs_matching
authorGary Benson <gbenson@redhat.com>
Sat, 31 Jan 2015 22:45:26 +0000 (14:45 -0800)
committerDoug Evans <xdje42@gmail.com>
Sat, 31 Jan 2015 22:45:26 +0000 (14:45 -0800)
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) <expand_symtabs_matching>:
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
gdb/ada-lang.c
gdb/dwarf2read.c
gdb/linespec.c
gdb/psymtab.c
gdb/symfile-debug.c
gdb/symfile.c
gdb/symfile.h
gdb/symmisc.c
gdb/symtab.c

index 33e0dffddc8594b252a80de45ef5a2411033191e..d97b9c4e3a2011c3477c7d7799db48dbd1fa74ca 100644 (file)
@@ -1,3 +1,17 @@
+2015-01-31  Gary Benson  <gbenson@redhat.com>
+
+       * symfile.h (expand_symtabs_exp_notify_ftype): New typedef.
+       (struct quick_symbol_functions) <expand_symtabs_matching>:
+       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.
+
 2015-01-31  Doug Evans  <xdje42@gmail.com>
 
        * cli-out.c: #include completer.h, readline/readline.h.
index f5753f13fcb7613fb1f1c739e73ec99116714895..f4f5bf36c8c162058cecd1510ab067367d6b4f22 100644 (file)
@@ -6247,8 +6247,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
@@ -12992,7 +12992,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)
index 090d1a5928939c5e7e31601c6782a3aeea181307..56e82f53a75ddcfdc2997e1fd0d56952afcc5211 100644 (file)
@@ -3825,6 +3825,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)
 {
@@ -3996,7 +3997,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);
+               }
+           }
        }
     }
 }
index 8a0d4be6ed1886167b96bdf8767c738f00f88919..0d012b402b732213f34fe921ac95df5e4c19f21e 100644 (file)
@@ -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)
index 592efd7d785c79667c83463ea5f32e7bfb41df6c..4ee9dc1e82fe93812ae4f8ed0732303b6d7c06c8 100644 (file)
@@ -1409,6 +1409,7 @@ psym_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)
 {
@@ -1451,7 +1452,13 @@ psym_expand_symtabs_matching
        }
 
       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);
+       }
     }
 }
 
index 92d00137b153f423f53069ab70ad1b2001f7e517..e0600a91f18f03078ef897018311cf37853b4977 100644 (file)
@@ -281,22 +281,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",
                    objfile_debug_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);
 }
 
index 96c7951be7bdddf4986db2df53ee697a62c86a75..5ae50009bf2e3de7bd1c3da8d825b9e1e2cb1865 100644 (file)
@@ -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);
   }
 }
index 380bd0e40aee315cb3e4279b8ac9f4a3b36f30a4..d5ae4ad85e4245fa1edbfffd490214a2d4dc7704 100644 (file)
@@ -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,
index 5c6b626ad8eca0ea7c609f0923a94fbd9ff051af..bee07ac64ea35c7cae4b01ec3a3e47a643928661 100644 (file)
@@ -926,7 +926,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);
        }
     }
 
index 321241beb691d67af2a724abd483368ccab46b77..47aea7664b81f72a01874b8de1a1b0bde926c9f5 100644 (file)
@@ -4521,7 +4521,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.
@@ -5309,8 +5309,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