* doc/binutils.texi: Fix typos.
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index 7e6647cd027d823f4853ee0e17a7a07ad49b2f48..68a67d523684d8a301e71f296b4e9d0baf0d936b 100644 (file)
@@ -44,6 +44,8 @@
 #include "demangle.h"
 #include "language.h"
 #include "doublest.h"
+#include "cp-abi.h"
+#include "cp-support.h"
 
 #include <ctype.h>
 
@@ -167,6 +169,8 @@ static int
 read_cfront_member_functions (struct field_info *, char **,
                              struct type *, struct objfile *);
 
+static char *find_name_end (char *name);
+
 /* end new functions added for cfront support */
 
 static void
@@ -183,10 +187,8 @@ resolve_symbol_reference (struct objfile *, struct symbol *, char *);
 
 void stabsread_clear_cache (void);
 
-static const char vptr_name[] =
-{'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
-static const char vb_name[] =
-{'_', 'v', 'b', CPLUS_MARKER, '\0'};
+static const char vptr_name[] = "_vptr$";
+static const char vb_name[] = "_vb$";
 
 /* Define this as 1 if a pcc declaration of a char or short argument
    gives the correct address.  Otherwise assume pcc gives the
@@ -200,47 +202,31 @@ static const char vb_name[] =
 #define BELIEVE_PCC_PROMOTION_TYPE 0
 #endif
 
-static struct complaint invalid_cpp_abbrev_complaint =
-{"invalid C++ abbreviation `%s'", 0, 0};
-
-static struct complaint invalid_cpp_type_complaint =
-{"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
-
-static struct complaint member_fn_complaint =
-{"member function type missing, got '%c'", 0, 0};
-
-static struct complaint const_vol_complaint =
-{"const/volatile indicator missing, got '%c'", 0, 0};
-
-static struct complaint error_type_complaint =
-{"couldn't parse type; debugger out of date?", 0, 0};
-
-static struct complaint invalid_member_complaint =
-{"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
-
-static struct complaint range_type_base_complaint =
-{"base type %d of range type is not defined", 0, 0};
-
-static struct complaint reg_value_complaint =
-{"register number %d too large (max %d) in symbol %s", 0, 0};
-
-static struct complaint vtbl_notfound_complaint =
-{"virtual function table pointer not found when defining class `%s'", 0, 0};
-
-static struct complaint unrecognized_cplus_name_complaint =
-{"Unknown C++ symbol name `%s'", 0, 0};
-
-static struct complaint rs6000_builtin_complaint =
-{"Unknown builtin type %d", 0, 0};
+static void
+invalid_cpp_abbrev_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints, "invalid C++ abbreviation `%s'", arg1);
+}
 
-static struct complaint unresolved_sym_chain_complaint =
-{"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
+static void
+reg_value_complaint (int arg1, int arg2, const char *arg3)
+{
+  complaint (&symfile_complaints,
+            "register number %d too large (max %d) in symbol %s", arg1, arg2,
+            arg3);
+}
 
-static struct complaint stabs_general_complaint =
-{"%s", 0, 0};
+static void
+stabs_general_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints, "%s", arg1);
+}
 
-static struct complaint lrs_general_complaint =
-{"%s", 0, 0};
+static void
+lrs_general_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints, "%s", arg1);
+}
 
 /* Make a list of forward references which haven't been defined.  */
 
@@ -309,11 +295,9 @@ dbx_lookup_type (int typenums[2])
 
   if (filenum < 0 || filenum >= n_this_object_header_files)
     {
-      static struct complaint msg =
-      {"\
-Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
-       0, 0};
-      complain (&msg, filenum, index, symnum);
+      complaint (&symfile_complaints,
+                "Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
+                filenum, index, symnum);
       goto error_return;
     }
 
@@ -604,6 +588,12 @@ get_cfront_method_physname (char *fname)
   return p;
 }
 
