Patchwork ping: [patch] libiberty/cp-demangle.c: Fix CP_DEMANGLE_DEBUG SIGSEGV

login
register
mail settings
Submitter Jan Kratochvil
Date Aug. 2, 2011, 6:07 p.m.
Message ID <20110802180715.GA28777@host1.jankratochvil.net>
Download mbox | patch
Permalink /patch/107983/
State New
Headers show

Comments

Jan Kratochvil - Aug. 2, 2011, 6:07 p.m.
ping:

On Tue, 28 Jun 2011 22:15:04 +0200, Jan Kratochvil wrote:
Hi,

a mechanical patch which fixes during

#define CP_DEMANGLE_DEBUG
make check
->
/bin/sh: line 1:  9179 Segmentation fault      ./test-demangle < ./demangle-expected

which also fixes confusing output for _Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_
        binary operator arguments
          binary operator
            operator .
            binary operator arguments
???--->                     template
                name 'g'
                template argument list
                  template parameter 1
          argument list


Thanks,
Jan


libiberty/
2011-06-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-demangle.c (d_dump): Add " (zero-based)" to
	DEMANGLE_COMPONENT_TEMPLATE_PARAM.  Implement
	DEMANGLE_COMPONENT_FUNCTION_PARAM, DEMANGLE_COMPONENT_VECTOR_TYPE,
	DEMANGLE_COMPONENT_NUMBER, DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS,
	DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, DEMANGLE_COMPONENT_LAMBDA,
	DEMANGLE_COMPONENT_DEFAULT_ARG and DEMANGLE_COMPONENT_UNNAMED_TYPE.
	Print "??? %d" on unknown dc->type.

Patch

--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -506,7 +507,10 @@  d_dump (struct demangle_component *dc, int indent)
       printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s);
       return;
     case DEMANGLE_COMPONENT_TEMPLATE_PARAM:
-      printf ("template parameter %ld\n", dc->u.s_number.number);
+      printf ("template parameter %ld (zero-based)\n", dc->u.s_number.number);
+      return;
+    case DEMANGLE_COMPONENT_FUNCTION_PARAM:
+      printf ("function parameter %ld (zero-based)\n", dc->u.s_number.number);
       return;
     case DEMANGLE_COMPONENT_CTOR:
       printf ("constructor %d\n", (int) dc->u.s_ctor.kind);
@@ -633,6 +637,9 @@  d_dump (struct demangle_component *dc, int indent)
     case DEMANGLE_COMPONENT_FIXED_TYPE:
       printf ("fixed-point type\n");
       break;
+    case DEMANGLE_COMPONENT_VECTOR_TYPE:
+      printf ("vector type\n");
+      break;
     case DEMANGLE_COMPONENT_ARGLIST:
       printf ("argument list\n");
       break;
@@ -675,12 +682,35 @@  d_dump (struct demangle_component *dc, int indent)
     case DEMANGLE_COMPONENT_CHARACTER:
       printf ("character '%c'\n",  dc->u.s_character.character);
       return;
+    case DEMANGLE_COMPONENT_NUMBER:
+      printf ("number %ld\n", dc->u.s_number.number);
+      return;
     case DEMANGLE_COMPONENT_DECLTYPE:
       printf ("decltype\n");
       break;
+    case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
+      printf ("global constructors keyed to name\n");
+      break;
+    case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
+      printf ("global destructors keyed to name\n");
+      break;
+    case DEMANGLE_COMPONENT_LAMBDA:
+      printf ("lambda %d (zero-based)\n", dc->u.s_unary_num.num);
+      d_dump (dc->u.s_unary_num.sub, indent + 2);
+      return;
+    case DEMANGLE_COMPONENT_DEFAULT_ARG:
+      printf ("default argument %d (zero-based)\n", dc->u.s_unary_num.num);
+      d_dump (dc->u.s_unary_num.sub, indent + 2);
+      return;
+    case DEMANGLE_COMPONENT_UNNAMED_TYPE:
+      printf ("unnamed type %ld\n", dc->u.s_number.number);
+      return;
     case DEMANGLE_COMPONENT_PACK_EXPANSION:
       printf ("pack expansion\n");
       break;
+    default:
+      printf ("??? %d\n", dc->type);
+      break;
     }
 
   d_dump (d_left (dc), indent + 2);