* breakpoint.c, breakpoint.h (breakpoint_init_inferior): New function
[deliverable/binutils-gdb.git] / gdb / symtab.c
index f8b2d81324bd4930c876f1e2cbc661f51b75993c..b5906a65224f1a2f71373e38c30e422d9c19bdde 100644 (file)
@@ -51,8 +51,11 @@ find_methods PARAMS ((struct type *, char *, struct symbol **));
 static void
 completion_list_add_name PARAMS ((char *, char *, int, char *, char *));
 
+static void
+build_canonical_line_spec PARAMS ((struct symtab_and_line *, char *, char ***));
+
 static struct symtabs_and_lines
-decode_line_2 PARAMS ((struct symbol *[], int, int));
+decode_line_2 PARAMS ((struct symbol *[], int, int, char ***));
 
 static void
 rbreak_command PARAMS ((char *, int));
@@ -78,8 +81,7 @@ output_source_filename PARAMS ((char *, int *));
 static char *
 operator_chars PARAMS ((char *, char **));
 
-static int
-find_line_common PARAMS ((struct linetable *, int, int *));
+static int find_line_common PARAMS ((struct linetable *, int, int *));
 
 static struct partial_symbol *
 lookup_partial_symbol PARAMS ((struct partial_symtab *, const char *,
@@ -256,14 +258,14 @@ gdb_mangle_name (type, i, j)
   char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
   char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
   char *newname = type_name_no_tag (type);
-  int is_constructor = STREQ (field_name, newname);
-  int is_destructor = is_constructor && DESTRUCTOR_PREFIX_P (physname);
+  int is_constructor = (physname[0]=='_' && physname[1]=='_');
+  int is_destructor = DESTRUCTOR_PREFIX_P (physname);
   /* Need a new type prefix.  */
   char *const_prefix = method->is_const ? "C" : "";
   char *volatile_prefix = method->is_volatile ? "V" : "";
   char buf[20];
-#ifndef GCC_MANGLE_BUG
-  int len = strlen (newname);
+#ifdef GCC_MANGLE_BUG
+  int len = newname == NULL ? 0 : strlen (newname);
 
   if (is_destructor)
     {
@@ -301,7 +303,12 @@ gdb_mangle_name (type, i, j)
        strcpy (mangled_name, field_name);
     }
   strcat (mangled_name, buf);
-  strcat (mangled_name, newname);
+  /* If the class doesn't have a name, i.e. newname NULL, then we just
+     mangle it using 0 for the length of the class.  Thus it gets mangled
+     as something starting with `::' rather than `classname::'. */ 
+  if (newname != NULL)
+    strcat (mangled_name, newname);
+
 #else
   char *opname;
 
@@ -376,7 +383,7 @@ find_pc_psymbol (psymtab, pc)
      struct partial_symtab *psymtab;
      CORE_ADDR pc;
 {
-  struct partial_symbol *best, *p;
+  struct partial_symbol *best = NULL, *p;
   CORE_ADDR best_pc;
   
   if (!psymtab)
@@ -424,14 +431,12 @@ lookup_symbol (name, block, namespace, is_a_field_of_this, symtab)
      struct symtab **symtab;
 {
   register struct symbol *sym;
-  register struct symtab *s;
+  register struct symtab *s = NULL;
   register struct partial_symtab *ps;
   struct blockvector *bv;
   register struct objfile *objfile;
   register struct block *b;
   register struct minimal_symbol *msymbol;
-  char *temp;
-  extern char *gdb_completer_word_break_characters;
 
   /* Search specified block and its superiors.  */
 
@@ -893,7 +898,8 @@ lookup_block_symbol (block, name, namespace)
                  SYMBOL_CLASS (sym) != LOC_LOCAL_ARG &&
                  SYMBOL_CLASS (sym) != LOC_REF_ARG &&
                  SYMBOL_CLASS (sym) != LOC_REGPARM &&
-                 SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR)
+                 SYMBOL_CLASS (sym) != LOC_REGPARM_ADDR &&
+                 SYMBOL_CLASS (sym) != LOC_BASEREG_ARG)
                {
                  break;
                }
@@ -931,10 +937,15 @@ find_pc_symtab (pc)
   register struct symtab *best_s = NULL;
   register struct partial_symtab *ps;
   register struct objfile *objfile;
-  int distance = 0;;
+  int distance = 0;
 
-
-  /* Search all symtabs for one whose file contains our pc */
+  /* Search all symtabs for the one whose file contains our address, and which
+     is the smallest of all the ones containing the address.  This is designed
+     to deal with a case like symtab a is at 0x1000-0x2000 and 0x3000-0x4000
+     and symtab b is at 0x2000-0x3000.  So the GLOBAL_BLOCK for a is from
+     0x1000-0x4000, but for address 0x2345 we want to return symtab b.
+     This is said to happen for the mips; it might be swifter to create
+     several symtabs with the same name like xcoff does (I'm not sure).  */
 
   ALL_SYMTABS (objfile, s)
     {
@@ -958,7 +969,12 @@ find_pc_symtab (pc)
   if (ps)
     {
       if (ps->readin)
-       printf_filtered ("(Internal error: pc 0x%x in read in psymtab, but not in symtab.)\n", pc);
+       /* Might want to error() here (in case symtab is corrupt and
+          will cause a core dump), but maybe we can successfully
+          continue, so let's not.  */
+       warning ("\
+(Internal error: pc 0x%lx in read in psymtab, but not in symtab.)\n",
+                (unsigned long) pc);
       s = PSYMTAB_TO_SYMTAB (ps);
     }
   return (s);
@@ -977,15 +993,9 @@ find_pc_symtab (pc)
    code in the middle of a subroutine.  To properly find the end of a line's PC
    range, we must search all symtabs associated with this compilation unit, and
    find the one whose first PC is closer than that of the next line in this
-   symtab.
-
-   FIXME:  We used to complain here about zero length or negative length line
-   tables, but there are two problems with this: (1) some symtabs may not have
-   any line numbers due to gcc -g1 compilation, and (2) this function is called
-   during single stepping, when we don't own the terminal and thus can't
-   produce any output.  One solution might be to implement a mechanism whereby
-   complaints can be queued until we regain control of the terminal.  -fnf
- */
+   symtab.  */
+
+/* If it's worth the effort, we could be using a binary search.  */
 
 struct symtab_and_line
 find_pc_line (pc, notcurrent)
@@ -1049,8 +1059,12 @@ find_pc_line (pc, notcurrent)
       if (!l)
         continue;
       len = l->nitems;
-      if (len <= 0)              /* See FIXME above. */
+      if (len <= 0)
        {
+         /* I think len can be zero if the symtab lacks line numbers
+            (e.g. gcc -g1).  (Either that or the LINETABLE is NULL;
+            I'm not sure which, and maybe it depends on the symbol
+            reader).  */
          continue;
        }
 
@@ -1126,6 +1140,99 @@ find_pc_line (pc, notcurrent)
   return val;
 }
 \f
+static int find_line_symtab PARAMS ((struct symtab *, int, struct linetable **,
+                                    int *, int *));
+
+/* Find line number LINE in any symtab whose name is the same as
+   SYMTAB.
+
+   If found, return 1, set *LINETABLE to the linetable in which it was
+   found, set *INDEX to the index in the linetable of the best entry
+   found, and set *EXACT_MATCH nonzero if the value returned is an
+   exact match.
+
+   If not found, return 0.  */
+
+static int
+find_line_symtab (symtab, line, linetable, index, exact_match)
+     struct symtab *symtab;
+     int line;
+     struct linetable **linetable;
+     int *index;
+     int *exact_match;
+{
+  int exact;
+
+  /* BEST_INDEX and BEST_LINETABLE identify the smallest linenumber > LINE
+     so far seen.  */
+
+  int best_index;
+  struct linetable *best_linetable;
+
+  /* First try looking it up in the given symtab.  */
+  best_linetable = LINETABLE (symtab);
+  best_index = find_line_common (best_linetable, line, &exact);
+  if (best_index < 0 || !exact)
+    {
+      /* Didn't find an exact match.  So we better keep looking for
+        another symtab with the same name.  In the case of xcoff,
+        multiple csects for one source file (produced by IBM's FORTRAN
+        compiler) produce multiple symtabs (this is unavoidable
+        assuming csects can be at arbitrary places in memory and that
+        the GLOBAL_BLOCK of a symtab has a begin and end address).  */
+
+      /* BEST is the smallest linenumber > LINE so far seen,
+        or 0 if none has been seen so far.
+        BEST_INDEX and BEST_LINETABLE identify the item for it.  */
+      int best;
+
+      struct objfile *objfile;
+      struct symtab *s;
+
+      if (best_index >= 0)
+       best = best_linetable->item[best_index].line;
+      else
+       best = 0;
+
+      ALL_SYMTABS (objfile, s)
+       {
+         struct linetable *l;
+         int ind;
+
+         if (!STREQ (symtab->filename, s->filename))
+           continue;
+         l = LINETABLE (s);
+         ind = find_line_common (l, line, &exact);
+         if (ind >= 0)
+           {
+             if (exact)
+               {
+                 best_index = ind;
+                 best_linetable = l;
+                 goto done;
+               }
+             if (best == 0 || l->item[ind].line < best)
+               {
+                 best = l->item[ind].line;
+                 best_index = ind;
+                 best_linetable = l;
+               }
+           }
+       }
+    }
+ done:
+  if (best_index < 0)
+    return 0;
+
+  if (index)
+    *index = best_index;
+  if (linetable)
+    *linetable = best_linetable;
+  if (exact_match)
+    *exact_match = exact;
+  return 1;
+}
+\f
 /* Find the PC value for a given source file and line number.
    Returns zero for invalid line number.
    The source file is specified with a struct symtab.  */
@@ -1135,15 +1242,15 @@ find_line_pc (symtab, line)
      struct symtab *symtab;
      int line;
 {
-  register struct linetable *l;
-  register int ind;
-  int dummy;
+  struct linetable *l;
+  int ind;
 
   if (symtab == 0)
     return 0;
-  l = LINETABLE (symtab);
-  ind = find_line_common(l, line, &dummy);
-  return (ind >= 0) ? l->item[ind].pc : 0;
+  if (find_line_symtab (symtab, line, &l, &ind, NULL))
+    return l->item[ind].pc;
+  else
+    return 0;
 }
 
 /* Find the range of pc values in a line.
@@ -1158,16 +1265,14 @@ find_line_pc_range (symtab, thisline, startptr, endptr)
      int thisline;
      CORE_ADDR *startptr, *endptr;
 {
-  register struct linetable *l;
-  register int ind;
+  struct linetable *l;
+  int ind;
   int exact_match;             /* did we get an exact linenumber match */
 
   if (symtab == 0)
     return 0;
 
-  l = LINETABLE (symtab);
-  ind = find_line_common (l, thisline, &exact_match);
-  if (ind >= 0)
+  if (find_line_symtab (symtab, thisline, &l, &ind, &exact_match))
     {
       *startptr = l->item[ind].pc;
       /* If we have not seen an entry for the specified line,
@@ -1222,6 +1327,7 @@ find_line_common (l, lineno, exact_match)
 
       if (item->line == lineno)
        {
+         /* Return the first (lowest address) entry which matches.  */
          *exact_match = 1;
          return i;
        }
@@ -1355,24 +1461,9 @@ find_methods (t, name, sym_arr)
   int ibase;
   struct symbol *sym_class;
   char *class_name = type_name_no_tag (t);
-  /* Ignore this class if it doesn't have a name.
-     This prevents core dumps, but is just a workaround
-     because we might not find the function in
-     certain cases, such as
-     struct D {virtual int f();}
-     struct C : D {virtual int g();}
-     (in this case g++ 1.35.1- does not put out a name
-     for D as such, it defines type 19 (for example) in
-     the same stab as C, and then does a
-     .stabs "D:T19" and a .stabs "D:t19".
-     Thus
-     "break C::f" should not be looking for field f in
-     the class named D, 
-     but just for the field f in the baseclasses of C
-     (no matter what their names).
-     
-     However, I don't know how to replace the code below
-     that depends on knowing the name of D.  */
+  /* 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
+     the class, then the loop can't do any good.  */
   if (class_name
       && (sym_class = lookup_symbol (class_name,
                                     (struct block *)NULL,
@@ -1381,6 +1472,7 @@ find_methods (t, name, sym_arr)
                                     (struct symtab **)NULL)))
     {
       int method_counter;
+      /* FIXME: Shouldn't this just be check_stub_type (t)?  */
       t = SYMBOL_TYPE (sym_class);
       for (method_counter = TYPE_NFN_FIELDS (t) - 1;
           method_counter >= 0;
@@ -1403,6 +1495,14 @@ find_methods (t, name, sym_arr)
                /* Destructor is handled by caller, dont add it to the list */
                if (DESTRUCTOR_PREFIX_P (phys_name))
                  continue;
+
+               /* FIXME: Why are we looking this up in the
+                  SYMBOL_BLOCK_VALUE (sym_class)?  It is intended as a hook
+                  for nested types?  If so, it should probably hook to the
+                  type, not the symbol.  mipsread.c is the only symbol
+                  reader which sets the SYMBOL_BLOCK_VALUE for types, and
+                  this is not documented in symtab.h.  -26Aug93.  */
+
                sym_arr[i1] = lookup_symbol (phys_name,
                                             SYMBOL_BLOCK_VALUE (sym_class),
                                             VAR_NAMESPACE,
@@ -1419,9 +1519,18 @@ find_methods (t, name, sym_arr)
              }
        }
     }
-  /* Only search baseclasses if there is no match yet,
-   * since names in derived classes override those in baseclasses.
-   */
+
+  /* Only search baseclasses if there is no match yet, since names in
+     derived classes override those in baseclasses.
+
+     FIXME: The above is not true; it is only true of member functions
+     if they have the same number of arguments (??? - section 13.1 of the
+     ARM says the function members are not in the same scope but doesn't
+     really spell out the rules in a way I understand.  In any case, if
+     the number of arguments differ this is a case in which we can overload
+     rather than hiding without any problem, and gcc 2.4.5 does overload
+     rather than hiding in this case).  */
+
   if (i1)
     return i1;
   for (ibase = 0; ibase < TYPE_N_BASECLASSES (t); ibase++)
@@ -1430,6 +1539,46 @@ find_methods (t, name, sym_arr)
   return i1;
 }
 
+/* Helper function for decode_line_1.
+   Build a canonical line spec in CANONICAL if it is non-NULL and if
+   the SAL has a symtab.
+   If SYMNAME is non-NULL the canonical line spec is `filename:symname'.
+   If SYMNAME is NULL the line number from SAL is used and the canonical
+   line spec is `filename:linenum'.  */
+
+static void
+build_canonical_line_spec (sal, symname, canonical)
+     struct symtab_and_line *sal;
+     char *symname;
+     char ***canonical;
+{
+  char **canonical_arr;
+  char *canonical_name;
+  char *filename;
+  struct symtab *s = sal->symtab;
+
+  if (s == (struct symtab *)NULL
+      || s->filename == (char *)NULL
+      || canonical == (char ***)NULL)
+    return;
+  canonical_arr = (char **) xmalloc (sizeof (char *));
+  *canonical = canonical_arr;
+
+  filename = s->filename;
+  if (symname != NULL)
+    {
+      canonical_name = xmalloc (strlen (filename) + strlen (symname) + 2);
+      sprintf (canonical_name, "%s:%s", filename, symname);
+    }
+  else
+    {
+      canonical_name = xmalloc (strlen (filename) + 30);
+      sprintf (canonical_name, "%s:%d", filename, sal->line);
+    }
+  canonical_arr[0] = canonical_name;
+}
+
 /* Parse a string that specifies a line number.
    Pass the address of a char * variable; that variable will be
    advanced over the characters actually parsed.
@@ -1454,17 +1603,23 @@ find_methods (t, name, sym_arr)
    It defaults to current_source_symtab.
    DEFAULT_LINE specifies the line number to use for relative
    line numbers (that start with signs).  Defaults to current_source_line.
+   If CANONICAL is non-NULL, store an array of strings containing the canonical
+   line specs there if necessary. Currently overloaded member functions and
+   line numbers or static functions without a filename yield a canonical
+   line spec. The array and the line spec strings are allocated on the heap,
+   it is the callers responsibility to free them.
 
    Note that it is possible to return zero for the symtab
    if no file is validly specified.  Callers must check that.
    Also, the line number returned may be invalid.  */
 
 struct symtabs_and_lines
-decode_line_1 (argptr, funfirstline, default_symtab, default_line)
+decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
      char **argptr;
      int funfirstline;
      struct symtab *default_symtab;
      int default_line;
+     char ***canonical;
 {
   struct symtabs_and_lines values;
 #ifdef HPPA_COMPILER_BUG
@@ -1538,6 +1693,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
       values.nelts = 1;
       values.sals[0] = find_pc_line (pc, 0);
       values.sals[0].pc = pc;
+      build_canonical_line_spec (values.sals, NULL, canonical);
       return values;
     }
 
@@ -1617,7 +1773,8 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
              t = SYMBOL_TYPE (sym_class);
              sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*));
 
