This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Demangling broken (was: Re: [PATCH] Demangler woes with currentCVS and type names)


OK, I couldn't leave well enough alone.  This patch reverts most of H.J.'s
change, adds a flags parameter to cplus_demangle_v3 instead of messing with
multiple functions, adds support for requesting verbose output, and changes
c++filt and collect2 to request it.  gdb folk may also want to consider
passing DMGL_VERBOSE, but I suspect they will want it in some places and
not in others.

I felt that adding a parameter to cplus_demangle_v3 was OK, as it's only
ever called by cplus_demangle.

Tested i686-pc-linux-gnu.

2002-02-05  Jason Merrill  <jason@redhat.com>

	* demangle.h (cplus_demangle_v3): Add "options" parm.
	(cplus_demangle_v3_type): Remove prototype.
	(DMGL_VERBOSE): New macro.
	(DMGL_TYPES): New macro.

2002-02-05  Jason Merrill  <jason@redhat.com>

	* cplus-dem.c (flags): Add DMGL_VERBOSE
	(cplus_demangle_v3_p): Remove.
	(demangle_it): Add DMGL_TYPES to passed flags.
	* cp-demangle.c (cplus_demangle_v3_all): Remove.
	(cplus_demangle_v3_type): Remove.
	(cplus_demangle_v3): Add options parm.

2002-02-05  Jason Merrill  <jason@redhat.com>

	* collect2.c (dump_file): Pass DMGL_VERBOSE to cplus_demangle.

Index: gcc/collect2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/collect2.c,v
retrieving revision 1.132
diff -c -p -r1.132 collect2.c
*** gcc/collect2.c	2002/01/03 19:34:16	1.132
--- gcc/collect2.c	2002/02/05 16:24:08
*************** dump_file (name)
*** 532,538 ****
  	  if (no_demangle)
  	    result = 0;
  	  else
