gdb/
[deliverable/binutils-gdb.git] / gdb / linespec.c
index 28fcf4dd4dd21b150db1b95a31db53120f541d3f..c2057cf708b7d9497fa466fa9df2e2badf7c9cfe 100644 (file)
@@ -329,21 +329,20 @@ struct symbol_matcher_data
   const char *lookup_name;
 
   /* The routine to be used for comparison.  */
-  symbol_name_match_p_ftype symbol_name_match_p;
+  symbol_name_cmp_ftype symbol_name_cmp;
 };
 
 /* A helper for iterate_over_all_matching_symtabs that is passed as a
    callback to the expand_symtabs_matching method.  */
 
 static int
-iterate_name_matcher (const struct language_defn *language,
-                     const char *name, void *d)
+iterate_name_matcher (const char *name, void *d)
 {
   const struct symbol_matcher_data *data = d;
 
-  if (data->symbol_name_match_p (name, data->lookup_name))
-    return 1;
-  return 0;
+  if (data->symbol_name_cmp (name, data->lookup_name) == 0)
+    return 1; /* Expand this symbol's symbol table.  */
+  return 0; /* Skip this symbol.  */
 }
 
 /* A helper that walks over all matching symtabs in all objfiles and
@@ -354,7 +353,7 @@ iterate_name_matcher (const struct language_defn *language,
 static void
 iterate_over_all_matching_symtabs (const char *name,
                                   const domain_enum domain,
-                                  int (*callback) (struct symbol *, void *),
+                                  symbol_found_callback_ftype *callback,
                                   void *data,
                                   struct program_space *search_pspace)
 {
@@ -363,9 +362,9 @@ iterate_over_all_matching_symtabs (const char *name,
   struct symbol_matcher_data matcher_data;
 
   matcher_data.lookup_name = name;
-  matcher_data.symbol_name_match_p =
-    current_language->la_get_symbol_name_match_p != NULL
-    ? current_language->la_get_symbol_name_match_p (name)
+  matcher_data.symbol_name_cmp =
+    current_language->la_get_symbol_name_cmp != NULL
+    ? current_language->la_get_symbol_name_cmp (name)
     : strcmp_iw;
 
   ALL_PSPACES (pspace)
@@ -436,8 +435,7 @@ find_methods (struct type *t, const char *name,
 {
   int i1 = 0;
   int ibase;
-  char *class_name = type_name_no_tag (t);
-  char *canon;
+  const char *class_name = type_name_no_tag (t);
 
   /* Ignore this class if it doesn't have a name.  This is ugly, but
      unless we figure out how to get the physname without the name of
@@ -457,7 +455,7 @@ find_methods (struct type *t, const char *name,
           method_counter >= 0;
           --method_counter)
        {
-         char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter);
+         const char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter);
          char dem_opname[64];
 
          if (strncmp (method_name, "__", 2) == 0 ||
@@ -652,6 +650,11 @@ decode_line_2 (struct linespec_state *self,
       return;
     }
 
+  /* Sort the list of method names alphabetically.  */
+  qsort (VEC_address (const_char_ptr, item_names),
+        VEC_length (const_char_ptr, item_names),
+        sizeof (const_char_ptr), compare_strings);
+
   printf_unfiltered (_("[0] cancel\n[1] all\n"));
   for (i = 0; VEC_iterate (const_char_ptr, item_names, i, iter); ++i)
     printf_unfiltered ("[%d] %s\n", i + 2, iter);
@@ -905,7 +908,7 @@ decode_line_internal (struct linespec_state *self, char **argptr)
 
   /* Locate the end of the first half of the linespec.
      After the call, for instance, if the argptr string is "foo.c:123"
-     p will point at "123".  If there is only one part, like "foo", p
+     p will point at ":123".  If there is only one part, like "foo", p
      will point to "".  If this is a C++ name, like "A::B::foo", p will
      point to "::B::foo".  Argptr is not changed by this call.  */
 
@@ -914,9 +917,11 @@ decode_line_internal (struct linespec_state *self, char **argptr)
   /* First things first: if ARGPTR starts with a filename, get its
      symtab and strip the filename from ARGPTR.
      Avoid calling symtab_from_filename if we know can,
-     it can be expensive.  */
+     it can be expensive.  We know we can avoid the call if we see a
+     single word (e.g., "break NAME") or if we see a qualified C++
+     name ("break QUAL::NAME").  */
 
-  if (*p != '\0')
+  if (*p != '\0' && !(p[0] == ':' && p[1] == ':'))
     {
       TRY_CATCH (file_exception, RETURN_MASK_ERROR)
        {
@@ -1809,14 +1814,14 @@ collect_one_symbol (struct symbol *sym, void *d)
   struct type *t;
 
   if (SYMBOL_CLASS (sym) != LOC_TYPEDEF)
-    return 1;
+    return 1; /* Continue iterating.  */
 
   t = SYMBOL_TYPE (sym);
   CHECK_TYPEDEF (t);
   if (TYPE_CODE (t) != TYPE_CODE_STRUCT
       && TYPE_CODE (t) != TYPE_CODE_UNION
       && TYPE_CODE (t) != TYPE_CODE_NAMESPACE)
-    return 1;
+    return 1; /* Continue iterating.  */
 
   slot = htab_find_slot (collector->unique_syms, sym, INSERT);
   if (!*slot)
@@ -1825,7 +1830,7 @@ collect_one_symbol (struct symbol *sym, void *d)
       VEC_safe_push (symbolp, collector->symbols, sym);
     }
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* Return the symbol corresponding to the substring of *ARGPTR ending
@@ -2216,7 +2221,7 @@ collect_function_symbols (struct symbol *sym, void *arg)
   if (SYMBOL_CLASS (sym) == LOC_BLOCK)
     VEC_safe_push (symbolp, *syms, sym);
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* Look up a function symbol in *ARGPTR.  If found, advance *ARGPTR
@@ -2723,7 +2728,7 @@ collect_symbols (struct symbol *sym, void *data)
     add_sal_to_sals (info->state, &info->result, &sal,
                     SYMBOL_NATURAL_NAME (sym));
 
-  return 1;
+  return 1; /* Continue iterating.  */
 }
 
 /* We've found a minimal symbol MSYMBOL to associate with our
This page took 0.028355 seconds and 4 git commands to generate.