-             if (destructor_name_p (copy, t))
+             /* Cfront objects don't have fieldlists.  */
+             if (destructor_name_p (copy, t) && TYPE_FN_FIELDLISTS (t) != NULL)
                {
                  /* destructors are a special case.  */
                  struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0);
@@ -1664,7 +1821,7 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
                {
                  /* There is more than one field with that name
                     (overloaded).  Ask the user which one to use.  */
-                 return decode_line_2 (sym_arr, i1, funfirstline);
+                 return decode_line_2 (sym_arr, i1, funfirstline, canonical);
                }
              else
                {
@@ -1737,6 +1894,9 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
       /* We found a token consisting of all digits -- at least one digit.  */
       enum sign {none, plus, minus} sign = none;
 
+      /* We might need a canonical line spec if no file was specified.  */
+      int need_canonical = (s == 0) ? 1 : 0;
+
       /* This is where we need to make sure that we have good defaults.
         We must guarantee that this section of code is never executed
         when we are called with just a function name, since
@@ -1783,6 +1943,8 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
       values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line));
       values.sals[0] = val;
       values.nelts = 1;
+      if (need_canonical)
+       build_canonical_line_spec (values.sals, NULL, canonical);
       return values;
     }
 
@@ -1790,13 +1952,14 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
      Find the next token (everything up to end or next whitespace).  */
 
   p = skip_quoted (*argptr);
+  if (is_quoted && p[-1] != '\'')
+    error ("Unmatched single quote.");
   copy = (char *) alloca (p - *argptr + 1);
   memcpy (copy, *argptr, p - *argptr);
   copy[p - *argptr] = '\0';
   if ((copy[0] == copy [p - *argptr - 1])
       && strchr (gdb_completer_quote_characters, copy[0]) != NULL)
     {
-      char *temp;
       copy [p - *argptr - 1] = '\0';
       copy++;
     }
@@ -1847,7 +2010,15 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
             SKIP_PROLOGUE".  */
          if (SYMBOL_LINE (sym) != 0)
            values.sals[0].line = SYMBOL_LINE (sym);
-         
+
+         /* We might need a canonical line spec if it is a static function.  */
+         if (s == 0)
+           {
+             struct blockvector *bv = BLOCKVECTOR (sym_symtab);
+             struct block *b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+             if (lookup_block_symbol (b, copy, VAR_NAMESPACE) != NULL)
+               build_canonical_line_spec (values.sals, copy, canonical);
+           }
          return values;
        }
       else if (SYMBOL_LINE (sym) != 0)
