]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 20 Apr 2011 20:10:30 +0000 (20:10 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 20 Apr 2011 20:10:30 +0000 (20:10 +0000)
* ada-lang.c (struct add_partial_datum): Update the comment for
expand_partial_symbol_name.
(ada_add_partial_symbol_completions): Rename to ...
(ada_expand_partial_symbol_name): ... here, change return type, update
function comment, call symbol_completion_match instead of
symbol_completion_add.
(ada_make_symbol_completion_list): Use now expand_partial_symbol_names
and ada_expand_partial_symbol_name.
* dwarf2read.c (dw2_expand_symtabs_matching): Support NULL
FILE_MATCHER.
(dw2_map_symbol_names): Remove.
(dwarf2_gdb_index_functions): Unlist dw2_map_symbol_names.
* psymtab.c (map_symbol_names_psymtab): Remove.
(expand_symtabs_matching_via_partial): Support NULL FILE_MATCHER.
Support KIND == ALL_DOMAIN.  Exchange the NAME_MATCHER and KIND check
order.
(psym_functions): Unlist map_symbol_names_psymtab.
(map_partial_symbol_names): Rename to ...
(expand_partial_symbol_names): ... here, change the FUN type, call
expand_symtabs_matching with ALL_DOMAIN and NULL FILE_MATCHER now.
* psymtab.h (map_partial_symbol_names): Rename to ...
(expand_partial_symbol_names): ... here, change the FUN type.
* symfile.h (struct quick_symbol_functions): Update the description of
expand_symtabs_matching.  Remove map_symbol_names.
* symtab.c (search_symbols): Add ALL_DOMAIN to the function comment.
(struct add_name_data): Update the comment for
expand_partial_symbol_name.
(add_partial_symbol_name): Rename to ...
(expand_partial_symbol_name): ... here.  Replace
completion_list_add_name call by strncmp.
(default_make_symbol_completion_list_break_on): Use now
expand_partial_symbol_names and expand_partial_symbol_name.
* symtab.h (enum search_domain): New element ALL_DOMAIN.

gdb/testsuite/
* gdb.cp/cpcompletion.exp (complete class methods)
(complete class methods beginning with F): Move them above runto.  New
comment about the runto delimiter.

gdb/ChangeLog
gdb/ada-lang.c
gdb/dwarf2read.c
gdb/psymtab.c
gdb/psymtab.h
gdb/symfile.h
gdb/symtab.c
gdb/symtab.h
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/cpcompletion.exp

index 7c32329a9c41cc2c0f0ef1b790bd1ad099b32a39..6b1b4f2a46b2f45a9c0222c37527b7af05cc98bd 100644 (file)
@@ -1,3 +1,39 @@
+2011-04-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * ada-lang.c (struct add_partial_datum): Update the comment for
+       expand_partial_symbol_name.
+       (ada_add_partial_symbol_completions): Rename to ...
+       (ada_expand_partial_symbol_name): ... here, change return type, update
+       function comment, call symbol_completion_match instead of
+       symbol_completion_add.
+       (ada_make_symbol_completion_list): Use now expand_partial_symbol_names
+       and ada_expand_partial_symbol_name.
+       * dwarf2read.c (dw2_expand_symtabs_matching): Support NULL
+       FILE_MATCHER.
+       (dw2_map_symbol_names): Remove.
+       (dwarf2_gdb_index_functions): Unlist dw2_map_symbol_names.
+       * psymtab.c (map_symbol_names_psymtab): Remove.
+       (expand_symtabs_matching_via_partial): Support NULL FILE_MATCHER.
+       Support KIND == ALL_DOMAIN.  Exchange the NAME_MATCHER and KIND check
+       order.
+       (psym_functions): Unlist map_symbol_names_psymtab.
+       (map_partial_symbol_names): Rename to ...
+       (expand_partial_symbol_names): ... here, change the FUN type, call
+       expand_symtabs_matching with ALL_DOMAIN and NULL FILE_MATCHER now.
+       * psymtab.h (map_partial_symbol_names): Rename to ...
+       (expand_partial_symbol_names): ... here, change the FUN type.
+       * symfile.h (struct quick_symbol_functions): Update the description of
+       expand_symtabs_matching.  Remove map_symbol_names.
+       * symtab.c (search_symbols): Add ALL_DOMAIN to the function comment.
+       (struct add_name_data): Update the comment for
+       expand_partial_symbol_name.
+       (add_partial_symbol_name): Rename to ...
+       (expand_partial_symbol_name): ... here.  Replace
+       completion_list_add_name call by strncmp.
+       (default_make_symbol_completion_list_break_on): Use now
+       expand_partial_symbol_names and expand_partial_symbol_name.
+       * symtab.h (enum search_domain): New element ALL_DOMAIN.
+
 2011-04-20  Pedro Alves  <pedro@codesourcery.com>
 
        * regcache.c (get_thread_arch_regcache): If creating a regcache for
index 2063f3de3c813fb32ae6df588bbb93dd3b80e31f..8fc8b1591351659dc6c802551ddb51a476adb0f0 100644 (file)
@@ -5486,7 +5486,7 @@ symbol_completion_add (VEC(char_ptr) **sv,
 }
 
 /* An object of this type is passed as the user_data argument to the
-   map_partial_symbol_names method.  */
+   expand_partial_symbol_names method.  */
 struct add_partial_datum
 {
   VEC(char_ptr) **completions;
@@ -5498,15 +5498,14 @@ struct add_partial_datum
   int encoded;
 };
 
-/* A callback for map_partial_symbol_names.  */
-static void
-ada_add_partial_symbol_completions (const char *name, void *user_data)
+/* A callback for expand_partial_symbol_names.  */
+static int
+ada_expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_partial_datum *data = user_data;
-
-  symbol_completion_add (data->completions, name,
-                        data->text, data->text_len, data->text0, data->word,
-                        data->wild_match, data->encoded);
+  
+  return symbol_completion_match (name, data->text, data->text_len,
+                                  data->wild_match, data->encoded) != NULL;
 }
 
 /* Return a list of possible symbol names completing TEXT0.  The list
@@ -5564,7 +5563,7 @@ ada_make_symbol_completion_list (char *text0, char *word)
     data.word = word;
     data.wild_match = wild_match;
     data.encoded = encoded;
-    map_partial_symbol_names (ada_add_partial_symbol_completions, &data);
+    expand_partial_symbol_names (ada_expand_partial_symbol_name, &data);
   }
 
   /* At this point scan through the misc symbol vectors and add each
index 08f603ef58f318f21a23bd5df4d21fd26fc8e172..88513ebdf2ff2c30b87bcfa57226b58c220150b9 100644 (file)
@@ -2560,30 +2560,31 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
     return;
   index = dwarf2_per_objfile->index_table;
 
-  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
-                  + dwarf2_per_objfile->n_type_comp_units); ++i)
-    {
-      int j;
-      struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
-      struct quick_file_names *file_data;
+  if (file_matcher != NULL)
+    for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+                    + dwarf2_per_objfile->n_type_comp_units); ++i)
+      {
+       int j;
+       struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+       struct quick_file_names *file_data;
 
-      per_cu->v.quick->mark = 0;
-      if (per_cu->v.quick->symtab)
-       continue;
+       per_cu->v.quick->mark = 0;
+       if (per_cu->v.quick->symtab)
+         continue;
 
-      file_data = dw2_get_file_names (objfile, per_cu);
-      if (file_data == NULL)
-       continue;
+       file_data = dw2_get_file_names (objfile, per_cu);
+       if (file_data == NULL)
+         continue;
 
-      for (j = 0; j < file_data->num_file_names; ++j)
-       {
-         if (file_matcher (file_data->file_names[j], data))
-           {
-             per_cu->v.quick->mark = 1;
-             break;
-           }
-       }
-    }
+       for (j = 0; j < file_data->num_file_names; ++j)
+         {
+           if (file_matcher (file_data->file_names[j], data))
+             {
+               per_cu->v.quick->mark = 1;
+               break;
+             }
+         }
+      }
 
   for (iter = 0; iter < index->symbol_table_slots; ++iter)
     {
@@ -2609,7 +2610,7 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
          struct dwarf2_per_cu_data *per_cu;
 
          per_cu = dw2_get_cu (MAYBE_SWAP (vec[vec_idx + 1]));
-         if (per_cu->v.quick->mark)
+         if (file_matcher == NULL || per_cu->v.quick->mark)
            dw2_instantiate_symtab (objfile, per_cu);
        }
     }
@@ -2640,36 +2641,6 @@ dw2_find_pc_sect_symtab (struct objfile *objfile,
   return dw2_instantiate_symtab (objfile, data);
 }
 
-static void
-dw2_map_symbol_names (struct objfile *objfile,
-                     void (*fun) (const char *, void *),
-                     void *data)
-{
-  offset_type iter;
-  struct mapped_index *index;
-
-  dw2_setup (objfile);
-
-  /* index_table is NULL if OBJF_READNOW.  */
-  if (!dwarf2_per_objfile->index_table)
-    return;
-  index = dwarf2_per_objfile->index_table;
-
-  for (iter = 0; iter < index->symbol_table_slots; ++iter)
-    {
-      offset_type idx = 2 * iter;
-      const char *name;
-      offset_type *vec, vec_len, vec_idx;
-
-      if (index->symbol_table[idx] == 0 && index->symbol_table[idx + 1] == 0)
-       continue;
-
-      name = (index->constant_pool + MAYBE_SWAP (index->symbol_table[idx]));
-
-      (*fun) (name, data);
-    }
-}
-
 static void
 dw2_map_symbol_filenames (struct objfile *objfile,
                          void (*fun) (const char *, const char *, void *),
@@ -2726,7 +2697,6 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
   dw2_map_matching_symbols,
   dw2_expand_symtabs_matching,
   dw2_find_pc_sect_symtab,
-  dw2_map_symbol_names,
   dw2_map_symbol_filenames
 };
 