+static void
+msg_unknown_complaint (const char *arg1)
+{
+  complaint (&symfile_complaints, "Unsupported token in stabs string %s", arg1);
+}
+
 /* Read base classes within cfront class definition.
    eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
    ^^^^^^^^^^^^^^^^^^
@@ -616,14 +606,6 @@ static int
 read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
                         struct objfile *objfile)
 {
-  static struct complaint msg_unknown =
-  {"\
-        Unsupported token in stabs string %s.\n",
-   0, 0};
-  static struct complaint msg_notfound =
-  {"\
-                  Unable to find base type for %s.\n",
-   0, 0};
   int bnum = 0;
   char *p;
   int i;
@@ -690,10 +672,9 @@ read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
          /* Bad visibility format.  Complain and treat it as
             public.  */
          {
-           static struct complaint msg =
-           {
-             "Unknown visibility `%c' for baseclass", 0, 0};
-           complain (&msg, new->visibility);
+           complaint (&symfile_complaints,
+                      "Unknown visibility `%c' for baseclass",
+                      new->visibility);
            new->visibility = VISIBILITY_PUBLIC;
          }
        }
@@ -701,7 +682,7 @@ read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
       /* "@" comes next - eg: @Bvir */
       if (**pp != '@')
        {
-         complain (&msg_unknown, *pp);
+         msg_unknown_complaint (*pp);
          return 1;
        }
       ++(*pp);
@@ -729,7 +710,7 @@ read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
          bname = get_substring (pp, ';');
        if (!bname || !*bname)
          {
-           complain (&msg_unknown, *pp);
+           msg_unknown_complaint (*pp);
            return 1;
          }
        /* FIXME! attach base info to type */
@@ -741,7 +722,8 @@ read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
          }
        else
          {
-           complain (&msg_notfound, *pp);
+           complaint (&symfile_complaints, "Unable to find base type for %s",
+                      *pp);
            return 1;
          }
       }
@@ -808,11 +790,8 @@ read_cfront_member_functions (struct field_info *fip, char **pp,
       ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0);                /* demangled name */
       if (!ref_func)
        {
-         static struct complaint msg =
-         {"\
-               Unable to find function symbol for %s\n",
-          0, 0};
-         complain (&msg, fname);
+         complaint (&symfile_complaints,
+                    "Unable to find function symbol for %s", fname);
          continue;
        }
       sublist = NULL;
@@ -1068,7 +1047,7 @@ resolve_symbol_reference (struct objfile *objfile, struct symbol *sym, char *p)
   ref_sym = ref_search (refnum);
   if (!ref_sym)
     {
-      complain (&lrs_general_complaint, "symbol for reference not found");
+      lrs_general_complaint ("symbol for reference not found");
       return 0;
     }
 
@@ -1104,7 +1083,7 @@ resolve_symbol_reference (struct objfile *objfile, struct symbol *sym, char *p)
                                               sizeof (struct alias_list));
   if (!alias)
     {
-      complain (&lrs_general_complaint, "Unable to allocate alias list memory");
+      lrs_general_complaint ("Unable to allocate alias list memory");
       return 0;
     }
 
@@ -1271,7 +1250,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
               struct objfile *objfile)
 {
   register struct symbol *sym;
-  char *p = (char *) strchr (string, ':');
+  char *p = (char *) find_name_end (string);
   int deftype;
   int synonym = 0;
   register int i;
@@ -1359,7 +1338,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
 #endif
 
        default:
-         complain (&unrecognized_cplus_name_complaint, string);
+         complaint (&symfile_complaints, "Unknown C++ symbol name `%s'",
+                    string);
          goto normal;          /* Do *something* with it */
        }
     }
@@ -1811,9 +1791,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
        {
-         complain (&reg_value_complaint, SYMBOL_VALUE (sym),
-                   NUM_REGS + NUM_PSEUDO_REGS,
-                   SYMBOL_SOURCE_NAME (sym));
+         reg_value_complaint (SYMBOL_VALUE (sym),
+                              NUM_REGS + NUM_PSEUDO_REGS,
+                              SYMBOL_SOURCE_NAME (sym));
          SYMBOL_VALUE (sym) = SP_REGNUM;       /* Known safe, though useless */
        }
       SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