@@ -1900,20 +2071,24 @@ decode_line_spec (string, funfirstline)
   if (string == 0)
     error ("Empty line specification.");
   sals = decode_line_1 (&string, funfirstline,
-                       current_source_symtab, current_source_line);
+                       current_source_symtab, current_source_line,
+                       (char ***)NULL);
   if (*string)
     error ("Junk at end of line specification: %s", string);
   return sals;
 }
 
-/* Given a list of NELTS symbols in sym_arr, return a list of lines to
-   operate on (ask user if necessary).  */
+/* Given a list of NELTS symbols in SYM_ARR, return a list of lines to
+   operate on (ask user if necessary).
+   If CANONICAL is non-NULL return a corresponding array of mangled names
+   as canonical line specs there.  */
 
 static struct symtabs_and_lines
-decode_line_2 (sym_arr, nelts, funfirstline)
+decode_line_2 (sym_arr, nelts, funfirstline, canonical)
      struct symbol *sym_arr[];
      int nelts;
      int funfirstline;
+     char ***canonical;
 {
   struct symtabs_and_lines values, return_values;
   register CORE_ADDR pc;
@@ -1921,9 +2096,20 @@ decode_line_2 (sym_arr, nelts, funfirstline)
   int i;
   char *prompt;
   char *symname;
+  struct cleanup *old_chain;
+  char **canonical_arr = (char **)NULL;
 
   values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line));
   return_values.sals = (struct symtab_and_line *) xmalloc (nelts * sizeof(struct symtab_and_line));
