tree.c (tree_code_size): Add TRANSLATION_UNIT_DECL, NAMESPACE_DECL, IMPORTED_DECL...
[gcc.git] / gcc / print-tree.c
index 1d66769a1f768ccd03ec8be7833f8996d17b7934..eee0df9afc0b91195e512d78209d7cc65cfdd2a6 100644 (file)
@@ -1,7 +1,5 @@
 /* Prints out tree in human readable form - GCC
-   Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2014 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -25,13 +23,19 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
-#include "real.h"
-#include "fixed-value.h"
+#include "varasm.h"
+#include "print-rtl.h"
+#include "stor-layout.h"
 #include "ggc.h"
 #include "langhooks.h"
 #include "tree-iterator.h"
 #include "diagnostic.h"
-#include "tree-flow.h"
+#include "gimple-pretty-print.h" /* FIXME */
+#include "cgraph.h"
+#include "tree-cfg.h"
+#include "tree-dump.h"
+#include "dumpfile.h"
+#include "wide-int-print.h"
 
 /* Define the hash table of nodes already seen.
    Such nodes are not repeated; brief cross-references are used.  */
@@ -46,20 +50,6 @@ struct bucket
 
 static struct bucket **table;
 
-/* Print the node NODE on standard error, for debugging.
-   Most nodes referred to by this one are printed recursively
-   down to a depth of six.  */
-
-void
-debug_tree (tree node)
-{
-  table = XCNEWVEC (struct bucket *, HASH_SIZE);
-  print_node (stderr, "", node, 0);
-  free (table);
-  table = 0;
-  putc ('\n', stderr);
-}
-
 /* Print PREFIX and ADDR to FILE.  */
 void
 dump_addr (FILE *file, const char *prefix, const void *addr)
@@ -86,7 +76,7 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
      name if any.  */
   if (indent > 0)
     fprintf (file, " ");
-  fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]);
+  fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node)));
   dump_addr (file, " ", node);
 
   if (tclass == tcc_declaration)
@@ -95,10 +85,22 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
        fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
       else if (TREE_CODE (node) == LABEL_DECL
               && LABEL_DECL_UID (node) != -1)
-       fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
+       {
+         if (dump_flags & TDF_NOUID)
+           fprintf (file, " L.xxxx");
+         else
+           fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
+       }
       else
-       fprintf (file, " %c.%u", TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
-                DECL_UID (node));
+       {
+         if (dump_flags & TDF_NOUID)
+           fprintf (file, " %c.xxxx",
+                    TREE_CODE (node) == CONST_DECL ? 'C' : 'D');
+         else
+           fprintf (file, " %c.%u",
+                    TREE_CODE (node) == CONST_DECL ? 'C' : 'D',
+                    DECL_UID (node));
+       }
     }
   else if (tclass == tcc_type)
     {
@@ -111,6 +113,8 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
            fprintf (file, " %s",
                     IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
        }
+      if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
+       fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
     }
   if (TREE_CODE (node) == IDENTIFIER_NODE)
     fprintf (file, " %s", IDENTIFIER_POINTER (node));
@@ -122,16 +126,7 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent)
        fprintf (file, " overflow");
 
       fprintf (file, " ");
-      if (TREE_INT_CST_HIGH (node) == 0)
-       fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED, TREE_INT_CST_LOW (node));
-      else if (TREE_INT_CST_HIGH (node) == -1
-              && TREE_INT_CST_LOW (node) != 0)
-       fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
-                -TREE_INT_CST_LOW (node));
-      else
-       fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
-                (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
-                (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
+      print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
     }
   if (TREE_CODE (node) == REAL_CST)
     {
@@ -197,7 +192,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
 
   if (node == 0)
     return;
-  
+
   code = TREE_CODE (node);
   tclass = TREE_CODE_CLASS (code);
 
@@ -227,8 +222,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
   /* Allow this function to be called if the table is not there.  */
   if (table)
     {
-      hash = ((unsigned long) node) % HASH_SIZE;
-      
+      hash = ((uintptr_t) node) % HASH_SIZE;
+
       /* If node is in the table, just mention its address.  */
       for (b = table[hash]; b; b = b->next)
        if (b->node == node)
@@ -236,7 +231,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
            print_node_brief (file, prefix, node, indent);
            return;
          }
-      
+
       /* Add this node to the table.  */
       b = XNEW (struct bucket);
       b->node = node;
@@ -248,7 +243,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
   indent_to (file, indent);
 
   /* Print the slot this node is in, and its code, and address.  */
-  fprintf (file, "%s <%s", prefix, tree_code_name[(int) code]);
+  fprintf (file, "%s <%s", prefix, get_tree_code_name (code));
   dump_addr (file, " ", node);
 
   /* Print the name, if any.  */
@@ -258,10 +253,20 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
        fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME (node)));
       else if (code == LABEL_DECL
               && LABEL_DECL_UID (node) != -1)