@@ -1827,9 +1807,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
        {
-         complain (&reg_value_complaint, SYMBOL_VALUE (sym),
-                   NUM_REGS + NUM_PSEUDO_REGS,
-                   SYMBOL_SOURCE_NAME (sym));
+         reg_value_complaint (SYMBOL_VALUE (sym),
+                              NUM_REGS + NUM_PSEUDO_REGS,
+                              SYMBOL_SOURCE_NAME (sym));
          SYMBOL_VALUE (sym) = SP_REGNUM;       /* Known safe, though useless */
        }
       SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
@@ -2004,7 +1984,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
          a typedef for "foo".  Unfortunately, cfront never makes the typedef
          when translating C++ into C.  We make the typedef here so that
          "ptype foo" works as expected for cfront translated code.  */
-      else if (current_subfile->language == language_cplus)
+      else if ((current_subfile->language == language_cplus)
+              || (current_subfile->language == language_objc))
        synonym = 1;
 
       SYMBOL_TYPE (sym) = read_type (&p, objfile);
@@ -2080,9 +2061,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
       SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
       if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
        {
-         complain (&reg_value_complaint, SYMBOL_VALUE (sym),
-                   NUM_REGS + NUM_PSEUDO_REGS,
-                   SYMBOL_SOURCE_NAME (sym));
+         reg_value_complaint (SYMBOL_VALUE (sym),
+                              NUM_REGS + NUM_PSEUDO_REGS,
+                              SYMBOL_SOURCE_NAME (sym));
          SYMBOL_VALUE (sym) = SP_REGNUM;       /* Known safe, though useless */
        }
       SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
@@ -2177,7 +2158,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
          p = strchr (p, ')');
          if (!*p || *p != ')')
            {
-             complain (&lrs_general_complaint, "live range format not recognized");
+             lrs_general_complaint ("live range format not recognized");
              return NULL;
            }
          p++;
@@ -2198,14 +2179,14 @@ resolve_live_range (struct objfile *objfile, struct symbol *sym, char *p)
   /* Sanity check the beginning of the stabs string.  */
   if (!*p || *p != 'l')
     {
-      complain (&lrs_general_complaint, "live range string 1");
+      lrs_general_complaint ("live range string 1");
       return 0;
     }
   p++;
 
   if (!*p || *p != '(')
     {
-      complain (&lrs_general_complaint, "live range string 2");
+      lrs_general_complaint ("live range string 2");
       return 0;
     }
   p++;
@@ -2218,13 +2199,13 @@ resolve_live_range (struct objfile *objfile, struct symbol *sym, char *p)
   start = ref_search_value (refnum);
   if (!start)
     {
-      complain (&lrs_general_complaint, "Live range symbol not found 1");
+      lrs_general_complaint ("Live range symbol not found 1");
       return 0;
     }
 
   if (!*p || *p != ',')
     {
-      complain (&lrs_general_complaint, "live range string 3");
+      lrs_general_complaint ("live range string 3");
       return 0;
     }
   p++;
@@ -2237,13 +2218,13 @@ resolve_live_range (struct objfile *objfile, struct symbol *sym, char *p)
   end = ref_search_value (refnum);
   if (!end)
     {
-      complain (&lrs_general_complaint, "Live range symbol not found 2");
+      lrs_general_complaint ("Live range symbol not found 2");
       return 0;
     }
 
   if (!*p || *p != ')')
     {
-      complain (&lrs_general_complaint, "live range string 4");
+      lrs_general_complaint ("live range string 4");
       return 0;
     }
 