index a402a5da6f60246abe4836b8b843a3808dd5fc0d..cd117c1e1ea1e401d3664e0cc480517a76b07899 100644 (file)
@@ -1072,42 +1072,6 @@ read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
     }
 }
 
-static void
-map_symbol_names_psymtab (struct objfile *objfile,
-                         void (*fun) (const char *, void *), void *data)
-{
-  struct partial_symtab *ps;
-
-  ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
-    {
-      struct partial_symbol **psym;
-
-      /* If the psymtab's been read in we'll get it when we search
-        through the blockvector.  */
-      if (ps->readin)
-       continue;
-
-      for (psym = objfile->global_psymbols.list + ps->globals_offset;
-          psym < (objfile->global_psymbols.list + ps->globals_offset
-                  + ps->n_global_syms);
-          psym++)
-       {
-         /* If interrupted, then quit.  */
-         QUIT;
-         (*fun) (SYMBOL_NATURAL_NAME (*psym), data);
-       }
-
-      for (psym = objfile->static_psymbols.list + ps->statics_offset;
-          psym < (objfile->static_psymbols.list + ps->statics_offset
-                  + ps->n_static_syms);
-          psym++)
-       {
-         QUIT;
-         (*fun) (SYMBOL_NATURAL_NAME (*psym), data);
-       }
-    }
-}
-
 static void
 map_symbol_filenames_psymtab (struct objfile *objfile,
                              void (*fun) (const char *, const char *,
@@ -1258,7 +1222,7 @@ expand_symtabs_matching_via_partial (struct objfile *objfile,
       if (ps->readin)
        continue;
 
-      if (! (*file_matcher) (ps->filename, data))
+      if (file_matcher && ! (*file_matcher) (ps->filename, data))
        continue;
 
       gbound = objfile->global_psymbols.list
@@ -1287,14 +1251,15 @@ expand_symtabs_matching_via_partial (struct objfile *objfile,
            {
              QUIT;
 
-             if ((*name_matcher) (SYMBOL_NATURAL_NAME (*psym), data)
-                 && ((kind == VARIABLES_DOMAIN
+             if ((kind == ALL_DOMAIN
+                  || (kind == VARIABLES_DOMAIN
                       && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
                       && SYMBOL_CLASS (*psym) != LOC_BLOCK)
-                     || (kind == FUNCTIONS_DOMAIN
-                         && SYMBOL_CLASS (*psym) == LOC_BLOCK)
-                     || (kind == TYPES_DOMAIN
-                         && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)))
+                  || (kind == FUNCTIONS_DOMAIN
+                      && SYMBOL_CLASS (*psym) == LOC_BLOCK)
+                  || (kind == TYPES_DOMAIN
+                      && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
+                 && (*name_matcher) (SYMBOL_NATURAL_NAME (*psym), data))
                {
                  PSYMTAB_TO_SYMTAB (ps);
                  keep_going = 0;
@@ -1329,7 +1294,6 @@ const struct quick_symbol_functions psym_functions =
   map_matching_symbols_psymtab,
   expand_symtabs_matching_via_partial,
   find_pc_sect_symtab_from_partial,
-  map_symbol_names_psymtab,
   map_symbol_filenames_psymtab
 };
 
@@ -1932,14 +1896,15 @@ maintenance_check_symtabs (char *ignore, int from_tty)
 \f
 
 void
-map_partial_symbol_names (void (*fun) (const char *, void *), void *data)
+expand_partial_symbol_names (int (*fun) (const char *, void *), void *data)
 {
   struct objfile *objfile;
 
   ALL_OBJFILES (objfile)
   {
     if (objfile->sf)
-      objfile->sf->qf->map_symbol_names (objfile, fun, data);
+      objfile->sf->qf->expand_symtabs_matching (objfile, NULL, fun,
+                                               ALL_DOMAIN, data);
   }
 }
 
index 73e0a81a1294fe1dc3534b4106eadb664aa629b9..086ff2fb6634c157ec42f7e40bcc8f93b6953773 100644 (file)
@@ -28,7 +28,8 @@ extern struct psymbol_bcache *psymbol_bcache_init (void);
 extern void psymbol_bcache_free (struct psymbol_bcache *);
 extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
 
-void map_partial_symbol_names (void (*) (const char *, void *), void *);
+void expand_partial_symbol_names (int (*fun) (const char *, void *),
+                                 void *data);
 
 void map_partial_symbol_filenames (void (*) (const char *, const char *,
                                             void *),
index a0151eafadb952eed9cec87d7f776846b8dc7a2a..19e3fd5cbf04ef829682457bc73f25e56524d679 100644 (file)
@@ -249,17 +249,18 @@ struct quick_symbol_functions
 
      FILE_MATCHER is called for each file in OBJFILE.  The file name
      and the DATA argument are passed to it.  If it returns zero, this
-     file is skipped.
+     file is skipped.  If FILE_MATCHER is NULL such file is not skipped.
 
-     Otherwise, if the file is not skipped, then NAME_MATCHER is
-     called for each symbol defined in the file.  The symbol's
-     "natural" name and DATA are passed to NAME_MATCHER.
+     Otherwise, if KIND does not match this symbol is skipped.
+     
+     If even KIND matches, then NAME_MATCHER is called for each symbol defined
+     in the file.  The symbol's "natural" name and DATA are passed to
+     NAME_MATCHER.
 
      If NAME_MATCHER returns zero, then this symbol is skipped.
 
-     Otherwise, if this symbol is not skipped, and it matches KIND,
-     then this symbol's symbol table is expanded.
-     
+     Otherwise, this symbol's symbol table is expanded.
+
      DATA is user data that is passed unmodified to the callback
      functions.  */
   void (*expand_symtabs_matching) (struct objfile *objfile,
@@ -280,13 +281,6 @@ struct quick_symbol_functions
                                         struct obj_section *section,
                                         int warn_if_readin);
 
-  /* Call a callback for every symbol defined in OBJFILE.  FUN is the
-     callback.  It is passed the symbol's natural name, and the DATA
-     passed to this function.  */
-  void (*map_symbol_names) (struct objfile *objfile,
-                           void (*fun) (const char *, void *),
-                           void *data);
-
   /* Call a callback for every file defined in OBJFILE whose symtab is
      not already read in.  FUN is the callback.  It is passed the file's name,
      the file's full name, and the DATA passed to this function.  */
index 8aa692d6c3bd7fca73ba6c50c6b4900cbe0c2942..d6e82b16b2bc3eb9ddc9f71bacedc45c3b4db456 100644 (file)
@@ -2979,6 +2979,7 @@ search_symbols_name_matches (const char *symname, void *user_data)
    TYPES_DOMAIN     - search all type names
    VARIABLES_DOMAIN - search all symbols, excluding functions, type names,
    and constants (enums)
+   ALL_DOMAIN       - an internal error for this function
 
    free_search_symbols should be called when *MATCHES is no longer needed.
 
@@ -3017,7 +3018,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
   struct cleanup *old_chain = NULL;
   struct search_symbols_data datum;
 
-  if (kind < VARIABLES_DOMAIN)
+  if (kind < VARIABLES_DOMAIN || kind >= ALL_DOMAIN)
     error (_("must search on specific domain"));
 
   ourtype = types[(int) (kind - VARIABLES_DOMAIN)];
@@ -3667,7 +3668,7 @@ completion_list_add_fields (struct symbol *sym, char *sym_text,
 }
 
 /* Type of the user_data argument passed to add_macro_name or
-   add_partial_symbol_name.  The contents are simply whatever is
+   expand_partial_symbol_name.  The contents are simply whatever is
    needed by completion_list_add_name.  */
 struct add_name_data
 {
@@ -3690,15 +3691,13 @@ add_macro_name (const char *name, const struct macro_definition *ignore,
                            datum->text, datum->word);
 }
 
-/* A callback for map_partial_symbol_names.  */
-static void
-add_partial_symbol_name (const char *name, void *user_data)
+/* A callback for expand_partial_symbol_names.  */
+static int
+expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_name_data *datum = (struct add_name_data *) user_data;
 
-  completion_list_add_name ((char *) name,
-                           datum->sym_text, datum->sym_text_len,
-                           datum->text, datum->word);
+  return strncmp (name, datum->sym_text, datum->sym_text_len) == 0;
 }
 
 char **
@@ -3788,8 +3787,9 @@ default_make_symbol_completion_list_break_on (char *text, char *word,
   datum.word = word;
 
   /* Look through the partial symtabs for all symbols which begin
-     by matching SYM_TEXT.  Add each one that you find to the list.  */
-  map_partial_symbol_names (add_partial_symbol_name, &datum);
+     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_partial_symbol_names (expand_partial_symbol_name, &datum);
 
   /* At this point scan through the misc symbol vectors and add each
      symbol you find to the list.  Eventually we want to ignore
index abe5e8610ef112c0fa3c2a668576ca7cb41598df..63002ac9bb5d418f53671b422cfc9977d9ee1a97 100644 (file)
@@ -408,7 +408,10 @@ typedef enum domain_enum_tag
   FUNCTIONS_DOMAIN,
 
   /* All defined types */
-  TYPES_DOMAIN
+  TYPES_DOMAIN,
+
+  /* Any type.  */
+  ALL_DOMAIN
 }
 domain_enum;
 
index a74a9400c68ed0ba2e8e30eb0e29da57adb3db70..c0911007cd61c542439462fd972de68850a02223 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * gdb.cp/cpcompletion.exp (complete class methods)
+       (complete class methods beginning with F): Move them above runto.  New
+       comment about the runto delimiter.
+
 2011-04-20  Pedro Alves  <pedro@codesourcery.com>
 
        * gdb.base/maint.exp: Test that "maint print registers" works
index 6a1978047cec7fe5f8fdc8d246a847f3396b5e18..9c96bb7e42810b7ff9b4b7fce55fc0ef2eaa125d 100644 (file)
@@ -74,6 +74,15 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
+# Test that completion is restricted by class name (all methods)
+test_class_complete Foo "" "complete class methods" \
+    [list Foo Foofoo get_foo set_foo ~Foo]
+
+test_class_complete Foo F "complete class methods beginning with F" \
+    [list Foo Foofoo]
+
+# The tests below depend on the current code scope.
+
 set bp_location [gdb_get_line_number "Set breakpoint here" ${testfile}.cc]
 
 if {![runto "${testfile}.cc:$bp_location"]} {
@@ -93,11 +102,3 @@ gdb_test "complete p foo1.Fo" "p foo1\\.Foofoo"
 
 # Test completion with an anonymous struct.
 gdb_test "complete p a.g" "p a\\.get"
-
-# Test that completion is restricted by class name (all methods)
-test_class_complete Foo "" "complete class methods" \
-    [list Foo Foofoo get_foo set_foo ~Foo]
-
-test_class_complete Foo F "complete class methods beginning with F" \
-    [list Foo Foofoo]
-