-       fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
+       {
+         if (dump_flags & TDF_NOUID)
+           fprintf (file, " L.xxxx");
+         else
+           fprintf (file, " L.%d", (int) LABEL_DECL_UID (node));
+       }
       else
-       fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
-                DECL_UID (node));
+       {
+         if (dump_flags & TDF_NOUID)
+           fprintf (file, " %c.xxxx", code == CONST_DECL ? 'C' : 'D');
+         else
+           fprintf (file, " %c.%u", code == CONST_DECL ? 'C' : 'D',
+                    DECL_UID (node));
+       }
     }
   else if (tclass == tcc_type)
     {
@@ -283,7 +288,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
       if (indent <= 4)
        print_node_brief (file, "type", TREE_TYPE (node), indent + 4);
     }
-  else
+  else if (CODE_CONTAINS_STRUCT (code, TS_TYPED))
     {
       print_node (file, "type", TREE_TYPE (node), indent + 4);
       if (TREE_TYPE (node))
@@ -295,11 +300,16 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
 
   if (TYPE_P (node) ? TYPE_READONLY (node) : TREE_READONLY (node))
     fputs (" readonly", file);
+  if (TYPE_P (node) && TYPE_ATOMIC (node))
+    fputs (" atomic", file);
   if (!TYPE_P (node) && TREE_CONSTANT (node))
     fputs (" constant", file);
   else if (TYPE_P (node) && TYPE_SIZES_GIMPLIFIED (node))
     fputs (" sizes-gimplified", file);
 
+  if (TYPE_P (node) && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
+    fprintf (file, " address-space-%d", TYPE_ADDR_SPACE (node));
+
   if (TREE_ADDRESSABLE (node))
     fputs (" addressable", file);
   if (TREE_THIS_VOLATILE (node))
@@ -322,20 +332,24 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
     fputs (" deprecated", file);
   if (TREE_VISITED (node))
     fputs (" visited", file);
-  if (TREE_LANG_FLAG_0 (node))
-    fputs (" tree_0", file);
-  if (TREE_LANG_FLAG_1 (node))
-    fputs (" tree_1", file);
-  if (TREE_LANG_FLAG_2 (node))
-    fputs (" tree_2", file);
-  if (TREE_LANG_FLAG_3 (node))
-    fputs (" tree_3", file);
-  if (TREE_LANG_FLAG_4 (node))
-    fputs (" tree_4", file);
-  if (TREE_LANG_FLAG_5 (node))
-    fputs (" tree_5", file);
-  if (TREE_LANG_FLAG_6 (node))
-    fputs (" tree_6", file);
+
+  if (code != TREE_VEC && code != INTEGER_CST && code != SSA_NAME)
+    {
+      if (TREE_LANG_FLAG_0 (node))
+       fputs (" tree_0", file);
+      if (TREE_LANG_FLAG_1 (node))
+       fputs (" tree_1", file);
+      if (TREE_LANG_FLAG_2 (node))
+       fputs (" tree_2", file);
+      if (TREE_LANG_FLAG_3 (node))
+       fputs (" tree_3", file);
+      if (TREE_LANG_FLAG_4 (node))
+       fputs (" tree_4", file);
+      if (TREE_LANG_FLAG_5 (node))
+       fputs (" tree_5", file);
+      if (TREE_LANG_FLAG_6 (node))
+       fputs (" tree_6", file);
+    }
 
   /* DECL_ nodes have additional attributes.  */
 
@@ -349,7 +363,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
          if (DECL_IGNORED_P (node))
            fputs (" ignored", file);
          if (DECL_ABSTRACT (node))
-           fputs (" abstract", file);      
+           fputs (" abstract", file);
          if (DECL_EXTERNAL (node))
            fputs (" external", file);
          if (DECL_NONLOCAL (node))
@@ -381,8 +395,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
        fputs (" autoinline", file);
       if (code == FUNCTION_DECL && DECL_BUILT_IN (node))
        fputs (" built-in", file);
-      if (code == FUNCTION_DECL && DECL_NO_STATIC_CHAIN (node))
-       fputs (" no-static-chain", file);
+      if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node))
+       fputs (" static-chain", file);
+      if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node))
+       fputs (" tm-clone", file);
 
       if (code == FIELD_DECL && DECL_PACKED (node))
        fputs (" packed", file);