@@ -2265,7 +2246,7 @@ add_live_range (struct objfile *objfile, struct symbol *sym, CORE_ADDR start,
 
   if (start >= end)
     {
-      complain (&lrs_general_complaint, "end of live range follows start");
+      lrs_general_complaint ("end of live range follows start");
       return;
     }
 
@@ -2322,7 +2303,7 @@ add_live_range (struct objfile *objfile, struct symbol *sym, CORE_ADDR start,
 static struct type *
 error_type (char **pp, struct objfile *objfile)
 {
-  complain (&error_type_complaint);
+  complaint (&symfile_complaints, "couldn't parse type; debugger out of date?");
   while (1)
     {
       /* Skip to end of symbol.  */
@@ -2432,9 +2413,8 @@ again:
              {
                /* Complain and keep going, so compilers can invent new
                   cross-reference types.  */
-               static struct complaint msg =
-               {"Unrecognized cross-reference type `%c'", 0, 0};
-               complain (&msg, (*pp)[0]);
+               complaint (&symfile_complaints,
+                          "Unrecognized cross-reference type `%c'", (*pp)[0]);
                code = TYPE_CODE_STRUCT;
                break;
              }
@@ -2657,11 +2637,9 @@ again:
           ++*pp;
         else
           {
-            static struct complaint msg = {
-              "Prototyped function type didn't end arguments with `#':\n%s",
-              0, 0
-            };
-            complain (&msg, type_start);
+           complaint (&symfile_complaints,
+                      "Prototyped function type didn't end arguments with `#':\n%s",
+                      type_start);
           }
 
         /* If there is just one argument whose type is `void', then
@@ -2794,7 +2772,9 @@ again:
          (*pp)++;
          return_type = read_type (pp, objfile);
          if (*(*pp)++ != ';')
-           complain (&invalid_member_complaint, symnum);
+           complaint (&symfile_complaints,
+                      "invalid (minimal) member type data format at symtab pos %d.",
+                      symnum);
          type = allocate_stub_method (return_type);
          if (typenums[0] != -1)
            *dbx_lookup_type (typenums) = type;
@@ -2927,7 +2907,7 @@ rs6000_builtin_type (int typenum)
 
   if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
     {
-      complain (&rs6000_builtin_complaint, typenum);
+      complaint (&symfile_complaints, "Unknown builtin type %d", typenum);
       return builtin_type_error;
     }
   if (negative_types[-typenum] != NULL)
@@ -3080,6 +3060,27 @@ rs6000_builtin_type (int typenum)
 \f
 /* This page contains subroutines of read_type.  */
 
+/* Replace *OLD_NAME with the method name portion of PHYSNAME.  */
+
+static void
+update_method_name_from_physname (char **old_name, char *physname)
+{
+  char *method_name;
+
+  method_name = method_name_from_physname (physname);
+
+  if (method_name == NULL)
+    error ("bad physname %s\n", physname);
+
+  if (strcmp (*old_name, method_name) != 0)
+    {
+      xfree (*old_name);
+      *old_name = method_name;
+    }
+  else
+    xfree (method_name);
+}
+
 /* Read member function stabs info for C++ classes.  The form of each member
    function data is:
 
@@ -3156,8 +3157,7 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
          /* This lets the user type "break operator+".
             We could just put in "+" as the name, but that wouldn't
             work for "*".  */
-         static char opname[32] =
-         {'o', 'p', CPLUS_MARKER};
+         static char opname[32] = "op$";
          char *o = opname + 3;
 
          /* Skip past '::'.  */
@@ -3265,7 +3265,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
            case '.':
              break;
            default:
-             complain (&const_vol_complaint, **pp);
+             complaint (&symfile_complaints,
+                        "const/volatile indicator missing, got '%c'", **pp);
              break;
            }
 
@@ -3347,7 +3348,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
 
            default:
              /* error */
-             complain (&member_fn_complaint, (*pp)[-1]);
+             complaint (&symfile_complaints,
+                        "member function type missing, got '%c'", (*pp)[-1]);
              /* Fall through into normal member function.  */
 
            case '.':
@@ -3377,6 +3379,164 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
        }
       else
        {
+         int has_stub = 0;
+         int has_destructor = 0, has_other = 0;
+         int is_v3 = 0;
+         struct next_fnfield *tmp_sublist;
+
+         /* Various versions of GCC emit various mostly-useless
+            strings in the name field for special member functions.
+
+            For stub methods, we need to defer correcting the name
+            until we are ready to unstub the method, because the current
+            name string is used by gdb_mangle_name.  The only stub methods
+            of concern here are GNU v2 operators; other methods have their
+            names correct (see caveat below).
+
+            For non-stub methods, in GNU v3, we have a complete physname.
+            Therefore we can safely correct the name now.  This primarily
+            affects constructors and destructors, whose name will be
+            __comp_ctor or __comp_dtor instead of Foo or ~Foo.  Cast
+            operators will also have incorrect names; for instance,
+            "operator int" will be named "operator i" (i.e. the type is
+            mangled).
+
+            For non-stub methods in GNU v2, we have no easy way to
+            know if we have a complete physname or not.  For most
+            methods the result depends on the platform (if CPLUS_MARKER
+            can be `$' or `.', it will use minimal debug information, or
+            otherwise the full physname will be included).
+
+            Rather than dealing with this, we take a different approach.
+            For v3 mangled names, we can use the full physname; for v2,
+            we use cplus_demangle_opname (which is actually v2 specific),
+            because the only interesting names are all operators - once again
+            barring the caveat below.  Skip this process if any method in the
+            group is a stub, to prevent our fouling up the workings of
+            gdb_mangle_name.
+
+            The caveat: GCC 2.95.x (and earlier?) put constructors and
+            destructors in the same method group.  We need to split this
+            into two groups, because they should have different names.
+            So for each method group we check whether it contains both
+            routines whose physname appears to be a destructor (the physnames
+            for and destructors are always provided, due to quirks in v2
+            mangling) and routines whose physname does not appear to be a
+            destructor.  If so then we break up the list into two halves.
+            Even if the constructors and destructors aren't in the same group
+            the destructor will still lack the leading tilde, so that also
+            needs to be fixed.
+
+            So, to summarize what we expect and handle here:
+
+               Given         Given          Real         Real       Action
+            method name     physname      physname   method name
+
+            __opi            [none]     __opi__3Foo  operator int    opname
+                                                                  [now or later]
+            Foo              _._3Foo       _._3Foo      ~Foo       separate and
+                                                                      rename
+            operator i     _ZN3FoocviEv _ZN3FoocviEv operator int    demangle
+            __comp_ctor  _ZN3FooC1ERKS_ _ZN3FooC1ERKS_   Foo         demangle
+         */
+
+         tmp_sublist = sublist;
+         while (tmp_sublist != NULL)
+           {
+             if (tmp_sublist->fn_field.is_stub)
+               has_stub = 1;
+             if (tmp_sublist->fn_field.physname[0] == '_'
+                 && tmp_sublist->fn_field.physname[1] == 'Z')
+               is_v3 = 1;
+
+             if (is_destructor_name (tmp_sublist->fn_field.physname))
+               has_destructor++;
+             else
+               has_other++;
+
+             tmp_sublist = tmp_sublist->next;
+           }
+
+         if (has_destructor && has_other)
+           {
+             struct next_fnfieldlist *destr_fnlist;
+             struct next_fnfield *last_sublist;
+
+             /* Create a new fn_fieldlist for the destructors.  */
+
+             destr_fnlist = (struct next_fnfieldlist *)
+               xmalloc (sizeof (struct next_fnfieldlist));
+             make_cleanup (xfree, destr_fnlist);
+             memset (destr_fnlist, 0, sizeof (struct next_fnfieldlist));
+             destr_fnlist->fn_fieldlist.name
+               = obconcat (&objfile->type_obstack, "", "~",
+                           new_fnlist->fn_fieldlist.name);
+
+             destr_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
+               obstack_alloc (&objfile->type_obstack,
+                              sizeof (struct fn_field) * has_destructor);
+             memset (destr_fnlist->fn_fieldlist.fn_fields, 0,
+                 sizeof (struct fn_field) * has_destructor);
+             tmp_sublist = sublist;
+             last_sublist = NULL;
+             i = 0;
+             while (tmp_sublist != NULL)
+               {
+                 if (!is_destructor_name (tmp_sublist->fn_field.physname))
+                   {
+                     tmp_sublist = tmp_sublist->next;
+                     continue;
+                   }
+                 
+                 destr_fnlist->fn_fieldlist.fn_fields[i++]
+                   = tmp_sublist->fn_field;
+                 if (last_sublist)
+                   last_sublist->next = tmp_sublist->next;
+                 else
+                   sublist = tmp_sublist->next;
+                 last_sublist = tmp_sublist;
+                 tmp_sublist = tmp_sublist->next;
+               }
+
+             destr_fnlist->fn_fieldlist.length = has_destructor;
+             destr_fnlist->next = fip->fnlist;
+             fip->fnlist = destr_fnlist;
+             nfn_fields++;
+             total_length += has_destructor;
+             length -= has_destructor;
+           }
+         else if (is_v3)
+           {
+             /* v3 mangling prevents the use of abbreviated physnames,
+                so we can do this here.  There are stubbed methods in v3
+                only:
+                - in -gstabs instead of -gstabs+
+                - or for static methods, which are output as a function type
+                  instead of a method type.  */
+
+             update_method_name_from_physname (&new_fnlist->fn_fieldlist.name,
+                                               sublist->fn_field.physname);
+           }
+         else if (has_destructor && new_fnlist->fn_fieldlist.name[0] != '~')
+           {
+             new_fnlist->fn_fieldlist.name = concat ("~", main_fn_name, NULL);
+             xfree (main_fn_name);
+           }
+         else if (!has_stub)
+           {
+             char dem_opname[256];
+             int ret;
+             ret = cplus_demangle_opname (new_fnlist->fn_fieldlist.name,
+                                             dem_opname, DMGL_ANSI);
+             if (!ret)
+               ret = cplus_demangle_opname (new_fnlist->fn_fieldlist.name,
+                                            dem_opname, 0);
+             if (ret)
+               new_fnlist->fn_fieldlist.name
+                 = obsavestring (dem_opname, strlen (dem_opname),
+                                 &objfile->type_obstack);
+           }
+
          new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
            obstack_alloc (&objfile->type_obstack,
                           sizeof (struct fn_field) * length);
@@ -3454,7 +3614,9 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
          name = type_name_no_tag (context);
          if (name == NULL)
            {
-             complain (&invalid_cpp_type_complaint, symnum);
+             complaint (&symfile_complaints,
+                        "C++ abbreviated type name unknown at symtab pos %d",
+                        symnum);
              name = "FOO";
            }
          fip->list->field.name =
@@ -3462,7 +3624,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
          break;
 
        default:
-         complain (&invalid_cpp_abbrev_complaint, *pp);
+         invalid_cpp_abbrev_complaint (*pp);
          fip->list->field.name =
            obconcat (&objfile->type_obstack,
                      "INVALID_CPLUSPLUS_ABBREV", "", "");
@@ -3475,7 +3637,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
       p = ++(*pp);
       if (p[-1] != ':')
        {
-         complain (&invalid_cpp_abbrev_complaint, *pp);
+         invalid_cpp_abbrev_complaint (*pp);
          return 0;
        }
       fip->list->field.type = read_type (pp, objfile);
@@ -3496,7 +3658,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
     }
   else
     {
-      complain (&invalid_cpp_abbrev_complaint, *pp);
+      invalid_cpp_abbrev_complaint (*pp);
       /* We have no idea what syntax an unrecognized abbrev would have, so
          better return 0.  If we returned 1, we would need to at least advance
          *pp to avoid an infinite loop.  */
@@ -3580,7 +3742,7 @@ read_one_struct_field (struct field_info *fip, char **pp, char *p,
   else if (**pp != ',')
     {
       /* Bad structure-type format.  */
-      complain (&stabs_general_complaint, "bad structure-type format");
+      stabs_general_complaint ("bad structure-type format");
       return;
     }
 
@@ -3591,13 +3753,13 @@ read_one_struct_field (struct field_info *fip, char **pp, char *p,
     FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
     if (nbits != 0)
       {
-       complain (&stabs_general_complaint, "bad structure-type format");
+       stabs_general_complaint ("bad structure-type format");
        return;
       }
     FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
     if (nbits != 0)
       {
-       complain (&stabs_general_complaint, "bad structure-type format");
+       stabs_general_complaint ("bad structure-type format");
        return;
       }
   }
@@ -3739,8 +3901,9 @@ read_struct_fields (struct field_info *fip, char **pp, struct type *type,
     }
   if (p[0] == ':' && p[1] == ':')
     {
-      /* chill the list of fields: the last entry (at the head) is a
-         partially constructed entry which we now scrub. */
+      /* (OBSOLETE) chill (OBSOLETE) the list of fields: the last
+         entry (at the head) is a partially constructed entry which we
+         now scrub. */
       fip->list = fip->list->next;
     }
   return 1;
@@ -3836,10 +3999,8 @@ read_baseclasses (struct field_info *fip, char **pp, struct type *type,
        default:
          /* Unknown character.  Complain and treat it as non-virtual.  */
          {
-           static struct complaint msg =
-           {
-             "Unknown virtual character `%c' for baseclass", 0, 0};
-           complain (&msg, **pp);
+           complaint (&symfile_complaints,
+                      "Unknown virtual character `%c' for baseclass", **pp);
          }
        }
       ++(*pp);
@@ -3855,11 +4016,9 @@ read_baseclasses (struct field_info *fip, char **pp, struct type *type,
          /* Bad visibility format.  Complain and treat it as
             public.  */
          {
-           static struct complaint msg =
-           {
-             "Unknown visibility `%c' for baseclass", 0, 0
-           };
-           complain (&msg, new->visibility);
+           complaint (&symfile_complaints,
+                      "Unknown visibility `%c' for baseclass",
+                      new->visibility);
            new->visibility = VISIBILITY_PUBLIC;
          }
        }
@@ -3956,15 +4115,18 @@ read_tilde_fields (struct field_info *fip, char **pp, struct type *type,
                   i >= TYPE_N_BASECLASSES (t);
                   --i)
                {
-                 if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
-                               sizeof (vptr_name) - 1))
+                 char *name = TYPE_FIELD_NAME (t, i);
+                 if (!strncmp (name, vptr_name, sizeof (vptr_name) - 2)
+                     && is_cplus_marker (name[sizeof (vptr_name) - 2]))
                    {
                      TYPE_VPTR_FIELDNO (type) = i;
                      goto gotit;
                    }
                }
              /* Virtual function table field not found.  */
-             complain (&vtbl_notfound_complaint, TYPE_NAME (type));
+             complaint (&symfile_complaints,
+                        "virtual function table pointer not found when defining class `%s'",
+                        TYPE_NAME (type));
              return 0;
            }
          else
@@ -4027,11 +4189,8 @@ read_cfront_static_fields (struct field_info *fip, char **pp, struct type *type,
       ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0);      /*demangled_name */
       if (!ref_static)
        {
-         static struct complaint msg =
-         {"\
-               Unable to find symbol for static data field %s\n",
-          0, 0};
-         complain (&msg, sname);
+         complaint (&symfile_complaints,
+                    "Unable to find symbol for static data field %s", sname);
          continue;
        }
       stype = SYMBOL_TYPE (ref_static);
@@ -4206,10 +4365,8 @@ attach_fields_to_type (struct field_info *fip, register struct type *type,
        default:
          /* Unknown visibility.  Complain and treat it as public.  */
          {
-           static struct complaint msg =
-           {
-             "Unknown visibility `%c' for field", 0, 0};
-           complain (&msg, fip->list->visibility);
+           complaint (&symfile_complaints, "Unknown visibility `%c' for field",
+                      fip->list->visibility);
          }
          break;
        }
@@ -4219,10 +4376,6 @@ attach_fields_to_type (struct field_info *fip, register struct type *type,
 }
 
 
-static struct complaint multiply_defined_struct =
-{"struct/union type gets multiply defined: %s%s", 0, 0};
-
-
 /* Complain that the compiler has emitted more than one definition for the
    structure type TYPE.  */
 static void 
@@ -4253,7 +4406,8 @@ complain_about_struct_wipeout (struct type *type)
       kind = "";
     }
 
