public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: looking for the developer of tree-dump.c
       [not found] <000e01c471a9$ccfb27c0$0101010a@client>
@ 2004-07-24 19:03 ` Gabriel Dos Reis
  2004-07-26 13:38   ` Christian Ehrhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Dos Reis @ 2004-07-24 19:03 UTC (permalink / raw)
  To: d43d41u5; +Cc: gcc, gcc-bugs

"d43d41u5" <daedalus@freemail.hu> writes:

| Hi !
| 
| For some reason the -fdump-translation-unit switch doesn't dumps the body of
| the functions from the AST if I compile sources with .c extension. (there is
| no "body:" in the .tu dumpfile) Are the functions bodies in the tree, but
| not dumped, or are they stored somewhere else ?

I've come across the similar misbehaivour a week ago for mainline.  I
think it is a regression introduced by the tree-ssa merge.

It is even worse than that:  If you compile your translation unit with
g++ (from mainline), you'll still miss most (all?) function bodies,
except for member functions that are defined in their enclosing
classes.

-- Gaby


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: looking for the developer of tree-dump.c
  2004-07-24 19:03 ` looking for the developer of tree-dump.c Gabriel Dos Reis
@ 2004-07-26 13:38   ` Christian Ehrhardt
  2004-07-27  9:55     ` Gabriel Dos Reis
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Ehrhardt @ 2004-07-26 13:38 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: d43d41u5, gcc, gcc-bugs

On Sat, Jul 24, 2004 at 09:04:57PM +0200, Gabriel Dos Reis wrote:
> | For some reason the -fdump-translation-unit switch doesn't dumps the body of
> | the functions from the AST if I compile sources with .c extension. (there is
> | no "body:" in the .tu dumpfile) Are the functions bodies in the tree, but
> | not dumped, or are they stored somewhere else ?
> 
> I've come across the similar misbehaivour a week ago for mainline.  I
> think it is a regression introduced by the tree-ssa merge.

It's probably a thinko in the way dump_enabled_p works for TDI_all.
Users off dump_enabled_p expect that the function returns true if
ANY dump is enabled whereas dump_enabled_p will only return true
if ALL dumps were enabled via -fdump-tree-all.

The following ad hoc patch works for me and fixes a few other cases
where interesting things were not dumped. 

Index: tree-dump.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.27
diff -u -r1.27 tree-dump.c
--- tree-dump.c	7 Jul 2004 10:19:18 -0000	1.27
+++ tree-dump.c	26 Jul 2004 13:14:21 -0000
@@ -570,6 +590,11 @@
       dump_child ("op 2", TREE_OPERAND (t, 2));
       break;
 
+    case TRY_FINALLY_EXPR:
+      dump_child ("op 0", TREE_OPERAND (t, 0));
+      dump_child ("op 1", TREE_OPERAND (t, 1));
+      break;
+
     case CALL_EXPR:
       dump_child ("fn", TREE_OPERAND (t, 0));
       dump_child ("args", TREE_OPERAND (t, 1));
@@ -592,6 +617,10 @@
       dump_child ("cond", TREE_OPERAND (t, 0));
       break;
 
+    case RETURN_EXPR:
+      dump_child ("expr", TREE_OPERAND (t, 0));
+      break;
+
     case TARGET_EXPR:
       dump_child ("decl", TREE_OPERAND (t, 0));
       dump_child ("init", TREE_OPERAND (t, 1));
@@ -603,6 +632,29 @@
       dump_child ("init", TREE_OPERAND (t, 3));
       break;
 
+    case CASE_LABEL_EXPR:
+      dump_child ("name", CASE_LABEL (t));
+      if (CASE_LOW (t)) {
+        dump_child ("low ", CASE_LOW (t));
+	if (CASE_HIGH (t)) {
+	  dump_child ("high", CASE_HIGH (t));
+	}
+      }
+      break;
+    case LABEL_EXPR:
+      dump_child ("name", TREE_OPERAND (t,0));
+      break;
+    case GOTO_EXPR:
+      dump_child ("labl", TREE_OPERAND (t, 0));
+      break;
+    case SWITCH_EXPR:
+      dump_child ("cond", TREE_OPERAND (t, 0));
+      dump_child ("body", TREE_OPERAND (t, 1));
+      if (TREE_OPERAND (t, 2))
+        {
+      	  dump_child ("labl", TREE_OPERAND (t,2));
+        }
+      break;
     default:
       /* There are no additional fields to print.  */
       break;
@@ -789,13 +841,28 @@
   return stream;
 }
 
-/* Returns nonzero if tree dump PHASE is enabled.  */
+/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
+   TDI_all, return nonzero if any dump is enabled.  */
 
 int
 dump_enabled_p (enum tree_dump_index phase)
 {
-  struct dump_file_info *dfi = get_dump_file_info (phase);
-  return dfi->state;
+  if (phase == TDI_all)
+    {
+      size_t i;
+      for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
+	if (dump_files[i].state)
+	  return 1;
+      for (i = 0; i < extra_dump_files_in_use; i++)
+	if (extra_dump_files[i].state)
+	  return 1;
+      return 0;
+    }
+  else
+    {
+      struct dump_file_info *dfi = get_dump_file_info (phase);
+      return dfi->state;
+    }
 }
 
 /* Returns the switch name of PHASE.  */

    regards  Christian

-- 
THAT'S ALL FOLKS!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: looking for the developer of tree-dump.c
  2004-07-26 13:38   ` Christian Ehrhardt
