* demangle.c (is_cplus_marker): New function, checks if a
authorFred Fish <fnf@specifix.com>
Fri, 16 Feb 1996 06:14:15 +0000 (06:14 +0000)
committerFred Fish <fnf@specifix.com>
Fri, 16 Feb 1996 06:14:15 +0000 (06:14 +0000)
character is one of the commonly used C++ marker characters.
* defs.h (is_cplus_marker):  Add prototype.
* c-typeprint.c (c_type_print_base), ch-lang.c (chill_demangle),
cp-valprint.c (cp_print_class_method), mdebugread.c (parse_symbol),
stabsread.c (define_symbol, read_member_functions, read_struct_fields),
symtab.h (OPNAME_PREFIX_P, VTBL_PREFIX_P, DESTRUCTOR_PREFIX_P),
values.c (vb_match):  Use is_cplus_marker instead of comparison
with CPLUS_MARKER.

gdb/ChangeLog
gdb/c-typeprint.c
gdb/ch-lang.c
gdb/cp-valprint.c
gdb/defs.h
gdb/demangle.c
gdb/mdebugread.c
gdb/stabsread.c
gdb/symtab.h
gdb/values.c

index 9433d4de096a1c0f0b9977be2c2ded66075b5c7f..37fd73a093ca81723aff8a072c7799f455e2f6cf 100644 (file)
@@ -1,3 +1,15 @@
+Thu Feb 15 21:40:52 1996  Peter Schauer  (pes@regent.e-technik.tu-muenchen.de)
+
+       * demangle.c (is_cplus_marker):  New function, checks if a
+       character is one of the commonly used C++ marker characters.
+       * defs.h (is_cplus_marker):  Add prototype.
+       * c-typeprint.c (c_type_print_base), ch-lang.c (chill_demangle),
+       cp-valprint.c (cp_print_class_method), mdebugread.c (parse_symbol),
+       stabsread.c (define_symbol, read_member_functions, read_struct_fields),
+       symtab.h (OPNAME_PREFIX_P, VTBL_PREFIX_P, DESTRUCTOR_PREFIX_P),
+       values.c (vb_match):  Use is_cplus_marker instead of comparison
+       with CPLUS_MARKER.
+
 Thu Feb 15 18:08:13 1996  Fred Fish  <fnf@cygnus.com>
 
        * symfile.h (INLINE_ADD_PSYMBOL): Default this to 0 and possibly
index 9be2d52c8ad3e50de0dfedab1fed5bce89d5510b..a7a5341c177264d7e8e6d9c20d483b9504cbe51f 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for printing C and C++ types for GDB, the GNU debugger.
-   Copyright 1986, 1988, 1989, 1991, 1993, 1994
+   Copyright 1986, 1988, 1989, 1991, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -582,8 +582,8 @@ c_type_print_base (type, stream, show, level)
            {
              QUIT;
              /* Don't print out virtual function table.  */
-             if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER &&
-                 !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5))
+             if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
+                 && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
                continue;
 
              /* If this is a C++ class we can print the various C++ section
@@ -737,7 +737,7 @@ c_type_print_base (type, stream, show, level)
                      free (mangled_name);
                    }
                  else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
-                       && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
+                         && is_cplus_marker (TYPE_FN_FIELD_PHYSNAME (f, j)[1]))
                    cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j) + 1,
                                               "~", method_name, 0, stream);
                  else
index 9988a3c07a207c50026bf4a0d6791303d584872d..904dc6b71f43eea425ce25794f2167cd972a4134 100644 (file)
@@ -1,5 +1,5 @@
 /* Chill language support routines for GDB, the GNU debugger.
-   Copyright 1992 Free Software Foundation, Inc.
+   Copyright 1992, 1995, 1996 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -35,11 +35,20 @@ char *
 chill_demangle (mangled)
      const char *mangled;
 {
-  char *joiner;
+  const char *joiner = NULL;
   char *demangled;
+  const char *cp = mangled;
 
-  joiner = strchr (mangled, CPLUS_MARKER);
-  if (joiner != NULL && *(joiner + 1) == CPLUS_MARKER)
+  while (*cp)
+    {
+      if (is_cplus_marker (*cp))
+       {
+         joiner = cp;
+         break;
+       }
+      cp++;
+    }
+  if (joiner != NULL && *(joiner + 1) == *joiner)
     {
       demangled = savestring (mangled, joiner - mangled);
     }
index f68b7530138216b6434af166c30a5a84138a385c..7046007ea2640c022bedd4a21eabb9d45293eba2 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
-   Copyright 1986, 1988, 1989, 1991, 1994, 1995
+   Copyright 1986, 1988, 1989, 1991, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -124,7 +124,7 @@ cp_print_class_method (valaddr, type, stream)
       c_type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0);
       fprintf_unfiltered (stream, kind);
       if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
-         && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER)
+         && is_cplus_marker (TYPE_FN_FIELD_PHYSNAME (f, j)[1]))
        {
          cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
                                     TYPE_FN_FIELDLIST_NAME (domain, i),
index af94db80b67b9e379109143f21f09fe07649d007..47de9f23ef2035851454465a6389fbe9d4ff7ce1 100644 (file)
@@ -1,5 +1,5 @@
 /* Basic, host-specific, and target-specific definitions for GDB.
-   Copyright (C) 1986, 1989, 1991, 1992, 1993, 1994, 1995
+   Copyright (C) 1986, 1989, 1991, 1992, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -22,6 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #define DEFS_H
 
 #include <stdio.h>
+#include <errno.h>             /* System call error return status */
+
+/* Just in case they're not defined in stdio.h. */
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
 
 /* First include ansidecl.h so we can use the various macro definitions
    here and in all subsequent file inclusions.  */