-  complain (&multiply_defined_struct, kind, name);
+  complaint (&symfile_complaints,
+            "struct/union type gets multiply defined: %s%s", kind, name);
 }
 
 
@@ -4889,9 +5043,11 @@ read_range_type (char **pp, int typenums[2], struct objfile *objfile)
   else if (self_subrange && n2 == 0 && n3 == 127)
     return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
 
-  else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
-          && !self_subrange)
-    goto handle_true_range;
+#if 0
+  /* OBSOLETE else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill */
+  /* OBSOLETE          && !self_subrange) */
+  /* OBSOLETE   goto handle_true_range; */
+#endif
 
   /* We used to do this only for subrange of self or subrange of int.  */
   else if (n2 == 0)
@@ -4953,7 +5109,8 @@ handle_true_range:
 
       static struct type *range_type_index;
 
-      complain (&range_type_base_complaint, rangenums[1]);
+      complaint (&symfile_complaints,
+                "base type %d of range type is not defined", rangenums[1]);
       if (range_type_index == NULL)
        range_type_index =
          init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
@@ -5029,11 +5186,8 @@ common_block_start (char *name, struct objfile *objfile)
 {
   if (common_block_name != NULL)
     {
-      static struct complaint msg =
-      {
-       "Invalid symbol data: common block within common block",
-       0, 0};
-      complain (&msg);
+      complaint (&symfile_complaints,
+                "Invalid symbol data: common block within common block");
     }
   common_block = local_symbols;
   common_block_i = local_symbols ? local_symbols->nsyms : 0;
@@ -5059,9 +5213,7 @@ common_block_end (struct objfile *objfile)
 
   if (common_block_name == NULL)
     {
-      static struct complaint msg =
-      {"ECOMM symbol unmatched by BCOMM", 0, 0};
-      complain (&msg);
+      complaint (&symfile_complaints, "ECOMM symbol unmatched by BCOMM");
       return;
     }
 
@@ -5174,9 +5326,7 @@ cleanup_undefined_types (void)
 
                if (typename == NULL)
                  {
-                   static struct complaint msg =
-                   {"need a type name", 0, 0};
-                   complain (&msg);
+                   complaint (&symfile_complaints, "need a type name");
                    break;
                  }
                for (ppt = file_symbols; ppt; ppt = ppt->next)
@@ -5199,10 +5349,9 @@ cleanup_undefined_types (void)
 
        default:
          {
-           static struct complaint msg =
-           {"\
-GDB internal error.  cleanup_undefined_types with bad type %d.", 0, 0};
-           complain (&msg, TYPE_CODE (*type));
+           complaint (&symfile_complaints,
+                      "GDB internal error.  cleanup_undefined_types with bad type %d.",
+                      TYPE_CODE (*type));
          }
          break;
        }