@ 2004-07-27  9:55     ` Gabriel Dos Reis
  2004-07-28  7:41       ` [PATCH] fix -fdump-translation-unit Christian Ehrhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Dos Reis @ 2004-07-27  9:55 UTC (permalink / raw)
  To: Christian Ehrhardt; +Cc: d43d41u5, gcc, gcc-bugs, gcc-patches

Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de> writes:

| On Sat, Jul 24, 2004 at 09:04:57PM +0200, Gabriel Dos Reis wrote:
| > | For some reason the -fdump-translation-unit switch doesn't dumps the body of
| > | the functions from the AST if I compile sources with .c extension. (there is
| > | no "body:" in the .tu dumpfile) Are the functions bodies in the tree, but
| > | not dumped, or are they stored somewhere else ?
| > 
| > I've come across the similar misbehaivour a week ago for mainline.  I
| > think it is a regression introduced by the tree-ssa merge.
| 
| It's probably a thinko in the way dump_enabled_p works for TDI_all.
| Users off dump_enabled_p expect that the function returns true if
| ANY dump is enabled whereas dump_enabled_p will only return true
| if ALL dumps were enabled via -fdump-tree-all.
| 
| The following ad hoc patch works for me and fixes a few other cases
| where interesting things were not dumped. 

Thanks.  I think this should go on mainline, with appropriate
ChangeLog entries.

-- Gaby


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] fix -fdump-translation-unit
  2004-07-27  9:55     ` Gabriel Dos Reis
@ 2004-07-28  7:41       ` Christian Ehrhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Ehrhardt @ 2004-07-28  7:41 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: d43d41u5, gcc, gcc-bugs, gcc-patches


Hi,

the following patch does several things to make dumps generated
by tree-dump.c useful again. There are several problems:

* The C-frontend doesn't dump anything into *.t01.tu at all.
  This was broken by one of the C-Frontend rewrites and never
  got fixed.
* Even with other frontends most function bodies aren't dumped because
  they get discarded before the dump starts. This is due to a bug in
  dump_enabled_p.
* Some node types contain interesting information that is not dumped.
  The following patch fixes those cases that I noticed, I didn't do
  an exhaustive search for other node types that might have the same
  problem.

Bootstrapped and regtested on i686-linux-gnu. No regressions.

Is this ok without Copyright Assignment? It looks trivial enough.

	* c-decl.c (c_write_global_declarations): Dump contents of
	external scope to.
	* tree-dump.c (dequeue_and_dump): Dump abstract origin of a decl.
	<TRY_FINALLY_EXPR>, <RETURN_EXPR>, <CASE_LABEL_EXPR>, <LABEL_EXPR>,
	<GOTO_EXPR>, <SWITCH_EXPR>: Add.
	(dump_enabled_p): Return TRUE if PHASE is TDI_all and any dump
	is enabled.

Index: c-decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.547
diff -u -r1.547 c-decl.c
--- c-decl.c	26 Jul 2004 00:38:04 -0000	1.547
+++ c-decl.c	27 Jul 2004 15:34:22 -0000
@@ -6676,6 +6676,17 @@
      through wrapup_global_declarations and check_global_declarations.  */
   for (t = all_translation_units; t; t = TREE_CHAIN (t))
     c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
