[project @ 2003-08-01 14:50:48 by panne]
authorpanne <unknown>
Fri, 1 Aug 2003 14:50:50 +0000 (14:50 +0000)
committerpanne <unknown>
Fri, 1 Aug 2003 14:50:50 +0000 (14:50 +0000)
Warning police: GCC complains about built-in function `log' being used
as a non-function, so let's rename it to logFile.

ghc/utils/prof/cgprof/cgprof.c
ghc/utils/prof/cgprof/cgprof.h
ghc/utils/prof/cgprof/daVinci.c
ghc/utils/prof/cgprof/main.c
ghc/utils/prof/cgprof/symbol.c

index 878f8ae..98c8ed0 100644 (file)
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------
- * $Id: cgprof.c,v 1.2 2002/10/05 22:18:46 panne Exp $
+ * $Id: cgprof.c,v 1.3 2003/08/01 14:50:48 panne Exp $
  *                                                                     
  *     Copyright (C) 1995-2000 University of Oxford
  *                                                                     
@@ -331,7 +331,7 @@ char* StripDoubleQuotes(char* s) /* For fussy daVinci! */
 void fill_cc_matrix(cc_matrix *m,char* name,char* module,char* group,int i)
 { 
   if (i>MAX_IDENTIFIERS) 
-  {  fprintf(log,"Cost centre MAX_IDENTIFIERS exceeded: %i \n",i); exit(1); }
+  {  fprintf(logFile,"Cost centre MAX_IDENTIFIERS exceeded: %i \n",i); exit(1); }
   name = StripDoubleQuotes(name);
   strcpy((*m)[i].name,name); 
   module = StripDoubleQuotes(module);
@@ -348,13 +348,13 @@ void fill_ccs_matrix(ccs_matrix *m,int cc, int ccs, int scc, int ticks, int byte
                         /* change behaviour of type 1 (apart from CAF:REP.  */
   {
     if (i>MAX_IDENTIFIERS) 
-    {  fprintf(log,"Cost centre stack MAX_IDENTIFIERS exceeded: %i \n",i); exit(1); }
+    {  fprintf(logFile,"Cost centre stack MAX_IDENTIFIERS exceeded: %i \n",i); exit(1); }
     hsm = (*m)[i].hsm;
     (*m)[i].cc = cc; (*m)[i].ccs = ccs; 
     (*m)[i].ticks = ticks; (*m)[i].bytes = bytes; (*m)[i].scc = scc;
     (*hsm)[h_o].count = count;
   }
-  else fprintf(log,"Ignoring redeclaration of stack %i\n",i);
+  else fprintf(logFile,"Ignoring redeclaration of stack %i\n",i);
 }
 
 void add_ccs_costs(ccs_matrix *m, int b,int c,int d,int x,int y,int h_o, int co)
@@ -376,7 +376,7 @@ void add_heap_sample_costs(ccs_matrix *m, int b,int c,int d,int x,int y,int h_o,
 void add_heap_object(heap_object_matrix *m, int pos, int t, char* des, int tr)
 {
   if (pos>MAX_IDENTIFIERS) 
-  {  fprintf(log,"Heap object MAX_IDENTIFIERS exceeded: %i \n",pos); exit(1); }
+  {  fprintf(logFile,"Heap object MAX_IDENTIFIERS exceeded: %i \n",pos); exit(1); }
   (*m)[pos].type = t;
   strcpy((*m)[pos].descriptor,des);
   (*m)[pos].type_constr_ref = tr;
@@ -385,7 +385,7 @@ void add_heap_object(heap_object_matrix *m, int pos, int t, char* des, int tr)
 void add_type_constr_object(type_constr_matrix *m, int pos, char* mod, char* n)
 {
   if (pos>MAX_IDENTIFIERS) 
-  {  fprintf(log,"Type constructor MAX_IDENTIFIERS exceeded: %i \n",pos); exit(1); }
+  {  fprintf(logFile,"Type constructor MAX_IDENTIFIERS exceeded: %i \n",pos); exit(1); }
   strcpy((*m)[pos].module,mod);
   strcpy((*m)[pos].name,n);
 }
@@ -396,23 +396,23 @@ void add_type_constr_object(type_constr_matrix *m, int pos, char* mod, char* n)
 void print_heap_update_list(heap_update_list *m, int number)
 {
   int i;
-  fprintf(log,"[");
+  fprintf(logFile,"[");
   for (i=0; i<number;i++)
   {
-    fprintf(log," (%i,%i,%i) ",(*m)[i].ccs,(*m)[i].ho,(*m)[i].count);
+    fprintf(logFile," (%i,%i,%i) ",(*m)[i].ccs,(*m)[i].ho,(*m)[i].count);
   }
-  fprintf(log,"]\n");
+  fprintf(logFile,"]\n");
 }
 
 void print_TheHeap(TheHeap *h)
 {
   int i;
-  fprintf(log,"The Heap\n========\n");
+  fprintf(logFile,"The Heap\n========\n");
   for (i=0; i<MAX_TIME;i++)
   {
     if ((*h)[i].no_samples>0)
     {
-      fprintf(log,"Sample time %i, number of samples %i actual samples "
+      fprintf(logFile,"Sample time %i, number of samples %i actual samples "
                  ,i,(*h)[i].no_samples);
       print_heap_update_list((*h)[i].acc_samples,(*h)[i].no_samples);
     }
@@ -459,12 +459,12 @@ void print_cc_matrix(cc_matrix *m)
 { 
   int i;
   char *blank="blank";
-  fprintf(log,"Cost centre matrix\n");
-  fprintf(log,"==================\n");
+  fprintf(logFile,"Cost centre matrix\n");
+  fprintf(logFile,"==================\n");
   for (i=0; i<MAX_IDENTIFIERS; i++)
     { if (strcmp((*m)[i].name,blank)!=0) 
-         fprintf(log,"%s %s %s\n",(*m)[i].name,(*m)[i].module,(*m)[i].group); }
-  fprintf(log,"\n");
+         fprintf(logFile,"%s %s %s\n",(*m)[i].name,(*m)[i].module,(*m)[i].group); }
+  fprintf(logFile,"\n");
 }
 
 void print_heap_object_matrix(FILE* hfp, TheHeap *h, heap_object_matrix *m)
@@ -547,39 +547,39 @@ void print_type_constr_matrix(type_constr_matrix *m)
 {
   int i;
   char *blank="blank";
-  fprintf(log,"Type constructor matrix\n");
-  fprintf(log,"=======================\n");
+  fprintf(logFile,"Type constructor matrix\n");
+  fprintf(logFile,"=======================\n");
   for (i=0; i<MAX_IDENTIFIERS; i++)
   {
     if (strcmp((*m)[i].name,blank)!=0)
-         fprintf(log,"%i %s %s\n",i,(*m)[i].module,(*m)[i].name);
+         fprintf(logFile,"%i %s %s\n",i,(*m)[i].module,(*m)[i].name);
   }
 }
 
 void print_heap_sample_matrix(heap_sample_matrix *m)
 {
   int i;
-  fprintf(log,"HeapSamples[");
+  fprintf(logFile,"HeapSamples[");
   for (i=0; i<MAX_IDENTIFIERS; i++)
   {
-    if ((*m)[i].count!=-1) fprintf(log,"(%i,%i),",i,(*m)[i].count);
+    if ((*m)[i].count!=-1) fprintf(logFile,"(%i,%i),",i,(*m)[i].count);
   }
-  fprintf(log,"]\n");
+  fprintf(logFile,"]\n");
 }
 
 void print_ccs_matrix(ccs_matrix *m)
 { 
   int i;
-  fprintf(log,"Cost centre stack matrix\n");
-  fprintf(log,"========================\n");
+  fprintf(logFile,"Cost centre stack matrix\n");
+  fprintf(logFile,"========================\n");
   for (i=0; i<MAX_IDENTIFIERS; i++)
   {  if ((*m)[i].cc!=0)
      {
-       fprintf(log,"%i %i %i %i %i \n",(*m)[i].cc,(*m)[i].ccs,(*m)[i].scc,
+       fprintf(logFile,"%i %i %i %i %i \n",(*m)[i].cc,(*m)[i].ccs,(*m)[i].scc,
                                (*m)[i].ticks,(*m)[i].bytes); 
      } 
   }
-  fprintf(log,"\n");
+  fprintf(logFile,"\n");
 }
 
 
@@ -599,7 +599,7 @@ void FormStack(ccs_matrix *m, cc_matrix *n, int i, char s[])
       j = (*m)[j].ccs;
     }
   }
-  else fprintf(log,"ERROR: Form Stack %i\n",i);
+  else fprintf(logFile,"ERROR: Form Stack %i\n",i);
 }
 
 /* This version, which is used, adds the module and group name to the cost centre name*/
@@ -629,7 +629,7 @@ void FormStack2(ccs_matrix *m, cc_matrix *n, int i, char s[])
       j = (*m)[j].ccs;
     }
   }
-  else fprintf(log,"ERROR: Form Stack %i\n",i);
+  else fprintf(logFile,"ERROR: Form Stack %i\n",i);
 }
 
 void PrintStack(ccs_matrix *m, cc_matrix *n, int i)
@@ -638,20 +638,20 @@ void PrintStack(ccs_matrix *m, cc_matrix *n, int i)
   int j = i;
   if ((*m)[j].cc != 0)
   {
-    fprintf(log,"<"); 
-    fprintf(log,"%s,",(*n)[(*m)[j].cc].name);
+    fprintf(logFile,"<"); 
+    fprintf(logFile,"%s,",(*n)[(*m)[j].cc].name);
     while ((*m)[j].ccs != (-1))
     {
-      fprintf(log,"%s,",(*n)[(*m)[(*m)[j].ccs].cc].name);
+      fprintf(logFile,"%s,",(*n)[(*m)[(*m)[j].ccs].cc].name);
       j = (*m)[j].ccs;
     }
-    fprintf(log,"> ");
-    fprintf(log,"%i scc %i ticks %i bytes  ",
+    fprintf(logFile,"> ");
+    fprintf(logFile,"%i scc %i ticks %i bytes  ",
             (*m)[i].scc,(*m)[i].ticks,(*m)[i].bytes);
     print_heap_sample_matrix((*m)[i].hsm);
   }
   else
-  { /* fprintf(log,"empty stack\n"); */ }
+  { /* fprintf(logFile,"empty stack\n"); */ }
 }
 
 int CountStacks(ccs_matrix *m)
@@ -665,7 +665,7 @@ int CountStacks(ccs_matrix *m)
 void PrintAllStacks(ccs_matrix *m, cc_matrix *n)
 {
   int i;
-  fprintf(log,"Stacks\n======\n");
+  fprintf(logFile,"Stacks\n======\n");
   for (i=0;i<MAX_IDENTIFIERS;i++) { PrintStack(m,n,i); }
 }
 
@@ -839,8 +839,8 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
 
   /* End of GHC specific variables */
 
-  //fprintf(log,"Number 1 %i \n",MAX_IDENTIFIERS*sizeof(_cc_));
-  //fprintf(log,"Number 2 %i \n",sizeof(cc_matrix));
+  //fprintf(logFile,"Number 1 %i \n",MAX_IDENTIFIERS*sizeof(_cc_));
+  //fprintf(logFile,"Number 2 %i \n",sizeof(cc_matrix));
 
   nolines=0; /* Number of lines read in from profile log file */
 
@@ -854,7 +854,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
   initialise_type_constr_matrix(tc_m);
   initialise_TheHeap(th);
 
-  fprintf(log,"MAX_IDENTIFIERS = %i \n",MAX_IDENTIFIERS);
+  fprintf(logFile,"MAX_IDENTIFIERS = %i \n",MAX_IDENTIFIERS);
   
   /* end GHC specific */
 
@@ -887,8 +887,8 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
       //while (fscanf(fp," %i %[^ ] %[^ ] %s", &z, e, f, g)!=0)
       while (fscanf(fp," %i %[^ ] %s", &z, e, f)!=0)
       {
-        fprintf(log,"Declaring cost centre `%i %s %s %s' \n",z,e,f,f);
-        fflush(log);
+        fprintf(logFile,"Declaring cost centre `%i %s %s %s' \n",z,e,f,f);
+        fflush(logFile);
         fill_cc_matrix(cc_m,e,f,f,z);
         next = fgetc(fp);
       }
