This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA (print-tree): PATCH for printing VEC(tree) in gdb
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 27 May 2010 12:39:32 -0400
- Subject: RFA (print-tree): PATCH for printing VEC(tree) in gdb
This patch adds a 'pvt' command to GDB for printing VEC(tree,...)* so
that I don't have to keep writing $.base.vec[0].
It also adds a 'pdd' command for dwarf2out DIE nodes which I've had
locally for a while.
Finally, it changes handling of TREE_VEC to print fully (depending on
indentation level) elements of the vector; I find the current behavior
inconvenient, as the brief representation is almost never enough
information.
OK for trunk?
commit 03c534b28302c1f13d9626404ebb173e86d10a8b
Author: Jason Merrill <jason@redhat.com>
Date: Mon May 24 11:51:07 2010 -0400
* print-tree.c (debug_vec_tree): New fn.
(print_vec_tree): New fn.
* tree.h: Declare them.
* gdbinit.in (ptv): New command.
* print-tree.c (print_node) [TREE_VEC]: Print elements normally.
* gdbinit.in (pdd): New command.
diff --git a/gcc/gdbinit.in b/gcc/gdbinit.in
index 22c99a7..e2375b2 100644
--- a/gcc/gdbinit.in
+++ b/gcc/gdbinit.in
@@ -122,6 +122,22 @@ document ptn
Print the name of the type-node that is $.
end
+define pvt
+set debug_vec_tree ($)
+end
+
+document pvt
+Print the VEC(tree) that is in $.
+end
+
+define pdd
+set debug_dwarf_die ($)
+end
+
+document pdd
+Print the dw_die_ref that is in $.
+end
+
define prc
output (enum rtx_code) $.code
echo \ (
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index f1a2455..0c23188 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -60,6 +60,20 @@ debug_tree (tree node)
putc ('\n', stderr);
}
+/* 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. */
+
+void
+debug_vec_tree (VEC(tree,gc) *vec)
+{
+ table = XCNEWVEC (struct bucket *, HASH_SIZE);
+ print_vec_tree (stderr, "", vec, 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)
@@ -860,8 +874,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;
@@ -979,3 +992,27 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
fprintf (file, ">");
}
+
+/* Print the tree vector VEC in full on file FILE, preceded by PREFIX,
+ starting in column INDENT. */
+
+void
+print_vec_tree (FILE *file, const char *prefix, VEC(tree,gc) *vec, int indent)
+{
+ tree elt;
+ unsigned ix;
+
+ /* Indent to the specified column, since this is the long form. */
+ indent_to (file, indent);
+
+ /* Print the slot this node is in, and its code, and address. */
+ fprintf (file, "%s <VEC", prefix);
+ dump_addr (file, " ", vec);
+
+ for (ix = 0; VEC_iterate (tree, vec, ix, elt); ++ix)
+ {
+ char temp[10];
+ sprintf (temp, "elt %d", ix);
+ print_node (file, temp, elt, indent + 4);
+ }
+}
diff --git a/gcc/tree.h b/gcc/tree.h
index 5f0098c..5acadb4 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5120,9 +5120,11 @@ extern void print_rtl (FILE *, const_rtx);
/* In print-tree.c */
extern void debug_tree (tree);
+extern void debug_vec_tree (VEC(tree,gc) *);
#ifdef BUFSIZ
extern void dump_addr (FILE*, const char *, const void *);
extern void print_node (FILE *, const char *, tree, int);
+extern void print_vec_tree (FILE *, const char *, VEC(tree,gc) *, int);
extern void print_node_brief (FILE *, const char *, const_tree, int);
extern void indent_to (FILE *, int);
#endif