Hello,

When we use fdump-tree-all, we get the dump file, however there is no way to know in which order the pass was executed. We can use gdb with a breakpoint at the good position (something like execute_one_pass), however this solution is not satisfiying for plugin devellopers for exemple. There is a number in the name of the dumpped file but from what I know it is a static number related to the pass but it has nothing to do with the order in which it is executed.

I would enjoy to have a number, giving the pass position, something like :

1.cfile.c.XXXt.pass

I have make a small change in tree-dump.c in order to have this working with -fdump-tree-all (patch file in attachment)

The drawback is that, as the pass is called for each function, we get a different file for each function, while it was written in the same file previously.


I am also surprized to see that the function print_current_pass is only called on a fail and that debug_pass doesn't appear to be called at all. Maybe in DEBUG, or at least with an f*_dump_all, we could print the order of the pass.

thanks

Pierre Vittet
Index: gcc/tree-dump.c
===================================================================
--- gcc/tree-dump.c     (revision 171340)
+++ gcc/tree-dump.c     (working copy)
@@ -925,21 +925,35 @@
   struct dump_file_info *dfi;
   FILE *stream;
 
+  /*allow to know how many pass have already been explored*/
+  static int nb_explored_pass = 0;
+  /*add to the name a position at which the pass is explored*/
+  char * name_with_pass_pos;    
+  int name_with_pass_pos_size;
+ 
   if (phase == TDI_none || !dump_enabled_p (phase))
     return NULL;
 
   name = get_dump_file_name (phase);
+  name_with_pass_pos_size=sizeof(char)*strlen(name)+ 
sizeof(nb_explored_pass)+1;
+  name_with_pass_pos= (char*) xmalloc(name_with_pass_pos_size);
+
+  snprintf (name_with_pass_pos, name_with_pass_pos_size, "%d.%s", 
nb_explored_pass, name);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
+  stream = fopen (name_with_pass_pos, dfi->state < 0 ? "w" : "a");
+
   if (!stream)
     error ("could not open dump file %qs: %m", name);
   else
     dfi->state = 1;
   free (name);
+  free (name_with_pass_pos);
 
   if (flag_ptr)
     *flag_ptr = dfi->flags;
 
+  nb_explored_pass++;
+
   return stream;
 }
 

Reply via email to