@@ -904,7 +904,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
         {
           if (d==1) /* of size one */
           {  
-            fprintf(log,"Declaring cost centre stack `%i %i %i'\n",a,d,b);
+            fprintf(logFile,"Declaring cost centre stack `%i %i %i'\n",a,d,b);
             fill_ccs_matrix(ccs_m,b,-1,(*ccs_m)[a].scc,(*ccs_m)[a].ticks,(*ccs_m)[a].bytes,0,-1,a);
           }
           if (d==2) /* of size > 1 */
@@ -912,7 +912,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
             fscanf(fp," %i",&c);
 
             /* CAF fixing */
-            fprintf(log,"Declaring cost centre stack `%i %i %i %i'\n",a,d,b,c);
+            fprintf(logFile,"Declaring cost centre stack `%i %i %i %i'\n",a,d,b,c);
             if ((c==1)&&!(strncmp((*cc_m)[b].name,"CAF",2)))
                // fill_ccs_matrix(ccs_m,b,MAX_IDENTIFIERS-1,(*ccs_m)[a].scc,(*ccs_m)[a].ticks,(*ccs_m)[a].bytes,0,-1,a);
                /* The line above hangs all CAFs off the CAF:REPOSITORY node
@@ -956,7 +956,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
           next = fgetc(fp);
           while (fscanf(fp,"%i %i %i %i",&a,&d,&b,&c))
           {
-            fprintf(log,"Loading scc_samples `%i %i %i %i'\n",a,d,b,c);
+            fprintf(logFile,"Loading scc_samples `%i %i %i %i'\n",a,d,b,c);
             add_ccs_costs(ccs_m,0,a,d,b,c,0,0);
             next = fgetc(fp);
           }
@@ -970,7 +970,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
             next = fgetc(fp);
             while (fscanf(fp,"%i %i %i",&a,&d,&b))
             {
-              fprintf(log,"Loading heap_samples `%i %i %i'\n",a,d,b);
+              fprintf(logFile,"Loading heap_samples `%i %i %i'\n",a,d,b);
               add_heap_sample_costs(ccs_m,0,a,0,0,0,d,b);
               next = fgetc(fp);
             }
@@ -1020,12 +1020,12 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
                   while (fscanf(fp,"%i %i %i %i %i %i",&a,&d,&b,&c,&z,&x))
                   {
                     add_to_TheHeap(th,a,b,c,z);
-                    fprintf(log,"Adding heap sample %i %i %i %i\n",a,b,c,z);
+                    fprintf(logFile,"Adding heap sample %i %i %i %i\n",a,b,c,z);
                     while (x) /* more than one sample */
                     {
                       fscanf(fp," %i %i %i %i",&b,&c,&z,&x);
                       add_to_TheHeap(th,a,b,c,z);
-                      fprintf(log,"Adding heap sample %i %i %i %i\n",a,b,c,z);
+                      fprintf(logFile,"Adding heap sample %i %i %i %i\n",a,b,c,z);
                     }  
                     next = fgetc(fp);
                   }