+  old_chain = make_cleanup (free, return_values.sals);
+
+  if (canonical)
+    {
+      canonical_arr = (char **) xmalloc (nelts * sizeof (char *));
+      make_cleanup (free, canonical_arr);
+      memset (canonical_arr, 0, nelts * sizeof (char *));
+      *canonical = canonical_arr;
+    }
 
   i = 0;
   printf("[0] cancel\n[1] all\n");
@@ -1955,7 +2141,7 @@ decode_line_2 (sym_arr, nelts, funfirstline)
 
   args = command_line_input ((char *) NULL, 0);
   
-  if (args == 0)
+  if (args == 0 || *args == 0)
     error_no_arg ("one or more choice numbers");
 
   i = 0;
@@ -1974,9 +2160,21 @@ decode_line_2 (sym_arr, nelts, funfirstline)
        error ("cancelled");
       else if (num == 1)
        {
+         if (canonical_arr)
+           {
+             for (i = 0; i < nelts; i++)
+               {
+                 if (canonical_arr[i] == NULL)
+                   {
+                     symname = SYMBOL_NAME (sym_arr[i]);
+                     canonical_arr[i] = savestring (symname, strlen (symname));
+                   }
+               }
+           }
          memcpy (return_values.sals, values.sals,
                  (nelts * sizeof(struct symtab_and_line)));
          return_values.nelts = nelts;
+         discard_cleanups (old_chain);
          return return_values;
        }
 