@@ -391,39 +407,23 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
       if (code == FIELD_DECL && DECL_NONADDRESSABLE_P (node))
        fputs (" nonaddressable", file);
 
-      if (code == LABEL_DECL && DECL_ERROR_ISSUED (node))
-       fputs (" error-issued", file);
       if (code == LABEL_DECL && EH_LANDING_PAD_NR (node))
        fprintf (file, " landing-pad:%d", EH_LANDING_PAD_NR (node));
 
       if (code == VAR_DECL && DECL_IN_TEXT_SECTION (node))
        fputs (" in-text-section", file);
+      if (code == VAR_DECL && DECL_IN_CONSTANT_POOL (node))
+       fputs (" in-constant-pool", file);
       if (code == VAR_DECL && DECL_COMMON (node))
        fputs (" common", file);
       if (code == VAR_DECL && DECL_THREAD_LOCAL_P (node))
        {
-         enum tls_model kind = DECL_TLS_MODEL (node);
-         switch (kind)
-           {
-             case TLS_MODEL_GLOBAL_DYNAMIC:
-               fputs (" tls-global-dynamic", file);
-               break;
-             case TLS_MODEL_LOCAL_DYNAMIC:
-               fputs (" tls-local-dynamic", file);
-               break;
-             case TLS_MODEL_INITIAL_EXEC:
-               fputs (" tls-initial-exec", file);
-               break;
-             case TLS_MODEL_LOCAL_EXEC:
-               fputs (" tls-local-exec", file);
-               break;
-             default:
-               gcc_unreachable ();
-           }
+         fputs (" ", file);
+         fputs (tls_model_names[DECL_TLS_MODEL (node)], file);
        }
 
       if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
-       {         
+       {
          if (DECL_VIRTUAL_P (node))
            fputs (" virtual", file);
          if (DECL_PRESERVE_P (node))
@@ -444,7 +444,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
            fputs (" decl_6", file);
          if (DECL_LANG_FLAG_7 (node))
            fputs (" decl_7", file);
-         
+
          mode = DECL_MODE (node);
          fprintf (file, " %s", GET_MODE_NAME (mode));
        }
@@ -462,16 +462,16 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
               xloc.column);
 
       if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
