1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2000
5 * Support for profiling
7 * ---------------------------------------------------------------------------*/
11 #include "PosixSource.h"
15 #include "Profiling.h"
16 #include "Proftimer.h"
19 #include "RetainerProfile.h"
28 * Profiling allocation arena.
33 * Global variables used to assign unique IDs to cc's, ccs's, and
41 /* figures for the profiling report.
43 static ullong total_alloc;
44 static lnat total_prof_ticks;
46 /* Globals for opening the profiling log file(s)
48 static char *prof_filename; /* prof report file name = <program>.prof */
51 static char *hp_filename; /* heap profile (hp2ps style) log file */
54 /* The Current Cost Centre Stack (for attributing costs)
56 CostCentreStack *CCCS;
58 /* Linked lists to keep track of cc's and ccs's that haven't
59 * been declared in the log file yet
62 CostCentreStack *CCS_LIST;
65 * Built-in cost centres and cost-centre stacks:
67 * MAIN is the root of the cost-centre stack tree. If there are
68 * no _scc_s in the program, all costs will be attributed
71 * SYSTEM is the RTS in general (scheduler, etc.). All costs for
72 * RTS operations apart from garbage collection are attributed
75 * GC is the storage manager / garbage collector.
77 * OVERHEAD gets all costs generated by the profiling system
78 * itself. These are costs that would not be incurred
79 * during non-profiled execution of the program.
81 * SUBSUMED is the one-and-only CCS placed on top-level functions.
82 * It indicates that all costs are to be attributed to the
83 * enclosing cost centre stack. SUBSUMED never accumulates
84 * any costs. The is_caf flag is set on the subsumed cost
87 * DONT_CARE is a placeholder cost-centre we assign to static
88 * constructors. It should *never* accumulate any costs.
91 CC_DECLARE(CC_MAIN, "MAIN", "MAIN", CC_IS_BORING, );
92 CC_DECLARE(CC_SYSTEM, "SYSTEM", "MAIN", CC_IS_BORING, );
93 CC_DECLARE(CC_GC, "GC", "GC", CC_IS_BORING, );
94 CC_DECLARE(CC_OVERHEAD, "OVERHEAD_of", "PROFILING", CC_IS_CAF, );
95 CC_DECLARE(CC_SUBSUMED, "SUBSUMED", "MAIN", CC_IS_CAF, );
96 CC_DECLARE(CC_DONT_CARE, "DONT_CARE", "MAIN", CC_IS_BORING, );
98 CCS_DECLARE(CCS_MAIN, CC_MAIN, );
99 CCS_DECLARE(CCS_SYSTEM, CC_SYSTEM, );
100 CCS_DECLARE(CCS_GC, CC_GC, );
101 CCS_DECLARE(CCS_OVERHEAD, CC_OVERHEAD, );
102 CCS_DECLARE(CCS_SUBSUMED, CC_SUBSUMED, );
103 CCS_DECLARE(CCS_DONT_CARE, CC_DONT_CARE, );
106 * Uniques for the XML log-file format
111 #define HEAP_OBJ_UQ 4
112 #define TIME_UPD_UQ 5
113 #define HEAP_UPD_UQ 6
119 static CostCentreStack * ActualPush_ ( CostCentreStack *ccs, CostCentre *cc,
120 CostCentreStack *new_ccs );
121 static rtsBool ccs_to_ignore ( CostCentreStack *ccs );
122 static void count_ticks ( CostCentreStack *ccs );
123 static void inherit_costs ( CostCentreStack *ccs );
124 static void reportCCS ( CostCentreStack *ccs, nat indent );
125 static void DecCCS ( CostCentreStack *ccs );
126 static void DecBackEdge ( CostCentreStack *ccs,
127 CostCentreStack *oldccs );
128 static CostCentreStack * CheckLoop ( CostCentreStack *ccs, CostCentre *cc );
129 static CostCentreStack * pruneCCSTree ( CostCentreStack *ccs );
130 static CostCentreStack * ActualPush ( CostCentreStack *, CostCentre * );
131 static CostCentreStack * IsInIndexTable ( IndexTable *, CostCentre * );
132 static IndexTable * AddToIndexTable ( IndexTable *, CostCentreStack *,
133 CostCentre *, unsigned int );
134 static void ccsSetSelected ( CostCentreStack *ccs );
136 static void initTimeProfiling ( void );
137 static void initProfilingLogFile( void );
139 static void reportCCS_XML ( CostCentreStack *ccs );
141 /* -----------------------------------------------------------------------------
142 Initialise the profiling environment
143 -------------------------------------------------------------------------- */
146 initProfiling1 (void)
148 // initialise our arena
149 prof_arena = newArena();
151 /* for the benefit of allocate()... */
154 /* Initialize counters for IDs */
159 /* Initialize Declaration lists to NULL */
163 /* Register all the cost centres / stacks in the program
164 * CC_MAIN gets link = 0, all others have non-zero link.
166 REGISTER_CC(CC_MAIN);
167 REGISTER_CC(CC_SYSTEM);
169 REGISTER_CC(CC_OVERHEAD);
170 REGISTER_CC(CC_SUBSUMED);
171 REGISTER_CC(CC_DONT_CARE);
172 REGISTER_CCS(CCS_MAIN);
173 REGISTER_CCS(CCS_SYSTEM);
174 REGISTER_CCS(CCS_GC);
175 REGISTER_CCS(CCS_OVERHEAD);
176 REGISTER_CCS(CCS_SUBSUMED);
177 REGISTER_CCS(CCS_DONT_CARE);
181 /* cost centres are registered by the per-module
182 * initialisation code now...
187 freeProfiling1 (void)
189 arenaFree(prof_arena);
193 initProfiling2 (void)
195 CostCentreStack *ccs, *next;
199 /* Set up the log file, and dump the header and cost centre
200 * information into it. */
201 initProfilingLogFile();
203 /* find all the "special" cost centre stacks, and make them children
206 ASSERT(CCS_MAIN->prevStack == 0);
207 CCS_MAIN->root = CC_MAIN;
208 ccsSetSelected(CCS_MAIN);
211 for (ccs = CCS_LIST; ccs != CCS_MAIN; ) {
212 next = ccs->prevStack;
214 ActualPush_(CCS_MAIN,ccs->cc,ccs);
219 if (RtsFlags.CcFlags.doCostCentres) {
223 if (RtsFlags.ProfFlags.doHeapProfile) {
228 // Decide whether closures with this CCS should contribute to the heap
231 ccsSetSelected( CostCentreStack *ccs )
233 if (RtsFlags.ProfFlags.modSelector) {
234 if (! strMatchesSelector( ccs->cc->module,
235 RtsFlags.ProfFlags.modSelector ) ) {
240 if (RtsFlags.ProfFlags.ccSelector) {
241 if (! strMatchesSelector( ccs->cc->label,
242 RtsFlags.ProfFlags.ccSelector ) ) {
247 if (RtsFlags.ProfFlags.ccsSelector) {
249 for (c = ccs; c != NULL; c = c->prevStack) {
250 if ( strMatchesSelector( c->cc->label,
251 RtsFlags.ProfFlags.ccsSelector )) {
267 initProfilingLogFile(void)
271 prog = arenaAlloc(prof_arena, strlen(prog_name) + 1);
272 strcpy(prog, prog_name);
273 #ifdef mingw32_HOST_OS
274 // on Windows, drop the .exe suffix if there is one
277 suff = strrchr(prog,'.');
278 if (suff != NULL && !strcmp(suff,".exe")) {
284 if (RtsFlags.CcFlags.doCostCentres == 0 &&
285 RtsFlags.ProfFlags.doHeapProfile != HEAP_BY_RETAINER)
287 /* No need for the <prog>.prof file */
288 prof_filename = NULL;
293 /* Initialise the log file name */
294 prof_filename = arenaAlloc(prof_arena, strlen(prog) + 6);
295 sprintf(prof_filename, "%s.prof", prog);
297 /* open the log file */
298 if ((prof_file = fopen(prof_filename, "w")) == NULL) {
299 debugBelch("Can't open profiling report file %s\n", prof_filename);
300 RtsFlags.CcFlags.doCostCentres = 0;
301 // The following line was added by Sung; retainer/LDV profiling may need
302 // two output files, i.e., <program>.prof/hp.
303 if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER)
304 RtsFlags.ProfFlags.doHeapProfile = 0;
308 if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
309 /* dump the time, and the profiling interval */
310 fprintf(prof_file, "\"%s\"\n", time_str());
311 fprintf(prof_file, "\"%d ms\"\n", RtsFlags.MiscFlags.tickInterval);
313 /* declare all the cost centres */
316 for (cc = CC_LIST; cc != NULL; cc = cc->link) {
317 fprintf(prof_file, "%d %ld \"%s\" \"%s\"\n",
318 CC_UQ, cc->ccID, cc->label, cc->module);
324 if (RtsFlags.ProfFlags.doHeapProfile) {
325 /* Initialise the log file name */
326 hp_filename = arenaAlloc(prof_arena, strlen(prog) + 6);
327 sprintf(hp_filename, "%s.hp", prog);
329 /* open the log file */
330 if ((hp_file = fopen(hp_filename, "w")) == NULL) {
331 debugBelch("Can't open profiling report file %s\n",
333 RtsFlags.ProfFlags.doHeapProfile = 0;
340 initTimeProfiling(void)
347 endProfiling ( void )
349 if (RtsFlags.CcFlags.doCostCentres) {
352 if (RtsFlags.ProfFlags.doHeapProfile) {
357 /* -----------------------------------------------------------------------------
358 Set cost centre stack when entering a function.
359 -------------------------------------------------------------------------- */
360 rtsBool entering_PAP;
363 EnterFunCCS ( CostCentreStack *ccsfn )
365 /* PAP_entry has already set CCCS for us */
367 entering_PAP = rtsFalse;
371 if (ccsfn->root->is_caf == CC_IS_CAF) {
372 CCCS = AppendCCS(CCCS,ccsfn);
378 /* -----------------------------------------------------------------------------
379 Cost-centre stack manipulation
380 -------------------------------------------------------------------------- */
383 CostCentreStack * _PushCostCentre ( CostCentreStack *ccs, CostCentre *cc );
385 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
386 #define PushCostCentre _PushCostCentre
389 traceBegin("pushing %s on ", cc->label);
393 return PushCostCentre(ccs,cc);
398 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
400 CostCentreStack *temp_ccs;
402 if (ccs == EMPTY_STACK)
403 return ActualPush(ccs,cc);
408 /* check if we've already memoized this stack */
409 temp_ccs = IsInIndexTable(ccs->indexTable,cc);
411 if (temp_ccs != EMPTY_STACK)
414 temp_ccs = CheckLoop(ccs,cc);
415 if (temp_ccs != NULL) {
416 /* we have recursed to an older CCS. Mark this in
417 * the index table, and emit a "back edge" into the
420 ccs->indexTable = AddToIndexTable(ccs->indexTable,temp_ccs,cc,1);
421 DecBackEdge(temp_ccs,ccs);
424 return ActualPush(ccs,cc);
431 static CostCentreStack *
432 CheckLoop ( CostCentreStack *ccs, CostCentre *cc )
434 while (ccs != EMPTY_STACK) {
437 ccs = ccs->prevStack;
442 /* Append ccs1 to ccs2 (ignoring any CAF cost centre at the root of ccs1 */
445 CostCentreStack *_AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
447 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
448 #define AppendCCS _AppendCCS
452 debugBelch("Appending ");
457 return AppendCCS(ccs1,ccs2);
462 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
464 CostCentreStack *ccs = NULL;
470 if (ccs2->cc->is_caf == CC_IS_CAF) {
474 if (ccs2->prevStack != NULL) {
475 ccs = AppendCCS(ccs1, ccs2->prevStack);
478 return PushCostCentre(ccs,ccs2->cc);
481 static CostCentreStack *
482 ActualPush ( CostCentreStack *ccs, CostCentre *cc )
484 CostCentreStack *new_ccs;
486 /* allocate space for a new CostCentreStack */
487 new_ccs = (CostCentreStack *) arenaAlloc(prof_arena, sizeof(CostCentreStack));
489 return ActualPush_(ccs, cc, new_ccs);
492 static CostCentreStack *
493 ActualPush_ ( CostCentreStack *ccs, CostCentre *cc, CostCentreStack *new_ccs )
495 /* assign values to each member of the structure */
496 new_ccs->ccsID = CCS_ID++;
498 new_ccs->prevStack = ccs;
500 new_ccs->indexTable = EMPTY_TABLE;
502 /* Initialise the various _scc_ counters to zero
504 new_ccs->scc_count = 0;
506 /* Initialize all other stats here. There should be a quick way
507 * that's easily used elsewhere too
509 new_ccs->time_ticks = 0;
510 new_ccs->mem_alloc = 0;
511 new_ccs->inherited_ticks = 0;
512 new_ccs->inherited_alloc = 0;
514 new_ccs->root = ccs->root;
516 // Set the selected field.
517 ccsSetSelected(new_ccs);
519 /* update the memoization table for the parent stack */
520 if (ccs != EMPTY_STACK)
521 ccs->indexTable = AddToIndexTable(ccs->indexTable, new_ccs, cc,
522 0/*not a back edge*/);
524 /* make sure this CC is declared at the next heap/time sample */
527 /* return a pointer to the new stack */
532 static CostCentreStack *
533 IsInIndexTable(IndexTable *it, CostCentre *cc)
535 while (it!=EMPTY_TABLE)
543 /* otherwise we never found it so return EMPTY_TABLE */
549 AddToIndexTable(IndexTable *it, CostCentreStack *new_ccs,
550 CostCentre *cc, unsigned int back_edge)
554 new_it = arenaAlloc(prof_arena, sizeof(IndexTable));
557 new_it->ccs = new_ccs;
559 new_it->back_edge = back_edge;
565 DecCCS(CostCentreStack *ccs)
567 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
568 if (ccs->prevStack == EMPTY_STACK)
569 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
570 ccs->ccsID, ccs->cc->ccID);
572 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
573 ccs->ccsID, ccs->cc->ccID, ccs->prevStack->ccsID);
578 DecBackEdge( CostCentreStack *ccs, CostCentreStack *oldccs )
580 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
581 if (ccs->prevStack == EMPTY_STACK)
582 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
583 ccs->ccsID, ccs->cc->ccID);
585 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
586 ccs->ccsID, ccs->cc->ccID, oldccs->ccsID);
590 /* -----------------------------------------------------------------------------
591 Generating a time & allocation profiling report.
592 -------------------------------------------------------------------------- */
594 /* We omit certain system-related CCs and CCSs from the default
595 * reports, so as not to cause confusion.
598 cc_to_ignore (CostCentre *cc)
600 if ( cc == CC_OVERHEAD
601 || cc == CC_DONT_CARE
603 || cc == CC_SYSTEM) {
611 ccs_to_ignore (CostCentreStack *ccs)
613 if ( ccs == CCS_OVERHEAD
614 || ccs == CCS_DONT_CARE
616 || ccs == CCS_SYSTEM) {
623 /* -----------------------------------------------------------------------------
624 Generating the aggregated per-cost-centre time/alloc report.
625 -------------------------------------------------------------------------- */
627 static CostCentre *sorted_cc_list;
630 aggregate_cc_costs( CostCentreStack *ccs )
634 ccs->cc->mem_alloc += ccs->mem_alloc;
635 ccs->cc->time_ticks += ccs->time_ticks;
637 for (i = ccs->indexTable; i != 0; i = i->next) {
639 aggregate_cc_costs(i->ccs);
645 insert_cc_in_sorted_list( CostCentre *new_cc )
647 CostCentre **prev, *cc;
649 prev = &sorted_cc_list;
650 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
651 if (new_cc->time_ticks > cc->time_ticks) {
664 report_per_cc_costs( void )
666 CostCentre *cc, *next;
668 aggregate_cc_costs(CCS_MAIN);
669 sorted_cc_list = NULL;
671 for (cc = CC_LIST; cc != NULL; cc = next) {
673 if (cc->time_ticks > total_prof_ticks/100
674 || cc->mem_alloc > total_alloc/100
675 || RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL) {
676 insert_cc_in_sorted_list(cc);
680 fprintf(prof_file, "%-30s %-20s", "COST CENTRE", "MODULE");
681 fprintf(prof_file, "%6s %6s", "%time", "%alloc");
682 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
683 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
685 fprintf(prof_file, "\n\n");
687 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
688 if (cc_to_ignore(cc)) {
691 fprintf(prof_file, "%-30s %-20s", cc->label, cc->module);
692 fprintf(prof_file, "%6.1f %6.1f",
693 total_prof_ticks == 0 ? 0.0 : (cc->time_ticks / (StgFloat) total_prof_ticks * 100),
694 total_alloc == 0 ? 0.0 : (cc->mem_alloc / (StgFloat)
698 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
699 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
700 (StgWord64)(cc->time_ticks), cc->mem_alloc);
702 fprintf(prof_file, "\n");
705 fprintf(prof_file,"\n\n");
708 /* -----------------------------------------------------------------------------
709 Generate the cost-centre-stack time/alloc report
710 -------------------------------------------------------------------------- */
713 fprint_header( void )
715 fprintf(prof_file, "%-24s %-10s individual inherited\n", "", "");
717 fprintf(prof_file, "%-24s %-50s", "COST CENTRE", "MODULE");
718 fprintf(prof_file, "%6s %10s %5s %5s %5s %5s", "no.", "entries", "%time", "%alloc", "%time", "%alloc");
720 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
721 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
722 #if defined(PROFILING_DETAIL_COUNTS)
723 fprintf(prof_file, " %8s %8s %8s %8s %8s %8s %8s",
724 "closures", "thunks", "funcs", "PAPs", "subfuns", "subcafs", "cafssub");
728 fprintf(prof_file, "\n\n");
732 reportCCSProfiling( void )
735 char temp[128]; /* sigh: magic constant */
739 total_prof_ticks = 0;
741 count_ticks(CCS_MAIN);
743 switch (RtsFlags.CcFlags.doCostCentres) {
746 case COST_CENTRES_XML:
753 fprintf(prof_file, "\t%s Time and Allocation Profiling Report (%s)\n",
754 time_str(), "Final");
756 fprintf(prof_file, "\n\t ");
757 fprintf(prof_file, " %s", prog_name);
758 fprintf(prof_file, " +RTS");
759 for (count = 0; rts_argv[count]; count++)
760 fprintf(prof_file, " %s", rts_argv[count]);
761 fprintf(prof_file, " -RTS");
762 for (count = 1; prog_argv[count]; count++)
763 fprintf(prof_file, " %s", prog_argv[count]);
764 fprintf(prof_file, "\n\n");
766 fprintf(prof_file, "\ttotal time = %11.2f secs (%lu ticks @ %d ms)\n",
767 (double) total_prof_ticks *
768 (double) RtsFlags.MiscFlags.tickInterval / 1000,
769 (unsigned long) total_prof_ticks,
770 (int) RtsFlags.MiscFlags.tickInterval);
772 fprintf(prof_file, "\ttotal alloc = %11s bytes",
773 ullong_format_string(total_alloc * sizeof(W_),
774 temp, rtsTrue/*commas*/));
776 #if defined(PROFILING_DETAIL_COUNTS)
777 fprintf(prof_file, " (%lu closures)", total_allocs);
779 fprintf(prof_file, " (excludes profiling overheads)\n\n");
781 report_per_cc_costs();
783 inherit_costs(CCS_MAIN);
786 reportCCS(pruneCCSTree(CCS_MAIN), 0);
790 reportCCS(CostCentreStack *ccs, nat indent)
797 /* Only print cost centres with non 0 data ! */
799 if ( RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL ||
800 ! ccs_to_ignore(ccs))
801 /* force printing of *all* cost centres if -P -P */
804 fprintf(prof_file, "%-*s%-*s %-50s",
805 indent, "", 24-indent, cc->label, cc->module);
807 fprintf(prof_file, "%6ld %11.0f %5.1f %5.1f %5.1f %5.1f",
808 ccs->ccsID, (double) ccs->scc_count,
809 total_prof_ticks == 0 ? 0.0 : ((double)ccs->time_ticks / (double)total_prof_ticks * 100.0),
810 total_alloc == 0 ? 0.0 : ((double)ccs->mem_alloc / (double)total_alloc * 100.0),
811 total_prof_ticks == 0 ? 0.0 : ((double)ccs->inherited_ticks / (double)total_prof_ticks * 100.0),
812 total_alloc == 0 ? 0.0 : ((double)ccs->inherited_alloc / (double)total_alloc * 100.0)
815 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
816 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
817 (StgWord64)(ccs->time_ticks), ccs->mem_alloc*sizeof(W_));
818 #if defined(PROFILING_DETAIL_COUNTS)
819 fprintf(prof_file, " %8ld %8ld %8ld %8ld %8ld %8ld %8ld",
820 ccs->mem_allocs, ccs->thunk_count,
821 ccs->function_count, ccs->pap_count,
822 ccs->subsumed_fun_count, ccs->subsumed_caf_count,
823 ccs->caffun_subsumed);
826 fprintf(prof_file, "\n");
829 for (i = ccs->indexTable; i != 0; i = i->next) {
831 reportCCS(i->ccs, indent+1);
837 /* Traverse the cost centre stack tree and accumulate
841 count_ticks(CostCentreStack *ccs)
845 if (!ccs_to_ignore(ccs)) {
846 total_alloc += ccs->mem_alloc;
847 total_prof_ticks += ccs->time_ticks;
849 for (i = ccs->indexTable; i != NULL; i = i->next)
855 /* Traverse the cost centre stack tree and inherit ticks & allocs.
858 inherit_costs(CostCentreStack *ccs)
862 if (ccs_to_ignore(ccs)) { return; }
864 ccs->inherited_ticks += ccs->time_ticks;
865 ccs->inherited_alloc += ccs->mem_alloc;
867 for (i = ccs->indexTable; i != NULL; i = i->next)
869 inherit_costs(i->ccs);
870 ccs->inherited_ticks += i->ccs->inherited_ticks;
871 ccs->inherited_alloc += i->ccs->inherited_alloc;
877 static CostCentreStack *
878 pruneCCSTree( CostCentreStack *ccs )
880 CostCentreStack *ccs1;
881 IndexTable *i, **prev;
883 prev = &ccs->indexTable;
884 for (i = ccs->indexTable; i != 0; i = i->next) {
885 if (i->back_edge) { continue; }
887 ccs1 = pruneCCSTree(i->ccs);
895 if ( (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL
896 /* force printing of *all* cost centres if -P -P */ )
898 || ( ccs->indexTable != 0 )
899 || ( ccs->scc_count || ccs->time_ticks || ccs->mem_alloc )
907 /* -----------------------------------------------------------------------------
908 Generate the XML time/allocation profile
909 -------------------------------------------------------------------------- */
912 gen_XML_logfile( void )
914 fprintf(prof_file, "%d %lu", TIME_UPD_UQ, total_prof_ticks);
916 reportCCS_XML(pruneCCSTree(CCS_MAIN));
918 fprintf(prof_file, " 0\n");
922 reportCCS_XML(CostCentreStack *ccs)
927 if (ccs_to_ignore(ccs)) { return; }
931 fprintf(prof_file, " 1 %ld %" FMT_Word64 " %" FMT_Word64 " %" FMT_Word64,
932 ccs->ccsID, ccs->scc_count, (StgWord64)(ccs->time_ticks), ccs->mem_alloc);
934 for (i = ccs->indexTable; i != 0; i = i->next) {
936 reportCCS_XML(i->ccs);
942 fprintCCS( FILE *f, CostCentreStack *ccs )
945 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
946 fprintf(f,"%s.%s", ccs->cc->module, ccs->cc->label);
947 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
954 /* For calling from .cmm code, where we can't reliably refer to stderr */
956 fprintCCS_stderr( CostCentreStack *ccs )
958 fprintCCS(stderr, ccs);
963 debugCCS( CostCentreStack *ccs )
966 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
967 debugBelch("%s.%s", ccs->cc->module, ccs->cc->label);
968 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
976 #endif /* PROFILING */