This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH]: C++ mangling patch that is about to be committed


I'm committing the following patch later today.

I'm also going to start moving these types of C++ specific routines
into cp-support.c and cp-support.h, rather than spread across 20
files, so it's clearer that they are C++ specific, and fall under the
maintainership of the C++ maintainer.  It'll also give other
maintainers less they feel they have to worry about, since they really
shouldn't have to deal with things like gdb_mangle_name.

	* symtab.h (OPNAME_PREFIX_P): Change operator prefix to correct value.
 
 	* symtab.c (gdb_mangle_name): Properly handle operators.


Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.15
diff -c -3 -p -w -B -b -r1.15 symtab.c
*** symtab.c	2000/09/04 08:29:25	1.15
--- symtab.c	2000/09/12 16:03:08	
*************** gdb_mangle_name (struct type *type, int 
*** 296,301 ****
--- 303,311 ----
    char buf[20];
    int len = (newname == NULL ? 0 : strlen (newname));
  
+   if (OPNAME_PREFIX_P (field_name))
+     return physname;
+ 
    is_full_physname_constructor =
      ((physname[0] == '_' && physname[1] == '_' &&
        (isdigit (physname[2]) || physname[2] == 'Q' || physname[2] == 't'))
*************** gdb_mangle_name (struct type *type, int 
*** 331,355 ****
        sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len);
      }
    mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
! 		      + strlen (buf) + len
! 		      + strlen (physname)
! 		      + 1);
! 
!   /* Only needed for GNU-mangled names.  ANSI-mangled names
!      work with the normal mechanisms.  */
!   if (OPNAME_PREFIX_P (field_name))
!     {
!       const char *opname = cplus_mangle_opname (field_name + 3, 0);
!       if (opname == NULL)
! 	error ("No mangling for \"%s\"", field_name);
!       mangled_name_len += strlen (opname);
!       mangled_name = (char *) xmalloc (mangled_name_len);
  
-       strncpy (mangled_name, field_name, 3);
-       mangled_name[3] = '\0';
-       strcat (mangled_name, opname);
-     }
-   else
      {
        mangled_name = (char *) xmalloc (mangled_name_len);
        if (is_constructor)
--- 341,348 ----
        sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len);
      }
    mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
! 		      + strlen (buf) + len + strlen (physname) + 1);
  
    {
      mangled_name = (char *) xmalloc (mangled_name_len);
      if (is_constructor)

Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.13
diff -c -3 -p -r1.13 symtab.h
*** symtab.h    2000/08/07 15:02:48     1.13
--- symtab.h    2000/10/10 01:39:57
*************** extern CORE_ADDR symbol_overlayed_addres
*** 168,175 ****
     specified obstack. */

  #define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack)                    \
!   do {                                                                       \      char *demangled = NULL;                                           \
      if (SYMBOL_LANGUAGE (symbol) == language_cplus                    \
        || SYMBOL_LANGUAGE (symbol) == language_auto)                   \
        {                                                                      \--- 168,177 ----
     specified obstack. */

  #define SYMBOL_INIT_DEMANGLED_NAME(symbol,obstack)                    \
!   {                                                                   \
      char *demangled = NULL;                                           \
+     if (SYMBOL_LANGUAGE (symbol) == language_unknown)                 \
+           SYMBOL_LANGUAGE(symbol) = language_auto;                    \
      if (SYMBOL_LANGUAGE (symbol) == language_cplus                    \
        || SYMBOL_LANGUAGE (symbol) == language_auto)                   \
        {                                                                      \*************** extern CORE_ADDR symbol_overlayed_addres
*** 222,232 ****
            SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL;                \
          }                                                             \
        }                                                                      \!     if (SYMBOL_LANGUAGE (symbol) == language_auto)                    \
!       {                                                                      \!       SYMBOL_LANGUAGE (symbol) = language_unknown;                    \
!       }                                                                      \!   } while (0)

  /* Macro that returns the demangled name for a symbol based on the language
     for that symbol.  If no demangled name exists, returns NULL. */
--- 224,230 ----
            SYMBOL_CHILL_DEMANGLED_NAME (symbol) = NULL;                \
          }                                                             \
        }                                                                      \!   }

  /* Macro that returns the demangled name for a symbol based on the language
     for that symbol.  If no demangled name exists, returns NULL. */
*************** struct partial_symtab
*** 1047,1059 ****
  #define VTBL_FNADDR_OFFSET 2
 
  /* Macro that yields non-zero value iff NAME is the prefix for C++ operator
!    names.  If you leave out the parenthesis here you will lose!
!    Currently 'o' 'p' CPLUS_MARKER is used for both the symbol in the
!    symbol-file and the names in gdb's symbol table.
!    Note that this macro is g++ specific (FIXME). */
!
  #define OPNAME_PREFIX_P(NAME) \
!   ((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).
--- 1045,1053 ----
  #define VTBL_FNADDR_OFFSET 2
 
  /* Macro that yields non-zero value iff NAME is the prefix for C++ operator
!    names.  If you leave out the parenthesis here you will lose! */
  #define OPNAME_PREFIX_P(NAME) \
!   (!strncmp(NAME,"operator",8))
 
  /* Macro that yields non-zero value iff NAME is the prefix for C++ vtbl
     names.  Note that this macro is g++ specific (FIXME).             


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]