+  if (ext_block)
+    {
+      tree tmp = BLOCK_VARS (ext_block);
+      int flags;
+      FILE * stream = dump_begin (TDI_tu, &flags);
+      if (stream && tmp)
+        {
+          dump_node (tmp, flags & ~TDF_SLIM, stream);
+          dump_end (TDI_tu, stream);
+        }
+    }
   c_write_global_declarations_1 (BLOCK_VARS (ext_block));
 
   /* Generate functions to call static constructors and destructors
Index: tree-dump.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.29
diff -u -r1.29 tree-dump.c
--- tree-dump.c	26 Jul 2004 08:23:34 -0000	1.29
+++ tree-dump.c	27 Jul 2004 15:34:22 -0000
@@ -320,6 +320,8 @@
       if (DECL_ASSEMBLER_NAME_SET_P (t)
 	  && DECL_ASSEMBLER_NAME (t) != DECL_NAME (t))
 	dump_child ("mngl", DECL_ASSEMBLER_NAME (t));
+      if (DECL_ABSTRACT_ORIGIN (t))
+        dump_child ("orig", DECL_ABSTRACT_ORIGIN (t));
       /* And types.  */
       queue_and_dump_type (di, t);
       dump_child ("scpe", DECL_CONTEXT (t));
@@ -568,6 +570,11 @@
       dump_child ("op 2", TREE_OPERAND (t, 2));
       break;
 
+    case TRY_FINALLY_EXPR:
+      dump_child ("op 0", TREE_OPERAND (t, 0));
+      dump_child ("op 1", TREE_OPERAND (t, 1));
+      break;
+
     case CALL_EXPR:
       dump_child ("fn", TREE_OPERAND (t, 0));
       dump_child ("args", TREE_OPERAND (t, 1));
@@ -590,6 +597,10 @@
       dump_child ("cond", TREE_OPERAND (t, 0));
       break;
 
+    case RETURN_EXPR:
+      dump_child ("expr", TREE_OPERAND (t, 0));
+      break;
+
     case TARGET_EXPR:
       dump_child ("decl", TREE_OPERAND (t, 0));
       dump_child ("init", TREE_OPERAND (t, 1));
@@ -601,6 +612,29 @@
       dump_child ("init", TREE_OPERAND (t, 3));
       break;
 
+    case CASE_LABEL_EXPR:
+      dump_child ("name", CASE_LABEL (t));
+      if (CASE_LOW (t)) {
+        dump_child ("low ", CASE_LOW (t));
+	if (CASE_HIGH (t)) {
+	  dump_child ("high", CASE_HIGH (t));
+	}
+      }
+      break;
+    case LABEL_EXPR:
+      dump_child ("name", TREE_OPERAND (t,0));
+      break;
+    case GOTO_EXPR:
+      dump_child ("labl", TREE_OPERAND (t, 0));
+      break;
+    case SWITCH_EXPR:
+      dump_child ("cond", TREE_OPERAND (t, 0));
+      dump_child ("body", TREE_OPERAND (t, 1));
+      if (TREE_OPERAND (t, 2))
+        {
+      	  dump_child ("labl", TREE_OPERAND (t,2));
+        }
+      break;
     default:
       /* There are no additional fields to print.  */
       break;
@@ -787,13 +821,28 @@
   return stream;
 }
 
-/* Returns nonzero if tree dump PHASE is enabled.  */
+/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
+   TDI_all, return nonzero if any dump is enabled.  */
 
 int
 dump_enabled_p (enum tree_dump_index phase)
 {
-  struct dump_file_info *dfi = get_dump_file_info (phase);
-  return dfi->state;
+  if (phase == TDI_all)
+    {
+      size_t i;
+      for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
+	if (dump_files[i].state)
+	  return 1;
+      for (i = 0; i < extra_dump_files_in_use; i++)
+	if (extra_dump_files[i].state)
+	  return 1;
+      return 0;
+    }
+  else
+    {
+      struct dump_file_info *dfi = get_dump_file_info (phase);
+      return dfi->state;
+    }
 }
 
 /* Returns the switch name of PHASE.  */

     regards   Christian

-- 
THAT'S ALL FOLKS!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-07-28  7:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <000e01c471a9$ccfb27c0$0101010a@client>
2004-07-24 19:03 ` looking for the developer of tree-dump.c Gabriel Dos Reis
2004-07-26 13:38   ` Christian Ehrhardt
2004-07-27  9:55     ` Gabriel Dos Reis
2004-07-28  7:41       ` [PATCH] fix -fdump-translation-unit Christian Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).