@@ -1989,6 +2187,12 @@ decode_line_2 (sym_arr, nelts, funfirstline)
          num -= 2;
          if (values.sals[num].pc)
            {
+             if (canonical_arr)
+               {
+                 symname = SYMBOL_NAME (sym_arr[num]);
+                 make_cleanup (free, symname);
+                 canonical_arr[i] = savestring (symname, strlen (symname));
+               }
              return_values.sals[i++] = values.sals[num];
              values.sals[num].pc = 0;
            }
@@ -2002,6 +2206,7 @@ decode_line_2 (sym_arr, nelts, funfirstline)
       while (*args == ' ' || *args == '\t') args++;
     }
   return_values.nelts = i;
+  discard_cleanups (old_chain);
   return return_values;
 }
 
@@ -2382,8 +2587,8 @@ list_symbols (regexp, class, bpt)
                              printf_filtered ("\nNon-debugging symbols:\n");
                              found_in_file = 1;
                            }
-                         printf_filtered ("    %08x  %s\n",
-                                          SYMBOL_VALUE_ADDRESS (msymbol),
+                         printf_filtered ("    %08lx  %s\n",
+                                          (unsigned long) SYMBOL_VALUE_ADDRESS (msymbol),
                                           SYMBOL_SOURCE_NAME (msymbol));
                        }
                    }