@@ -1044,18 +1044,18 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
 
    print_cc_matrix(cc_m);
    print_ccs_matrix(ccs_m);
-   fprintf(log,"There are %i stacks\n",CountStacks(ccs_m));
+   fprintf(logFile,"There are %i stacks\n",CountStacks(ccs_m));
    print_type_constr_matrix(tc_m);
 
    /* Functions for heap profile */
    print_TheHeap(th);
-   fprintf(log,"The units for the x axis are \n");
-   PrintXaxis(log,th);
-   fprintf(log,"\n");
-   fprintf(log,"There are %i distinct heap objects\n",number_of_heap_objects(ho_m));
-   names_of_heap_objects(log,ho_m);
-   names_and_colour_assignment(log,ho_m);
-   print_heap_object_matrix(log,th,ho_m);
+   fprintf(logFile,"The units for the x axis are \n");
+   PrintXaxis(logFile,th);
+   fprintf(logFile,"\n");
+   fprintf(logFile,"There are %i distinct heap objects\n",number_of_heap_objects(ho_m));
+   names_of_heap_objects(logFile,ho_m);
+   names_and_colour_assignment(logFile,ho_m);
+   print_heap_object_matrix(logFile,th,ho_m);
 
    PrintAllStacks(ccs_m,cc_m);
    /* comment out line below to remove the heap profile generator */