@@ -70,7 +80,8 @@ typedef bfd_vma CORE_ADDR;
    the program's identifiers (such as $this and $$vptr).  */
 #define CPLUS_MARKER '$'       /* May be overridden to '.' for SysV */
 
-#include <errno.h>             /* System call error return status */
+/* Check if a character is one of the commonly used C++ marker characters.  */
+extern int is_cplus_marker PARAMS ((int));
 
 extern int quit_flag;
 extern int immediate_quit;
@@ -263,38 +274,38 @@ extern int fputc_unfiltered PARAMS ((int c, GDB_FILE *));
 
 extern int putchar_unfiltered PARAMS ((int c));
 
-extern void puts_filtered PARAMS ((char *));
+extern void puts_filtered PARAMS ((const char *));
 
-extern void puts_unfiltered PARAMS ((char *));
+extern void puts_unfiltered PARAMS ((const char *));
 
-extern void vprintf_filtered PARAMS ((char *, va_list))
+extern void vprintf_filtered PARAMS ((const char *, va_list))
      ATTR_FORMAT(printf, 1, 0);
 
-extern void vfprintf_filtered PARAMS ((FILE *, char *, va_list))
+extern void vfprintf_filtered PARAMS ((FILE *, const char *, va_list))
      ATTR_FORMAT(printf, 2, 0);
 
-extern void fprintf_filtered PARAMS ((FILE *, char *, ...))
+extern void fprintf_filtered PARAMS ((FILE *, const char *, ...))
      ATTR_FORMAT(printf, 2, 3);
 
-extern void fprintfi_filtered PARAMS ((int, FILE *, char *, ...))
+extern void fprintfi_filtered PARAMS ((int, FILE *, const char *, ...))
      ATTR_FORMAT(printf, 3, 4);
 
-extern void printf_filtered PARAMS ((char *, ...))
+extern void printf_filtered PARAMS ((const char *, ...))
      ATTR_FORMAT(printf, 1, 2);
 
-extern void printfi_filtered PARAMS ((int, char *, ...))
+extern void printfi_filtered PARAMS ((int, const char *, ...))
      ATTR_FORMAT(printf, 2, 3);
 
-extern void vprintf_unfiltered PARAMS ((char *, va_list))
+extern void vprintf_unfiltered PARAMS ((const char *, va_list))
      ATTR_FORMAT(printf, 1, 0);
 
-extern void vfprintf_unfiltered PARAMS ((FILE *, char *, va_list))
+extern void vfprintf_unfiltered PARAMS ((FILE *, const char *, va_list))
      ATTR_FORMAT(printf, 2, 0);
 
-extern void fprintf_unfiltered PARAMS ((FILE *, char *, ...))
+extern void fprintf_unfiltered PARAMS ((FILE *, const char *, ...))
      ATTR_FORMAT(printf, 2, 3);
 