@@ -2459,11 +2664,15 @@ static char **return_val;
 
 #define COMPLETION_LIST_ADD_SYMBOL(symbol, sym_text, len, text, word) \
   do { \
-    completion_list_add_name (SYMBOL_NAME (symbol), (sym_text), (len), \
-                             (text), (word)); \
     if (SYMBOL_DEMANGLED_NAME (symbol) != NULL) \
+      /* Put only the mangled name on the list.  */ \
+      /* Advantage:  "b foo<TAB>" completes to "b foo(int, int)" */ \
+      /* Disadvantage:  "b foo__i<TAB>" doesn't complete.  */ \
       completion_list_add_name \
        (SYMBOL_DEMANGLED_NAME (symbol), (sym_text), (len), (text), (word)); \
+    else \
+      completion_list_add_name \
+       (SYMBOL_NAME (symbol), (sym_text), (len), (text), (word)); \
   } while (0)
 
 /*  Test to see if the symbol specified by SYMNAME (which is already
@@ -2564,7 +2773,7 @@ make_symbol_completion_list (text, word)
   {
     char *p;
     char quote_found;
-    char *quote_pos;
+    char *quote_pos = NULL;
 
     /* First see if this is a quoted string.  */
     quote_found = '\0';
This page took 0.031617 seconds and 4 git commands to generate.