! 	    result = cplus_demangle (p, DMGL_PARAMS | DMGL_ANSI);
  
  	  if (result)
  	    {
--- 532,538 ----
  	  if (no_demangle)
  	    result = 0;
  	  else
! 	    result = cplus_demangle (p, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
  
  	  if (result)
  	    {
Index: libiberty/cp-demangle.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.c,v
retrieving revision 1.38
diff -c -p -r1.38 cp-demangle.c
*** libiberty/cp-demangle.c	2002/02/03 04:00:33	1.38
--- libiberty/cp-demangle.c	2002/02/05 16:24:08
*************** static status_t cp_demangle
*** 940,947 ****
    PARAMS ((const char *, dyn_string_t, int));
  static status_t cp_demangle_type
    PARAMS ((const char*, dyn_string_t));
- static char* cplus_demangle_v3_all
-   PARAMS ((const char*, int));
  
  /* When passed to demangle_bare_function_type, indicates that the
     function's return type is not encoded before its parameter types.  */
--- 940,945 ----
*************** __cxa_demangle (mangled_name, output_buf
*** 3687,3712 ****
     If the demangling failes, returns NULL.  */
  
  char *
! cplus_demangle_v3 (mangled)
       const char* mangled;
  {
-   return cplus_demangle_v3_all (mangled, 0);
- }
- 
- char *
- cplus_demangle_v3_type (mangled)
-      const char* mangled;
- {
-   return cplus_demangle_v3_all (mangled, 1);
- }
- 
- static char *
- cplus_demangle_v3_all (mangled, type)
-      const char* mangled;
-      int type;
- {
    dyn_string_t demangled;
    status_t status;
  
    if (mangled[0] == '_' && mangled[1] == 'Z')
      /* It is not a type.  */
--- 3685,3697 ----
     If the demangling failes, returns NULL.  */
  
  char *
! cplus_demangle_v3 (mangled, options)
       const char* mangled;
+      int options;
  {
    dyn_string_t demangled;
    status_t status;
+   int type = !!(options & DMGL_TYPES);
  
    if (mangled[0] == '_' && mangled[1] == 'Z')
      /* It is not a type.  */
*************** cplus_demangle_v3_all (mangled, type)
*** 3717,3722 ****
--- 3702,3709 ----
        if (!type)
  	return NULL;
      }
+ 
+   flag_verbose = !!(options & DMGL_VERBOSE);
  
    /* Create a dyn_string to hold the demangled name.  */
    demangled = dyn_string_new (0);
Index: libiberty/cplus-dem.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cplus-dem.c,v
retrieving revision 1.82
diff -c -p -r1.82 cplus-dem.c
*** libiberty/cplus-dem.c	2002/02/03 04:00:34	1.82
--- libiberty/cplus-dem.c	2002/02/05 16:24:09
*************** do_hpacc_template_literal PARAMS ((struc
*** 478,486 ****
  static int
  snarf_numeric_literal PARAMS ((const char **, string *));
  
- static char* (*cplus_demangle_v3_p) PARAMS ((const char* mangled))
-   = cplus_demangle_v3;
- 
  /* There is a TYPE_QUAL value for each type qualifier.  They can be
     combined by bitwise-or to form the complete set of qualifiers for a
     type.  */
--- 478,483 ----
*************** cplus_demangle (mangled, options)
*** 914,920 ****
    /* The V3 ABI demangling is implemented elsewhere.  */
    if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
      {
!       ret = cplus_demangle_v3_p (mangled);
        if (ret || GNU_V3_DEMANGLING)
  	return ret;
      }
--- 911,917 ----
    /* The V3 ABI demangling is implemented elsewhere.  */
    if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
      {
!       ret = cplus_demangle_v3 (mangled, work->options);
        if (ret || GNU_V3_DEMANGLING)
  	return ret;
      }
*************** string_append_template_idx (s, idx)
*** 4877,4883 ****
  
  static const char *program_name;
  static const char *program_version = VERSION;
! static int flags = DMGL_PARAMS | DMGL_ANSI;
  
  static void demangle_it PARAMS ((char *));
  static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
--- 4874,4880 ----
  
  static const char *program_name;
  static const char *program_version = VERSION;
! static int flags = DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE;
  
  static void demangle_it PARAMS ((char *));
  static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
*************** demangle_it (mangled_name)
*** 4890,4896 ****
  {
    char *result;
  
!   result = cplus_demangle (mangled_name, flags);
    if (result == NULL)
      {
        printf ("%s\n", mangled_name);
--- 4887,4894 ----
  {
    char *result;
  
!   /* For command line args, also try to demangle type encodings.  */
!   result = cplus_demangle (mangled_name, flags | DMGL_TYPES);
    if (result == NULL)
      {
        printf ("%s\n", mangled_name);
*************** main (argc, argv)
*** 5089,5095 ****
  
    if (optind < argc)
      {
-       cplus_demangle_v3_p = cplus_demangle_v3_type;
        for ( ; optind < argc; optind++)
  	{
  	  demangle_it (argv[optind]);
--- 5087,5092 ----
Index: include/demangle.h
===================================================================
RCS file: /cvs/gcc/gcc/include/demangle.h,v
retrieving revision 1.19
diff -c -p -r1.19 demangle.h
*** include/demangle.h	2002/02/03 03:59:23	1.19
--- include/demangle.h	2002/02/05 16:24:09
***************
*** 29,34 ****
--- 29,36 ----
  #define DMGL_PARAMS	 (1 << 0)	/* Include function args */
  #define DMGL_ANSI	 (1 << 1)	/* Include const, volatile, etc */
  #define DMGL_JAVA	 (1 << 2)	/* Demangle as Java rather than C++. */
+ #define DMGL_VERBOSE	 (1 << 3)	/* Include implementation details.  */
+ #define DMGL_TYPES	 (1 << 4)	/* Also try to demangle type encodings.  */
  
  #define DMGL_AUTO	 (1 << 8)
  #define DMGL_GNU	 (1 << 9)
*************** cplus_demangle_name_to_style PARAMS ((co
*** 125,136 ****
  
  /* V3 ABI demangling entry points, defined in cp-demangle.c.  */
  extern char*
! cplus_demangle_v3 PARAMS ((const char* mangled));
! 
! /* V3 ABI demangling entry points, defined in cp-demangle.c. Also
!    demagle types. */
! extern char*
! cplus_demangle_v3_type PARAMS ((const char* mangled));
  
  extern char*
  java_demangle_v3 PARAMS ((const char* mangled));
--- 127,133 ----
  
  /* V3 ABI demangling entry points, defined in cp-demangle.c.  */
  extern char*
! cplus_demangle_v3 PARAMS ((const char* mangled, int options));
  
  extern char*
  java_demangle_v3 PARAMS ((const char* mangled));

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