-extern void printf_unfiltered PARAMS ((char *, ...))
+extern void printf_unfiltered PARAMS ((const char *, ...))
      ATTR_FORMAT(printf, 1, 2);
 
 extern void print_spaces PARAMS ((int, GDB_FILE *));
@@ -648,7 +659,7 @@ extern void free ();
 
 #endif /* MALLOC_INCOMPATIBLE */
 
-#ifndef WIN32
+#ifndef __WIN32__
 
 #ifndef strchr
 extern char *strchr ();
@@ -670,7 +681,7 @@ extern char *strtok ();
 extern char *strerror ();
 #endif
 
-#endif /* !WIN32 */
+#endif /* !__WIN32__ */
 
 /* Various possibilities for alloca.  */
 #ifndef alloca
@@ -909,7 +920,7 @@ extern int use_windows;
 #endif
 
 #ifndef SLASH_P
-#if defined(__GO32__)||defined(WIN32)
+#if defined(__GO32__)||defined(__WIN32__)
 #define SLASH_P(X) ((X)=='\\')
 #else
 #define SLASH_P(X) ((X)=='/')
@@ -917,7 +928,7 @@ extern int use_windows;
 #endif
 
 #ifndef SLASH_CHAR
-#if defined(__GO32__)||defined(WIN32)
+#if defined(__GO32__)||defined(__WIN32__)
 #define SLASH_CHAR '\\'
 #else
 #define SLASH_CHAR '/'
@@ -925,7 +936,7 @@ extern int use_windows;
 #endif
 
 #ifndef SLASH_STRING
-#if defined(__GO32__)||defined(WIN32)
+#if defined(__GO32__)||defined(__WIN32__)
 #define SLASH_STRING "\\"
 #else
 #define SLASH_STRING "/"
index 4abc84c86ac09154358dc705705d29570a314fc0..bb3f0922485a70aaa87116677685ff5479c518c6 100644 (file)
@@ -1,5 +1,5 @@
 /* Basic C++ demangling support for GDB.
-   Copyright 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1991, 1992, 1996 Free Software Foundation, Inc.
    Written by Fred Fish at Cygnus Support.
 
 This file is part of GDB.
@@ -162,6 +162,31 @@ set_demangling_style (style)
   set_demangling_command ((char *) NULL, 0);
 }
 
+/* In order to allow a single demangler executable to demangle strings
+   using various common values of CPLUS_MARKER, as well as any specific
+   one set at compile time, we maintain a string containing all the
+   commonly used ones, and check to see if the marker we are looking for
+   is in that string.  CPLUS_MARKER is usually '$' on systems where the
+   assembler can deal with that.  Where the assembler can't, it's usually
+   '.' (but on many systems '.' is used for other things).  We put the
+   current defined CPLUS_MARKER first (which defaults to '$'), followed
+   by the next most common value, followed by an explicit '$' in case
+   the value of CPLUS_MARKER is not '$'.
+
+   We could avoid this if we could just get g++ to tell us what the actual
+   cplus marker character is as part of the debug information, perhaps by
+   ensuring that it is the character that terminates the gcc<n>_compiled
+   marker symbol (FIXME). */
+
+static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' };
+
+int
+is_cplus_marker (c)
+     int c;
+{
+  return c && strchr (cplus_markers, c) != NULL;
+}
+
 void
 _initialize_demangler ()
 {
index 07dca2b3b00082353fb9412aa3e493c1e4b009cc..96c59f859718cacac419396e08cc32e20dec5375 100644 (file)
@@ -785,7 +785,7 @@ parse_symbol (sh, ax, ext_sh, bigend, section_offsets)
       top_stack->numargs++;
 
       /* Special GNU C++ name.  */
-      if (name[0] == CPLUS_MARKER && name[1] == 't' && name[2] == 0)
+      if (is_cplus_marker (name[0]) && name[1] == 't' && name[2] == 0)
        name = "this";          /* FIXME, not alloc'd in obstack */
       s = new_symbol (name);
 
index 4ea4ba34ebd3b795351534c956a1aa00010ec975..dd0373b198f34c6120510f014601f35fb97c5e27 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for decoding "stabs" debugging information format.
-   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
              Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -565,7 +565,7 @@ define_symbol (valu, string, desc, type, objfile)
       SYMBOL_LINE(sym) = 0;                    /* unknown */
     }
 