-       {         
+       {
          print_node (file, "size", DECL_SIZE (node), indent + 4);
          print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
-         
+
          if (code != FUNCTION_DECL || DECL_BUILT_IN (node))
            indent_to (file, indent + 3);
-         
+
          if (DECL_USER_ALIGN (node))
            fprintf (file, " user");
-         
+
          fprintf (file, " align %d", DECL_ALIGN (node));
          if (code == FIELD_DECL)
            fprintf (file, " offset_align " HOST_WIDE_INT_PRINT_UNSIGNED,
@@ -499,7 +499,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
 
       print_node_brief (file, "context", DECL_CONTEXT (node), indent + 4);
 
-      if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) 
+      if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
        {
          print_node_brief (file, "attributes",
                            DECL_ATTRIBUTES (node), indent + 4);
@@ -514,7 +514,6 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
        }
       if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
        {
-         print_node (file, "arguments", DECL_ARGUMENT_FLD (node), indent + 4);
          print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
        }
 
@@ -540,8 +539,9 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
       else if (code == FUNCTION_DECL
               && DECL_STRUCT_FUNCTION (node) != 0)
        {
+         print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
          indent_to (file, indent + 4);
-         dump_addr (file, "saved-insns ", DECL_STRUCT_FUNCTION (node));
+         dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
        }
 
       if ((code == VAR_DECL || code == PARM_DECL)
@@ -559,26 +559,20 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
       if (TYPE_UNSIGNED (node))
        fputs (" unsigned", file);
 
-      /* The no-force-blk flag is used for different things in
-        different types.  */
-      if ((code == RECORD_TYPE
-          || code == UNION_TYPE
-          || code == QUAL_UNION_TYPE)
-         && TYPE_NO_FORCE_BLK (node))
+      if (TYPE_NO_FORCE_BLK (node))
        fputs (" no-force-blk", file);
-      else if (code == INTEGER_TYPE
-              && TYPE_IS_SIZETYPE (node))
-       fputs (" sizetype", file);
 
       if (TYPE_STRING_FLAG (node))
        fputs (" string-flag", file);
+
       if (TYPE_NEEDS_CONSTRUCTING (node))
        fputs (" needs-constructing", file);
 
       /* The transparent-union flag is used for different things in
         different nodes.  */
-      if (code == UNION_TYPE && TYPE_TRANSPARENT_UNION (node))
-       fputs (" transparent-union", file);
+      if ((code == UNION_TYPE || code == RECORD_TYPE)
+         && TYPE_TRANSPARENT_AGGR (node))
+       fputs (" transparent-aggr", file);
       else if (code == ARRAY_TYPE
               && TYPE_NONALIASED_COMPONENT (node))
        fputs (" nonaliased-component", file);
@@ -622,7 +616,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
        fprintf (file, " structural equality");
       else
        dump_addr (file, " canonical type ", TYPE_CANONICAL (node));
-      
+
       print_node (file, "attributes", TYPE_ATTRIBUTES (node), indent + 4);
 
       if (INTEGRAL_TYPE_P (node) || code == REAL_TYPE
@@ -707,12 +701,13 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
          for (i = 0; i < len; i++)
            {
              char temp[10];
-             
+
              sprintf (temp, "arg %d", i);
              print_node (file, temp, TREE_OPERAND (node, i), indent + 4);
            }
        }
-      print_node (file, "chain", TREE_CHAIN (node), indent + 4);
+      if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
+       print_node (file, "chain", TREE_CHAIN (node), indent + 4);
       break;
 
     case tcc_constant:
@@ -724,17 +719,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
            fprintf (file, " overflow");
 
          fprintf (file, " ");
-         if (TREE_INT_CST_HIGH (node) == 0)
-           fprintf (file, HOST_WIDE_INT_PRINT_UNSIGNED,
-                    TREE_INT_CST_LOW (node));
-         else if (TREE_INT_CST_HIGH (node) == -1
-                  && TREE_INT_CST_LOW (node) != 0)
-           fprintf (file, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
-                    -TREE_INT_CST_LOW (node));
-         else
-           fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
-                    (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (node),
-                    (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (node));
+         print_dec (node, file, TYPE_SIGN (TREE_TYPE (node)));
          break;
 
        case REAL_CST:
@@ -774,16 +759,13 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
 
        case VECTOR_CST:
          {
-           tree vals = TREE_VECTOR_CST_ELTS (node);
            char buf[10];
-           tree link;
-           int i;
+           unsigned i;
 
-           i = 0;
-           for (link = vals; link; link = TREE_CHAIN (link), ++i)
+           for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
              {
-               sprintf (buf, "elt%d: ", i);
-               print_node (file, buf, TREE_VALUE (link), indent + 4);
+               sprintf (buf, "elt%u: ", i);
+               print_node (file, buf, VECTOR_CST_ELT (node, i), indent + 4);
              }
          }
          break;
@@ -804,15 +786,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
                if (ch >= ' ' && ch < 127)
                  putc (ch, file);
                else
-                 fprintf(file, "\\%03o", ch & 0xFF);
+                 fprintf (file, "\\%03o", ch & 0xFF);
              }
            fputc ('\"', file);
          }
-         /* Print the chain at second level.  */
-         if (indent == 4)
-           print_node (file, "chain", TREE_CHAIN (node), indent + 4);
-         else
-           print_node_brief (file, "chain", TREE_CHAIN (node), indent + 4);
          break;
 
        case IDENTIFIER_NODE:
@@ -832,8 +809,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
              {
                char temp[10];
                sprintf (temp, "elt %d", i);
-               indent_to (file, indent + 4);
-               print_node_brief (file, temp, TREE_VEC_ELT (node, i), 0);
+               print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4);
              }
          break;
 
@@ -841,7 +817,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
          {
            unsigned HOST_WIDE_INT cnt;
            tree index, value;
-           len = VEC_length (constructor_elt, CONSTRUCTOR_ELTS (node));
+           len = vec_safe_length (CONSTRUCTOR_ELTS (node));
            fprintf (file, " lngt %d", len);
            FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),
                                      cnt, index, value)
@@ -872,7 +848,6 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
                print_node (file, "stmt", tsi_stmt (i), indent + 4);
              }
          }