@@ -5362,8 +5511,9 @@ scan_file_globals (struct objfile *objfile)
          if (SYMBOL_CLASS (prev) == LOC_STATIC)
            SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
          else
-           complain (&unresolved_sym_chain_complaint,
-                     objfile->name, SYMBOL_NAME (prev));
+           complaint (&symfile_complaints,
+                      "%s: common block `%s' from global_sym_chain unresolved",
+                      objfile->name, SYMBOL_NAME (prev));
        }
     }
   memset (global_sym_chain, 0, sizeof (global_sym_chain));
@@ -5434,6 +5584,32 @@ finish_global_stabs (struct objfile *objfile)
     }
 }
 
+/* Find the end of the name, delimited by a ':', but don't match
+   ObjC symbols which look like -[Foo bar::]:bla.  */
+static char *
+find_name_end (char *name)
+{
+  char *s = name;
+  if (s[0] == '-' || *s == '+')
+    {
+      /* Must be an ObjC method symbol.  */
+      if (s[1] != '[')
+       {
+         error ("invalid symbol name \"%s\"", name);
+       }
+      s = strchr (s, ']');
+      if (s == NULL)
+       {
+         error ("invalid symbol name \"%s\"", name);
+       }
+      return strchr (s, ':');
+    }
+  else
+    {
+      return strchr (s, ':');
+    }
+}
+
 /* Initializer for this module */
 
 void
This page took 0.036203 seconds and 4 git commands to generate.