-  if (string[0] == CPLUS_MARKER)
+  if (is_cplus_marker (string[0]))
     {
       /* Special GNU C++ names.  */
       switch (string[1])
@@ -2000,7 +2000,7 @@ read_member_functions (fip, pp, type, objfile)
       make_cleanup (free, new_fnlist);
       memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
       
-      if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == CPLUS_MARKER)
+      if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
        {
          /* This is a completely wierd case.  In order to stuff in the
             names that might contain colons (the usual name delimiter),
@@ -2535,12 +2535,9 @@ read_struct_fields (fip, pp, type, objfile)
       /* If is starts with CPLUS_MARKER it is a special abbreviation,
         unless the CPLUS_MARKER is followed by an underscore, in
         which case it is just the name of an anonymous type, which we
-        should handle like any other type name.  We accept either '$'
-        or '.', because a field name can never contain one of these
-        characters except as a CPLUS_MARKER (we probably should be
-        doing that in most parts of GDB).  */
+        should handle like any other type name.  */
 
-      if ((*p == '$' || *p == '.') && p[1] != '_')
+      if (is_cplus_marker (p[0]) && p[1] != '_')
        {
          if (!read_cpp_abbrev (fip, pp, type, objfile))
            return 0;
index 0a20db51dd6dc98a1149dce43cb97c47b5abca6b..49b0c1aa86ec79dc4ca1e567fe42d221b25c79e8 100644 (file)
@@ -931,7 +931,7 @@ struct partial_symtab
    Note that this macro is g++ specific (FIXME). */
 
 #define OPNAME_PREFIX_P(NAME) \
-  ((NAME)[0] == 'o' && (NAME)[1] == 'p' && (NAME)[2] == CPLUS_MARKER)
+  ((NAME)[0] == 'o' && (NAME)[1] == 'p' && is_cplus_marker ((NAME)[2]))
 
 /* Macro that yields non-zero value iff NAME is the prefix for C++ vtbl
    names.  Note that this macro is g++ specific (FIXME).
@@ -939,15 +939,16 @@ struct partial_symtab
    style, using thunks (where '$' is really CPLUS_MARKER). */
 
 #define VTBL_PREFIX_P(NAME) \
-  ((NAME)[3] == CPLUS_MARKER && (NAME)[0] == '_' \
+  ((NAME)[0] == '_' \
    && (((NAME)[1] == 'V' && (NAME)[2] == 'T') \
-       || ((NAME)[1] == 'v' && (NAME)[2] == 't')))
+       || ((NAME)[1] == 'v' && (NAME)[2] == 't')) \
+   && is_cplus_marker ((NAME)[3]))
 
 /* Macro that yields non-zero value iff NAME is the prefix for C++ destructor
    names.  Note that this macro is g++ specific (FIXME).  */
 
 #define DESTRUCTOR_PREFIX_P(NAME) \
-  ((NAME)[0] == '_' && (NAME)[1] == CPLUS_MARKER && (NAME)[2] == '_')
+  ((NAME)[0] == '_' && is_cplus_marker ((NAME)[1]) && (NAME)[2] == '_')
 
 \f
 /* External variables and functions for the objects described above. */
@@ -964,6 +965,10 @@ extern int current_source_line;
 
 extern struct objfile *current_objfile;
 
+/* True if we are nested inside psymtab_to_symtab. */
+
+extern int currently_reading_symtab;
+
 /* From utils.c.  */
 extern int demangle;
 extern int asm_demangle;
index f95c831601dbe986d5cdee4d61f76d97aa8e0d99..991d374a84d9e52f31caa389c020ff419b7ec91b 100644 (file)
@@ -1,5 +1,5 @@
 /* Low level packing and unpacking of values for GDB, the GNU Debugger.
-   Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1995
+   Copyright 1986, 1987, 1989, 1991, 1993, 1994, 1995, 1996
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -1039,7 +1039,7 @@ vb_match (type, index, basetype)
   if (*name != '_')
     return 0;
   /* gcc 2.4 uses _vb$.  */
-  if (name[1] == 'v' && name[2] == 'b' && name[3] == CPLUS_MARKER)
+  if (name[1] == 'v' && name[2] == 'b' && is_cplus_marker (name[3]))
     field_class_name = name + 4;
   /* gcc 2.5 will use __vb_.  */
   if (name[1] == '_' && name[2] == 'v' && name[3] == 'b' && name[4] == '_')
This page took 0.041343 seconds and 4 git commands to generate.