@@ -1117,11 +1117,11 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
         exit(1);
       }
 
-      fprintf(log,"STACK=\"%s\"\n",stack);
+      fprintf(logFile,"STACK=\"%s\"\n",stack);
       raw_profile[raw_profile_next].stack_size=1;
       /* move the stack read frame to the first space (or comma) in the stack string */ 
       for(ptr=stack; ((*ptr)!=' ') && (*ptr!=',');ptr++) {}
-      fprintf(log,"TOS=%d at line %d\n",*ptr,sstepline);
+      fprintf(logFile,"TOS=%d at line %d\n",*ptr,sstepline);
      
       /* to distinguish the head of the stack from the rest */
       /* if read frame points to space you are at the head of the stack */
@@ -1144,7 +1144,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
       for(;*ptr;ptr++) { /* find the next element in the stack */
         if (*ptr==',') {
          *ptr='\0';
-          if (Verbose) fprintf(log,"NAME=\"%s\"\n",drag); /* name of the next element */
+          if (Verbose) fprintf(logFile,"NAME=\"%s\"\n",drag); /* name of the next element */
           if (!ignore_function(drag)) {
             raw_profile[raw_profile_next].stack[
               raw_profile[raw_profile_next].stack_size++]
@@ -1183,7 +1183,7 @@ void readRawProfile(FILE *fp,int *nonodes, int MaxNoNodes) {
   } /* end of new for loop */
 
   *nonodes = symbol_table_next;
-  fprintf(log,"%s: read %d lines from profile.Graph contains %i nodes.\n",
+  fprintf(logFile,"%s: read %d lines from profile.Graph contains %i nodes.\n",
           Pgm,nolines,symbol_table_next);
 
   free_cc_matrix(cc_m); /* be nice and clean up the cost centre matrix */
@@ -1198,14 +1198,14 @@ void printRawProfile() {
   object_cost *cost;
   int         *stack;
   
-  fprintf(log,"\n\nRAW DATA:\n");
+  fprintf(logFile,"\n\nRAW DATA:\n");
   for(i=0;i<raw_profile_next;i++) {
     cost  = &raw_profile[i].cost;
     stack = raw_profile[i].stack;
-    fprintf(log,"Stack=[");
+    fprintf(logFile,"Stack=[");
     for(j=0;j<raw_profile[i].stack_size;j++) 
       printSymbolTable_entry(stack[j]);
-    fprintf(log,"] %d Syncs %f Comp %f Comm %f Wait\n\n",
+    fprintf(logFile,"] %d Syncs %f Comp %f Comm %f Wait\n\n",
            cost->syncs,cost->comp_max,cost->comm_max,cost->comp_idle_max);
   }
 }
@@ -1279,15 +1279,15 @@ void printConnectivityMatrix(Matrix graph,Matrix costs,int root) {
   int i,j;
   object_cost cost;
 
-  fprintf(log,"Root node is %d\n",root);
+  fprintf(logFile,"Root node is %d\n",root);
   for(i=0;i<graph.rows;i++) {
-    fprintf(log,"%4d)",i);
+    fprintf(logFile,"%4d)",i);
     printSymbolTable_entry(i);
     cost = Mat(object_cost,costs,i,0);
-    fprintf(log,"%d %f %f %f\n\tBranch=[",
+    fprintf(logFile,"%d %f %f %f\n\tBranch=[",
            cost.syncs,cost.comp_max,cost.comm_max,cost.comp_idle_max);
     for(j=0;j<graph.cols;j++) 
-      if (Mat_dense(graph,i,j)) fprintf(log,"%d ",j);
-    fprintf(log,"]\n\n");
+      if (Mat_dense(graph,i,j)) fprintf(logFile,"%d ",j);
+    fprintf(logFile,"]\n\n");
   }
 }
index 84cbb54..e93f02b 100644 (file)
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------
- * $Id: cgprof.h,v 1.1 2000/04/05 10:06:36 simonmar Exp $
+ * $Id: cgprof.h,v 1.2 2003/08/01 14:50:50 panne Exp $
  *                                                                     
  *     Copyright (C) 1995-2000 University of Oxford
  *                                                                     
@@ -78,5 +78,5 @@ extern void printRawProfile();
 extern void add_costs(object_cost *,object_cost);
 extern void createConnectivityMatrix(int,Matrix *,Matrix *,int *,int);
 extern void printConnectivityMatrix(Matrix,Matrix,int);
-extern FILE* log;
+extern FILE* logFile;
 #endif
index 667a270..fc30b6b 100644 (file)
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------
- * $Id: daVinci.c,v 1.1 2000/04/05 10:06:36 simonmar Exp $
+ * $Id: daVinci.c,v 1.2 2003/08/01 14:50:50 panne Exp $
  *                                                                     
  *     Copyright (C) 1995-2000 University of Oxford
  *                                                                     
@@ -507,7 +507,7 @@ static void recur_graphToDaVinci(int node,Matrix *graph,Matrix *costs,char* p_ze
       if (mode==1)
       {
       if ((ptr->comm_max+ptr->comp_idle_max+ptr->comp_max) <= 0.0)
-          { fprintf(log,"Node %d %s is a candidate for deletion\n",node, node_str);
+          { fprintf(logFile,"Node %d %s is a candidate for deletion\n",node, node_str);
             sprintf(tempnode,"\"%d\",",node);
             strcat(p_zeronodes,tempnode);
           }
@@ -536,7 +536,7 @@ static void recur_graphToDaVinci_old(int node,Matrix *graph, Matrix *costs) {
   int i,j,no_children=0,*children,colour,small;
   char line[MAX_FUNNAME], *node_str;
   if (Mat(int,*graph,node,node)<0) {
-    fprintf(log,"r(\"%d\") ",node);
+    fprintf(logFile,"r(\"%d\") ",node);
     printf("r(\"%d\") ",node);
   } else {
     for(i=0;i<graph->cols;i++) 
@@ -558,9 +558,9 @@ static void recur_graphToDaVinci_old(int node,Matrix *graph, Matrix *costs) {
     node_str=(NodeviewCompress)?
                printCompressNode(node,ptr):
                printUncompressNode(node,ptr);
-    fprintf(log,"l(\"%d\",n(\"\",[a(\"OBJECT\",\"%s\"),",node,node_str);
+    fprintf(logFile,"l(\"%d\",n(\"\",[a(\"OBJECT\",\"%s\"),",node,node_str);
     printf("l(\"%d\",n(\"\",[a(\"OBJECT\",\"%s\"),",node,node_str);
-    fprintf(log,"a(\"FONTFAMILY\",\"courier\"),");
+    fprintf(logFile,"a(\"FONTFAMILY\",\"courier\"),");
     printf("a(\"FONTFAMILY\",\"courier\"),");
     if (symbol_table[node].type==CG_SSTEP)
       printf("a(\"BORDER\",\"double\"),");
@@ -577,27 +577,27 @@ static void recur_graphToDaVinci_old(int node,Matrix *graph, Matrix *costs) {
 
     colour=percentToColour(1.0-nodeColour(ptr));
     //if (!small) 
-       fprintf(log,"a(\"COLOR\",\"#ff%.2x%.2x\")",colour,colour);
+       fprintf(logFile,"a(\"COLOR\",\"#ff%.2x%.2x\")",colour,colour);
        printf("a(\"COLOR\",\"#ff%.2x%.2x\")",colour,colour);
     //else 
     //   printf("a(\"COLOR\",\"yellow\"),"); 
-    fprintf(log,"],[");
+    fprintf(logFile,"],[");
     printf("],[");
     Mat(int,*graph,node,node)=-1;
     for(i=0;i<no_children;i++) {
 
       //if (!small) 
-           fprintf(log,"e(\"%d->%d\",[],",node,children[i]);
+           fprintf(logFile,"e(\"%d->%d\",[],",node,children[i]);
            printf("e(\"%d->%d\",[],",node,children[i]);
       //else 
       //     printf("e(\"%d->%d\",[a(\"EDGECOLOR\",\"yellow\")],",node,children[i]);
  
       recur_graphToDaVinci_old(children[i],graph,costs);
-      fprintf(log,")");
+      fprintf(logFile,")");
       printf(")");
-      if (i<(no_children-1)) {fprintf(log,","); printf(",");}
+      if (i<(no_children-1)) {fprintf(logFile,","); printf(",");}
     } 
-    fprintf(log,"]))");
+    fprintf(logFile,"]))");
     printf("]))");
   } 
 }
@@ -642,7 +642,7 @@ davinciCmd parseDaVinciCmd(char *input) {
 
   crp=input;
   word = parse_word(&crp);
-  if (Verbose) fprintf(log,"{parseDaVinciCmd}=%s size=%d\n",word,result.size);
+  if (Verbose) fprintf(logFile,"{parseDaVinciCmd}=%s size=%d\n",word,result.size);
   if        (strcmp(word,"node_selections_labels")==0) {
     result.type=DAVINCI_NODE;
     result.list =calloc(result.size,sizeof(char*));
@@ -715,7 +715,7 @@ static char* extra_space(int x) {
   static char space[MAX_FUNNAME+1];
   int i;
 
-  if (Verbose) fprintf(log,"Padding is %d\n",x);
+  if (Verbose) fprintf(logFile,"Padding is %d\n",x);
   for(i=0;(i<x)&&(i<MAX_FUNNAME);i++) space[i]=' ';
   space[i]='\0';
   return space;
index 2a276fb..ce3c0de 100644 (file)
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------
- * $Id: main.c,v 1.1 2000/04/05 10:06:36 simonmar Exp $
+ * $Id: main.c,v 1.2 2003/08/01 14:50:50 panne Exp $
  *                                                                     
  *     Copyright (C) 1995-2000 University of Oxford
  *                                                                     
@@ -65,7 +65,7 @@ double bsp_l = 1902;
 double bsp_g = 9.3;
 int    bsp_p;
 
-FILE *log;
+FILE *logFile;
 
 
 extern void printDaVinci(int);
@@ -121,7 +121,7 @@ main(int argc, char *argv[]) {
             Pgm,ProfileData,usage);
     exit(1);
   }
-  if (!(log=fopen("ghcprof.log","w"))) {
+  if (!(logFile=fopen("ghcprof.log","w"))) {
     fprintf(stderr,"%s: unable to open log file for writing\n",Pgm);
     exit(1);
   }
@@ -141,13 +141,13 @@ main(int argc, char *argv[]) {
   
   /* printf("Ending initialisation of daVinci\n"); */
  
-  if (Verbose) fprintf(log,"%s: opened profile file \"%s\".\n",Pgm,ProfileData);
+  if (Verbose) fprintf(logFile,"%s: opened profile file \"%s\".\n",Pgm,ProfileData);
   readRawProfile(fptr,&NoNodes,MaxNoNodes);
   fclose(fptr);
-  if (Verbose) fprintf(log,"%s: %d nodes in profile.\n",Pgm,NoNodes);
+  if (Verbose) fprintf(logFile,"%s: %d nodes in profile.\n",Pgm,NoNodes);
 
   if (NoNodes<=0) {
-    fprintf(log,"%s: no call-graph profile data in \"%s\".\n"
+    fprintf(logFile,"%s: no call-graph profile data in \"%s\".\n"
             "Re-run your program using the appropriate profiling flags\n",
             Pgm,ProfileData);
     exit(1);
@@ -163,7 +163,7 @@ main(int argc, char *argv[]) {
   TotalH        = Mat(object_cost,costs,root,0).hrel_max;
   TotalSyncs    = Mat(object_cost,costs,root,0).syncs;
   if (Verbose) printConnectivityMatrix(graph,costs,root);
-  fflush(log);
+  fflush(logFile);
   graphToDaVinci(root,&graph,&costs,0);
   fflush(stdout);
   undo_stack   = calloc(NoDeletes,sizeof(int));
@@ -181,7 +181,7 @@ main(int argc, char *argv[]) {
   select_nodes[0]=root;
   while (fgets(davinci_stdin, MAX_PROFILE_LINE_LENGTH, stdin) && going) {
     cmd = parseDaVinciCmd(davinci_stdin);
-    if (Verbose) fprintf(log,"From davinci=\"%s\"\n",davinci_stdin);
+    if (Verbose) fprintf(logFile,"From davinci=\"%s\"\n",davinci_stdin);
     switch (cmd.type) {
     case DAVINCI_OK:
       continue;
@@ -423,7 +423,7 @@ main(int argc, char *argv[]) {
       break;
     }
     fflush(stdout);
-    fflush(log);
+    fflush(logFile);
   }  
 
   return 0;
index 3a47d21..133f59b 100644 (file)
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------------
- * $Id: symbol.c,v 1.2 2001/07/24 06:01:21 ken Exp $
+ * $Id: symbol.c,v 1.3 2003/08/01 14:50:50 panne Exp $
  *                                                                     
  *     Copyright (C) 1995-2000 University of Oxford
  *                                                                     
@@ -55,7 +55,7 @@ void enlargeSymbolTable() {
 
 name_id lookupSymbolTable(int type,int lineno,char* str) {
   int i;
-  extern FILE *log;
+  extern FILE *logFile;
 
   for(i=0;i<symbol_table_next;i++) {
     if ((type==symbol_table[i].type) && 
@@ -64,7 +64,7 @@ name_id lookupSymbolTable(int type,int lineno,char* str) {
       return i;
     }
   }
-  fprintf(log,"{lookupSymbolTable} %d at %s line %d\n",type,str,lineno);
+  fprintf(logFile,"{lookupSymbolTable} %d at %s line %d\n",type,str,lineno);
   if (symbol_table_next==symbol_table_size) enlargeSymbolTable();
   symbol_table[symbol_table_next].type    = type;
   symbol_table[symbol_table_next].lineno  = lineno;
@@ -100,12 +100,12 @@ int cmp_symbol_entry(const int *x, const int *y) {
  * -------------------------------------------------------------------------- */
 
 void printSymbolTable_entry(int idx) {
-  extern FILE *log;
+  extern FILE *logFile;
   if (symbol_table[idx].type==CG_SSTEP) {
-    fprintf(log,"(line %d of %s) ",symbol_table[idx].lineno,
+    fprintf(logFile,"(line %d of %s) ",symbol_table[idx].lineno,
                                      symbol_table[idx].filename);
   } else {
-    fprintf(log,"%s ",symbol_table[idx].filename);
+    fprintf(logFile,"%s ",symbol_table[idx].filename);
   }
 }