diff mbox

[committed] PR other/65800. Fix crash in gengtype's internal debug debug dump

Message ID 56242F6E.8030603@gmail.com
State New
Headers show

Commit Message

Mikhail Maltsev Oct. 18, 2015, 11:46 p.m. UTC
Hi!

gengtype has an option '-d' which allows to dump it's internal state. I planned
to use it in order to create some kind of list of all data which GCC stores in
garbage-collected memory.

Unfortunately this option was broken. The attached patch fixes it. Because it
only affects gengtype's internal debugging option (and is also rather small), I
think it's OK to commit it without approve (as obvious).

Bootstrapped and regtested on x86_64-pc-linux-gnu.

Comments

Richard Biener Oct. 19, 2015, 9:20 a.m. UTC | #1
On Mon, Oct 19, 2015 at 1:46 AM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> Hi!
>
> gengtype has an option '-d' which allows to dump it's internal state. I planned
> to use it in order to create some kind of list of all data which GCC stores in
> garbage-collected memory.
>
> Unfortunately this option was broken. The attached patch fixes it. Because it
> only affects gengtype's internal debugging option (and is also rather small), I
> think it's OK to commit it without approve (as obvious).
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu.

Ok.

> --
> Regards,
>     Mikhail Maltsev
>
> gcc/ChangeLog:
>
> 2015-10-18  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         PR other/65800
>         * gengtype.c (dump_type): Handle TYPE_UNDEFINED correctly.
diff mbox

Patch

diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index 866d809..8c5c36d 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -4878,10 +4878,17 @@  dump_type (int indent, type_p t)
 {
   PTR *slot;
 
+  printf ("%*cType at %p: ", indent, ' ', (void *) t);
+  if (t->kind == TYPE_UNDEFINED)
+    {
+      gcc_assert (t->gc_used == GC_UNUSED);
+      printf ("undefined.\n");
+      return;
+    }
+
   if (seen_types == NULL)
     seen_types = htab_create (100, htab_hash_pointer, htab_eq_pointer, NULL);
 
-  printf ("%*cType at %p: ", indent, ' ', (void *) t);
   slot = htab_find_slot (seen_types, t, INSERT);
   if (*slot != NULL)
     {