-         print_node (file, "chain", TREE_CHAIN (node), indent + 4);
          break;
 
        case BLOCK:
@@ -951,3 +926,172 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
 
   fprintf (file, ">");
 }
+
+
+/* Print the node NODE on standard error, for debugging.
+   Most nodes referred to by this one are printed recursively
+   down to a depth of six.  */
+
+DEBUG_FUNCTION void
+debug_tree (tree node)
+{
+  table = XCNEWVEC (struct bucket *, HASH_SIZE);
+  print_node (stderr, "", node, 0);
+  free (table);
+  table = 0;
+  putc ('\n', stderr);
+}
+
+DEBUG_FUNCTION void
+debug_raw (const tree_node &ref)
+{
+  debug_tree (const_cast <tree> (&ref));
+}
+
+DEBUG_FUNCTION void
+debug_raw (const tree_node *ptr)
+{
+  if (ptr)
+    debug_raw (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+static void
+dump_tree_via_hooks (const tree_node *ptr, int options)
+{
+  if (DECL_P (ptr))
+    lang_hooks.print_decl (stderr, const_cast <tree_node*> (ptr), 0);
+  else if (TYPE_P (ptr))
+    lang_hooks.print_type (stderr, const_cast <tree_node*> (ptr), 0);
+  else if (TREE_CODE (ptr) == IDENTIFIER_NODE)
+    lang_hooks.print_identifier (stderr, const_cast <tree_node*> (ptr), 0);
+  else
+    print_generic_expr (stderr, const_cast <tree_node*> (ptr), options);
+  fprintf (stderr, "\n");
+}
+
+DEBUG_FUNCTION void
+debug (const tree_node &ref)
+{
+  dump_tree_via_hooks (&ref, 0);
+}
+
+DEBUG_FUNCTION void
+debug (const tree_node *ptr)
+{
+  if (ptr)
+    debug (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_verbose (const tree_node &ref)
+{
+  dump_tree_via_hooks (&ref, TDF_VERBOSE);
+}
+
+DEBUG_FUNCTION void
+debug_verbose (const tree_node *ptr)
+{
+  if (ptr)
+    debug_verbose (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_head (const tree_node &ref)
+{
+  debug (ref);
+}
+
+DEBUG_FUNCTION void
+debug_head (const tree_node *ptr)
+{
+  if (ptr)
+    debug_head (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_body (const tree_node &ref)
+{
+  if (TREE_CODE (&ref) == FUNCTION_DECL)
+    dump_function_to_file (const_cast <tree_node*> (&ref), stderr, 0);
+  else
+    debug (ref);
+}
+
+DEBUG_FUNCTION void
+debug_body (const tree_node *ptr)
+{
+  if (ptr)
+    debug_body (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+/* Print the vector of trees VEC on standard error, for debugging.
+   Most nodes referred to by this one are printed recursively
+   down to a depth of six.  */
+
+DEBUG_FUNCTION void
+debug_raw (vec<tree, va_gc> &ref)
+{
+  tree elt;
+  unsigned ix;
+
+  /* Print the slot this node is in, and its code, and address.  */
+  fprintf (stderr, "<VEC");
+  dump_addr (stderr, " ", ref.address ());
+
+  FOR_EACH_VEC_ELT (ref, ix, elt)
+    {
+      fprintf (stderr, "elt %d ", ix);
+      debug_raw (elt);
+    }
+}
+
+DEBUG_FUNCTION void
+debug (vec<tree, va_gc> &ref)
+{
+  tree elt;
+  unsigned ix;
+
+  /* Print the slot this node is in, and its code, and address.  */
+  fprintf (stderr, "<VEC");
+  dump_addr (stderr, " ", ref.address ());
+
+  FOR_EACH_VEC_ELT (ref, ix, elt)
+    {
+      fprintf (stderr, "elt %d ", ix);
+      debug (elt);
+    }
+}
+
+DEBUG_FUNCTION void
+debug (vec<tree, va_gc> *ptr)
+{
+  if (ptr)
+    debug (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_raw (vec<tree, va_gc> *ptr)
+{
+  if (ptr)
+    debug_raw (*ptr);
+  else
+    fprintf (stderr, "<nil>\n");
+}
+
+DEBUG_FUNCTION void
+debug_vec_tree (vec<tree, va_gc> *vec)
+{
+  debug_raw (vec);
+}