gdbhooks.py (TreePrinter.to_string): Recognize ggc_free'd memory.
authorJason Merrill <jason@redhat.com>
Tue, 11 Jun 2019 12:40:08 +0000 (08:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 11 Jun 2019 12:40:08 +0000 (08:40 -0400)
* gdbhooks.py (TreePrinter.to_string): Recognize ggc_free'd memory.

* tree.c (get_tree_code_name): Likewise.
* print-tree.c (print_node): Only briefly print a node with an
invalid code.

From-SVN: r272150

gcc/ChangeLog
gcc/gdbhooks.py
gcc/print-tree.c
gcc/tree.c

index 66e45395da8eb34a0685040e21051d84796e0470..f115982cf1d7f0c30a2a69fa0a878cf17e43c7a7 100644 (file)
@@ -1,3 +1,10 @@
+2019-06-11  Jason Merrill  <jason@redhat.com>
+
+       * gdbhooks.py (TreePrinter.to_string): Recognize ggc_free'd memory.
+       * tree.c (get_tree_code_name): Likewise.
+       * print-tree.c (print_node): Only briefly print a node with an
+       invalid code.
+
 2019-06-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/90819
index 39f5c4772f95f5920e1ac1f31b4288ed0651eff3..e08208e1533667cf55f131d80d1e854d0cf3f292 100644 (file)
@@ -222,6 +222,9 @@ class TreePrinter:
         # extern const enum tree_code_class tree_code_type[];
         # #define TREE_CODE_CLASS(CODE)        tree_code_type[(int) (CODE)]
 
+        if val_TREE_CODE == 0xa5a5:
+            return '<ggc_freed 0x%x>' % intptr(self.gdbval)
+
         val_tree_code_type = gdb.parse_and_eval('tree_code_type')
         val_tclass = val_tree_code_type[val_TREE_CODE]
 
index 81b66a1891b8063881d731098fcd0c1af7caeda7..f69a2c2667998c3649cb3b38af482611b63d4197 100644 (file)
@@ -233,6 +233,15 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
     return;
 
   code = TREE_CODE (node);
+
+  /* It is unsafe to look at any other fields of a node with ERROR_MARK or
+     invalid code.  */
+  if (code == ERROR_MARK || code >= MAX_TREE_CODES)
+    {
+      print_node_brief (file, prefix, node, indent);
+      return;
+    }
+
   tclass = TREE_CODE_CLASS (code);
 
   /* Don't get too deep in nesting.  If the user wants to see deeper,
@@ -251,13 +260,6 @@ print_node (FILE *file, const char *prefix, tree node, int indent,
       return;
     }
 
-  /* It is unsafe to look at any other fields of an ERROR_MARK node.  */
-  if (code == ERROR_MARK)
-    {
-      print_node_brief (file, prefix, node, indent);
-      return;
-    }
-
   /* Allow this function to be called if the table is not there.  */
   if (table)
     {
index 5d955535accd8f3681dac9dc35747c7ad0fe2cb9..e879f15a841d26de994c6c94402eaf40963b0d8e 100644 (file)
@@ -13450,7 +13450,11 @@ get_tree_code_name (enum tree_code code)
   const char *invalid = "<invalid tree code>";
 
   if (code >= MAX_TREE_CODES)
-    return invalid;
+    {
+      if (code == 0xa5a5)
+       return "ggc_freed";
+      return invalid;
+    }
 
   return tree_code_name[code];
 }