1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2000
5 * Support for profiling
7 * ---------------------------------------------------------------------------*/
11 #include "PosixSource.h"
15 #include "Profiling.h"
17 #include "Proftimer.h"
21 #include "RetainerProfile.h"
22 #include "LdvProfile.h"
31 * Profiling allocation arena.
36 * Global variables used to assign unique IDs to cc's, ccs's, and
44 /* figures for the profiling report.
46 static ullong total_alloc;
47 static lnat total_prof_ticks;
49 /* Globals for opening the profiling log file(s)
51 static char *prof_filename; /* prof report file name = <program>.prof */
54 static char *hp_filename; /* heap profile (hp2ps style) log file */
57 /* The Current Cost Centre Stack (for attributing costs)
59 CostCentreStack *CCCS;
61 /* Linked lists to keep track of cc's and ccs's that haven't
62 * been declared in the log file yet
65 CostCentreStack *CCS_LIST;
68 * Built-in cost centres and cost-centre stacks:
70 * MAIN is the root of the cost-centre stack tree. If there are
71 * no _scc_s in the program, all costs will be attributed
74 * SYSTEM is the RTS in general (scheduler, etc.). All costs for
75 * RTS operations apart from garbage collection are attributed
78 * GC is the storage manager / garbage collector.
80 * OVERHEAD gets all costs generated by the profiling system
81 * itself. These are costs that would not be incurred
82 * during non-profiled execution of the program.
84 * SUBSUMED is the one-and-only CCS placed on top-level functions.
85 * It indicates that all costs are to be attributed to the
86 * enclosing cost centre stack. SUBSUMED never accumulates
87 * any costs. The is_caf flag is set on the subsumed cost
90 * DONT_CARE is a placeholder cost-centre we assign to static
91 * constructors. It should *never* accumulate any costs.
94 CC_DECLARE(CC_MAIN, "MAIN", "MAIN", CC_IS_BORING, );
95 CC_DECLARE(CC_SYSTEM, "SYSTEM", "MAIN", CC_IS_BORING, );
96 CC_DECLARE(CC_GC, "GC", "GC", CC_IS_BORING, );
97 CC_DECLARE(CC_OVERHEAD, "OVERHEAD_of", "PROFILING", CC_IS_CAF, );
98 CC_DECLARE(CC_SUBSUMED, "SUBSUMED", "MAIN", CC_IS_CAF, );
99 CC_DECLARE(CC_DONT_CARE, "DONT_CARE", "MAIN", CC_IS_BORING, );
101 CCS_DECLARE(CCS_MAIN, CC_MAIN, );
102 CCS_DECLARE(CCS_SYSTEM, CC_SYSTEM, );
103 CCS_DECLARE(CCS_GC, CC_GC, );
104 CCS_DECLARE(CCS_OVERHEAD, CC_OVERHEAD, );
105 CCS_DECLARE(CCS_SUBSUMED, CC_SUBSUMED, );
106 CCS_DECLARE(CCS_DONT_CARE, CC_DONT_CARE, );
109 * Uniques for the XML log-file format
114 #define HEAP_OBJ_UQ 4
115 #define TIME_UPD_UQ 5
116 #define HEAP_UPD_UQ 6
122 static CostCentreStack * ActualPush_ ( CostCentreStack *ccs, CostCentre *cc,
123 CostCentreStack *new_ccs );
124 static rtsBool ccs_to_ignore ( CostCentreStack *ccs );
125 static void count_ticks ( CostCentreStack *ccs );
126 static void inherit_costs ( CostCentreStack *ccs );
127 static void reportCCS ( CostCentreStack *ccs, nat indent );
128 static void DecCCS ( CostCentreStack *ccs );
129 static void DecBackEdge ( CostCentreStack *ccs,
130 CostCentreStack *oldccs );
131 static CostCentreStack * CheckLoop ( CostCentreStack *ccs, CostCentre *cc );
132 static CostCentreStack * pruneCCSTree ( CostCentreStack *ccs );
133 static CostCentreStack * ActualPush ( CostCentreStack *, CostCentre * );
134 static CostCentreStack * IsInIndexTable ( IndexTable *, CostCentre * );
135 static IndexTable * AddToIndexTable ( IndexTable *, CostCentreStack *,
136 CostCentre *, unsigned int );
137 static void ccsSetSelected ( CostCentreStack *ccs );
139 static void initTimeProfiling ( void );
140 static void initProfilingLogFile( void );
142 static void reportCCS_XML ( CostCentreStack *ccs );
144 /* -----------------------------------------------------------------------------
145 Initialise the profiling environment
146 -------------------------------------------------------------------------- */
149 initProfiling1 (void)
151 // initialise our arena
152 prof_arena = newArena();
154 /* for the benefit of allocate()... */
157 /* Initialize counters for IDs */
162 /* Initialize Declaration lists to NULL */
166 /* Register all the cost centres / stacks in the program
167 * CC_MAIN gets link = 0, all others have non-zero link.
169 REGISTER_CC(CC_MAIN);
170 REGISTER_CC(CC_SYSTEM);
172 REGISTER_CC(CC_OVERHEAD);
173 REGISTER_CC(CC_SUBSUMED);
174 REGISTER_CC(CC_DONT_CARE);
175 REGISTER_CCS(CCS_MAIN);
176 REGISTER_CCS(CCS_SYSTEM);
177 REGISTER_CCS(CCS_GC);
178 REGISTER_CCS(CCS_OVERHEAD);
179 REGISTER_CCS(CCS_SUBSUMED);
180 REGISTER_CCS(CCS_DONT_CARE);
184 /* cost centres are registered by the per-module
185 * initialisation code now...
190 initProfiling2 (void)
192 CostCentreStack *ccs, *next;
196 /* Set up the log file, and dump the header and cost centre
197 * information into it. */
198 initProfilingLogFile();
200 /* find all the "special" cost centre stacks, and make them children
203 ASSERT(CCS_MAIN->prevStack == 0);
204 CCS_MAIN->root = CC_MAIN;
205 ccsSetSelected(CCS_MAIN);
208 for (ccs = CCS_LIST; ccs != CCS_MAIN; ) {
209 next = ccs->prevStack;
211 ActualPush_(CCS_MAIN,ccs->cc,ccs);
216 if (RtsFlags.CcFlags.doCostCentres) {
220 if (RtsFlags.ProfFlags.doHeapProfile) {
225 // Decide whether closures with this CCS should contribute to the heap
228 ccsSetSelected( CostCentreStack *ccs )
230 if (RtsFlags.ProfFlags.modSelector) {
231 if (! strMatchesSelector( ccs->cc->module,
232 RtsFlags.ProfFlags.modSelector ) ) {
237 if (RtsFlags.ProfFlags.ccSelector) {
238 if (! strMatchesSelector( ccs->cc->label,
239 RtsFlags.ProfFlags.ccSelector ) ) {
244 if (RtsFlags.ProfFlags.ccsSelector) {
246 for (c = ccs; c != NULL; c = c->prevStack) {
247 if ( strMatchesSelector( c->cc->label,
248 RtsFlags.ProfFlags.ccsSelector )) {
264 initProfilingLogFile(void)
266 /* Initialise the log file name */
267 prof_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6);
268 sprintf(prof_filename, "%s.prof", prog_name);
270 /* open the log file */
271 if ((prof_file = fopen(prof_filename, "w")) == NULL) {
272 debugBelch("Can't open profiling report file %s\n", prof_filename);
273 RtsFlags.CcFlags.doCostCentres = 0;
274 // The following line was added by Sung; retainer/LDV profiling may need
275 // two output files, i.e., <program>.prof/hp.
276 if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER)
277 RtsFlags.ProfFlags.doHeapProfile = 0;
281 if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
282 /* dump the time, and the profiling interval */
283 fprintf(prof_file, "\"%s\"\n", time_str());
284 fprintf(prof_file, "\"%d ms\"\n", RtsFlags.MiscFlags.tickInterval);
286 /* declare all the cost centres */
289 for (cc = CC_LIST; cc != NULL; cc = cc->link) {
290 fprintf(prof_file, "%d %ld \"%s\" \"%s\"\n",
291 CC_UQ, cc->ccID, cc->label, cc->module);
296 if (RtsFlags.ProfFlags.doHeapProfile) {
297 /* Initialise the log file name */
298 hp_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6);
299 sprintf(hp_filename, "%s.hp", prog_name);
301 /* open the log file */
302 if ((hp_file = fopen(hp_filename, "w")) == NULL) {
303 debugBelch("Can't open profiling report file %s\n",
305 RtsFlags.ProfFlags.doHeapProfile = 0;
312 initTimeProfiling(void)
319 endProfiling ( void )
321 if (RtsFlags.CcFlags.doCostCentres) {
324 if (RtsFlags.ProfFlags.doHeapProfile) {
329 /* -----------------------------------------------------------------------------
330 Set cost centre stack when entering a function.
331 -------------------------------------------------------------------------- */
332 rtsBool entering_PAP;
335 EnterFunCCS ( CostCentreStack *ccsfn )
337 /* PAP_entry has already set CCCS for us */
339 entering_PAP = rtsFalse;
343 if (ccsfn->root->is_caf == CC_IS_CAF) {
344 CCCS = AppendCCS(CCCS,ccsfn);
350 /* -----------------------------------------------------------------------------
351 Cost-centre stack manipulation
352 -------------------------------------------------------------------------- */
355 CostCentreStack * _PushCostCentre ( CostCentreStack *ccs, CostCentre *cc );
357 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
358 #define PushCostCentre _PushCostCentre
361 traceBegin("pushing %s on ", cc->label);
365 return PushCostCentre(ccs,cc);
370 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
372 CostCentreStack *temp_ccs;
374 if (ccs == EMPTY_STACK)
375 return ActualPush(ccs,cc);
380 /* check if we've already memoized this stack */
381 temp_ccs = IsInIndexTable(ccs->indexTable,cc);
383 if (temp_ccs != EMPTY_STACK)
386 temp_ccs = CheckLoop(ccs,cc);
387 if (temp_ccs != NULL) {
388 /* we have recursed to an older CCS. Mark this in
389 * the index table, and emit a "back edge" into the
392 ccs->indexTable = AddToIndexTable(ccs->indexTable,temp_ccs,cc,1);
393 DecBackEdge(temp_ccs,ccs);
396 return ActualPush(ccs,cc);
403 static CostCentreStack *
404 CheckLoop ( CostCentreStack *ccs, CostCentre *cc )
406 while (ccs != EMPTY_STACK) {
409 ccs = ccs->prevStack;
414 /* Append ccs1 to ccs2 (ignoring any CAF cost centre at the root of ccs1 */
417 CostCentreStack *_AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
419 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
420 #define AppendCCS _AppendCCS
424 debugBelch("Appending ");
429 return AppendCCS(ccs1,ccs2);
434 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
436 CostCentreStack *ccs = NULL;
442 if (ccs2->cc->is_caf == CC_IS_CAF) {
446 if (ccs2->prevStack != NULL) {
447 ccs = AppendCCS(ccs1, ccs2->prevStack);
450 return PushCostCentre(ccs,ccs2->cc);
453 static CostCentreStack *
454 ActualPush ( CostCentreStack *ccs, CostCentre *cc )
456 CostCentreStack *new_ccs;
458 /* allocate space for a new CostCentreStack */
459 new_ccs = (CostCentreStack *) arenaAlloc(prof_arena, sizeof(CostCentreStack));
461 return ActualPush_(ccs, cc, new_ccs);
464 static CostCentreStack *
465 ActualPush_ ( CostCentreStack *ccs, CostCentre *cc, CostCentreStack *new_ccs )
467 /* assign values to each member of the structure */
468 new_ccs->ccsID = CCS_ID++;
470 new_ccs->prevStack = ccs;
472 new_ccs->indexTable = EMPTY_TABLE;
474 /* Initialise the various _scc_ counters to zero
476 new_ccs->scc_count = 0;
478 /* Initialize all other stats here. There should be a quick way
479 * that's easily used elsewhere too
481 new_ccs->time_ticks = 0;
482 new_ccs->mem_alloc = 0;
483 new_ccs->inherited_ticks = 0;
484 new_ccs->inherited_alloc = 0;
486 new_ccs->root = ccs->root;
488 // Set the selected field.
489 ccsSetSelected(new_ccs);
491 /* update the memoization table for the parent stack */
492 if (ccs != EMPTY_STACK)
493 ccs->indexTable = AddToIndexTable(ccs->indexTable, new_ccs, cc,
494 0/*not a back edge*/);
496 /* make sure this CC is declared at the next heap/time sample */
499 /* return a pointer to the new stack */
504 static CostCentreStack *
505 IsInIndexTable(IndexTable *it, CostCentre *cc)
507 while (it!=EMPTY_TABLE)
515 /* otherwise we never found it so return EMPTY_TABLE */
521 AddToIndexTable(IndexTable *it, CostCentreStack *new_ccs,
522 CostCentre *cc, unsigned int back_edge)
526 new_it = arenaAlloc(prof_arena, sizeof(IndexTable));
529 new_it->ccs = new_ccs;
531 new_it->back_edge = back_edge;
537 DecCCS(CostCentreStack *ccs)
539 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
540 if (ccs->prevStack == EMPTY_STACK)
541 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
542 ccs->ccsID, ccs->cc->ccID);
544 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
545 ccs->ccsID, ccs->cc->ccID, ccs->prevStack->ccsID);
550 DecBackEdge( CostCentreStack *ccs, CostCentreStack *oldccs )
552 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
553 if (ccs->prevStack == EMPTY_STACK)
554 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
555 ccs->ccsID, ccs->cc->ccID);
557 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
558 ccs->ccsID, ccs->cc->ccID, oldccs->ccsID);
562 /* -----------------------------------------------------------------------------
563 Generating a time & allocation profiling report.
564 -------------------------------------------------------------------------- */
566 /* We omit certain system-related CCs and CCSs from the default
567 * reports, so as not to cause confusion.
570 cc_to_ignore (CostCentre *cc)
572 if ( cc == CC_OVERHEAD
573 || cc == CC_DONT_CARE
575 || cc == CC_SYSTEM) {
583 ccs_to_ignore (CostCentreStack *ccs)
585 if ( ccs == CCS_OVERHEAD
586 || ccs == CCS_DONT_CARE
588 || ccs == CCS_SYSTEM) {
595 /* -----------------------------------------------------------------------------
596 Generating the aggregated per-cost-centre time/alloc report.
597 -------------------------------------------------------------------------- */
599 static CostCentre *sorted_cc_list;
602 aggregate_cc_costs( CostCentreStack *ccs )
606 ccs->cc->mem_alloc += ccs->mem_alloc;
607 ccs->cc->time_ticks += ccs->time_ticks;
609 for (i = ccs->indexTable; i != 0; i = i->next) {
611 aggregate_cc_costs(i->ccs);
617 insert_cc_in_sorted_list( CostCentre *new_cc )
619 CostCentre **prev, *cc;
621 prev = &sorted_cc_list;
622 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
623 if (new_cc->time_ticks > cc->time_ticks) {
636 report_per_cc_costs( void )
638 CostCentre *cc, *next;
640 aggregate_cc_costs(CCS_MAIN);
641 sorted_cc_list = NULL;
643 for (cc = CC_LIST; cc != NULL; cc = next) {
645 if (cc->time_ticks > total_prof_ticks/100
646 || cc->mem_alloc > total_alloc/100
647 || RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL) {
648 insert_cc_in_sorted_list(cc);
652 fprintf(prof_file, "%-30s %-20s", "COST CENTRE", "MODULE");
653 fprintf(prof_file, "%6s %6s", "%time", "%alloc");
654 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
655 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
657 fprintf(prof_file, "\n\n");
659 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
660 if (cc_to_ignore(cc)) {
663 fprintf(prof_file, "%-30s %-20s", cc->label, cc->module);
664 fprintf(prof_file, "%6.1f %6.1f",
665 total_prof_ticks == 0 ? 0.0 : (cc->time_ticks / (StgFloat) total_prof_ticks * 100),
666 total_alloc == 0 ? 0.0 : (cc->mem_alloc / (StgFloat)
670 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
671 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
672 (StgWord64)(cc->time_ticks), cc->mem_alloc);
674 fprintf(prof_file, "\n");
677 fprintf(prof_file,"\n\n");
680 /* -----------------------------------------------------------------------------
681 Generate the cost-centre-stack time/alloc report
682 -------------------------------------------------------------------------- */
685 fprint_header( void )
687 fprintf(prof_file, "%-24s %-10s individual inherited\n", "", "");
689 fprintf(prof_file, "%-24s %-50s", "COST CENTRE", "MODULE");
690 fprintf(prof_file, "%6s %10s %5s %5s %5s %5s", "no.", "entries", "%time", "%alloc", "%time", "%alloc");
692 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
693 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
694 #if defined(PROFILING_DETAIL_COUNTS)
695 fprintf(prof_file, " %8s %8s %8s %8s %8s %8s %8s",
696 "closures", "thunks", "funcs", "PAPs", "subfuns", "subcafs", "cafssub");
700 fprintf(prof_file, "\n\n");
704 reportCCSProfiling( void )
707 char temp[128]; /* sigh: magic constant */
711 total_prof_ticks = 0;
713 count_ticks(CCS_MAIN);
715 switch (RtsFlags.CcFlags.doCostCentres) {
718 case COST_CENTRES_XML:
725 fprintf(prof_file, "\t%s Time and Allocation Profiling Report (%s)\n",
726 time_str(), "Final");
728 fprintf(prof_file, "\n\t ");
729 fprintf(prof_file, " %s", prog_name);
730 fprintf(prof_file, " +RTS");
731 for (count = 0; rts_argv[count]; count++)
732 fprintf(prof_file, " %s", rts_argv[count]);
733 fprintf(prof_file, " -RTS");
734 for (count = 1; prog_argv[count]; count++)
735 fprintf(prof_file, " %s", prog_argv[count]);
736 fprintf(prof_file, "\n\n");
738 fprintf(prof_file, "\ttotal time = %11.2f secs (%lu ticks @ %d ms)\n",
739 (double) total_prof_ticks *
740 (double) RtsFlags.MiscFlags.tickInterval / 1000,
741 (unsigned long) total_prof_ticks,
742 (int) RtsFlags.MiscFlags.tickInterval);
744 fprintf(prof_file, "\ttotal alloc = %11s bytes",
745 ullong_format_string(total_alloc * sizeof(W_),
746 temp, rtsTrue/*commas*/));
748 #if defined(PROFILING_DETAIL_COUNTS)
749 fprintf(prof_file, " (%lu closures)", total_allocs);
751 fprintf(prof_file, " (excludes profiling overheads)\n\n");
753 report_per_cc_costs();
755 inherit_costs(CCS_MAIN);
758 reportCCS(pruneCCSTree(CCS_MAIN), 0);
762 reportCCS(CostCentreStack *ccs, nat indent)
769 /* Only print cost centres with non 0 data ! */
771 if ( RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL ||
772 ! ccs_to_ignore(ccs))
773 /* force printing of *all* cost centres if -P -P */
776 fprintf(prof_file, "%-*s%-*s %-50s",
777 indent, "", 24-indent, cc->label, cc->module);
779 fprintf(prof_file, "%6ld %11.0f %5.1f %5.1f %5.1f %5.1f",
780 ccs->ccsID, (double) ccs->scc_count,
781 total_prof_ticks == 0 ? 0.0 : ((double)ccs->time_ticks / (double)total_prof_ticks * 100.0),
782 total_alloc == 0 ? 0.0 : ((double)ccs->mem_alloc / (double)total_alloc * 100.0),
783 total_prof_ticks == 0 ? 0.0 : ((double)ccs->inherited_ticks / (double)total_prof_ticks * 100.0),
784 total_alloc == 0 ? 0.0 : ((double)ccs->inherited_alloc / (double)total_alloc * 100.0)
787 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
788 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
789 (StgWord64)(ccs->time_ticks), ccs->mem_alloc*sizeof(W_));
790 #if defined(PROFILING_DETAIL_COUNTS)
791 fprintf(prof_file, " %8ld %8ld %8ld %8ld %8ld %8ld %8ld",
792 ccs->mem_allocs, ccs->thunk_count,
793 ccs->function_count, ccs->pap_count,
794 ccs->subsumed_fun_count, ccs->subsumed_caf_count,
795 ccs->caffun_subsumed);
798 fprintf(prof_file, "\n");
801 for (i = ccs->indexTable; i != 0; i = i->next) {
803 reportCCS(i->ccs, indent+1);
809 /* Traverse the cost centre stack tree and accumulate
813 count_ticks(CostCentreStack *ccs)
817 if (!ccs_to_ignore(ccs)) {
818 total_alloc += ccs->mem_alloc;
819 total_prof_ticks += ccs->time_ticks;
821 for (i = ccs->indexTable; i != NULL; i = i->next)
827 /* Traverse the cost centre stack tree and inherit ticks & allocs.
830 inherit_costs(CostCentreStack *ccs)
834 if (ccs_to_ignore(ccs)) { return; }
836 ccs->inherited_ticks += ccs->time_ticks;
837 ccs->inherited_alloc += ccs->mem_alloc;
839 for (i = ccs->indexTable; i != NULL; i = i->next)
841 inherit_costs(i->ccs);
842 ccs->inherited_ticks += i->ccs->inherited_ticks;
843 ccs->inherited_alloc += i->ccs->inherited_alloc;
849 static CostCentreStack *
850 pruneCCSTree( CostCentreStack *ccs )
852 CostCentreStack *ccs1;
853 IndexTable *i, **prev;
855 prev = &ccs->indexTable;
856 for (i = ccs->indexTable; i != 0; i = i->next) {
857 if (i->back_edge) { continue; }
859 ccs1 = pruneCCSTree(i->ccs);
867 if ( (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL
868 /* force printing of *all* cost centres if -P -P */ )
870 || ( ccs->indexTable != 0 )
871 || ( ccs->scc_count || ccs->time_ticks || ccs->mem_alloc )
879 /* -----------------------------------------------------------------------------
880 Generate the XML time/allocation profile
881 -------------------------------------------------------------------------- */
884 gen_XML_logfile( void )
886 fprintf(prof_file, "%d %lu", TIME_UPD_UQ, total_prof_ticks);
888 reportCCS_XML(pruneCCSTree(CCS_MAIN));
890 fprintf(prof_file, " 0\n");
894 reportCCS_XML(CostCentreStack *ccs)
899 if (ccs_to_ignore(ccs)) { return; }
903 fprintf(prof_file, " 1 %ld %" FMT_Word64 " %" FMT_Word64 " %" FMT_Word64,
904 ccs->ccsID, ccs->scc_count, (StgWord64)(ccs->time_ticks), ccs->mem_alloc);
906 for (i = ccs->indexTable; i != 0; i = i->next) {
908 reportCCS_XML(i->ccs);
914 fprintCCS( FILE *f, CostCentreStack *ccs )
917 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
918 fprintf(f,"%s.%s", ccs->cc->module, ccs->cc->label);
919 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
926 /* For calling from .cmm code, where we can't reliably refer to stderr */
928 fprintCCS_stderr( CostCentreStack *ccs )
930 fprintCCS(stderr, ccs);
935 debugCCS( CostCentreStack *ccs )
938 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
939 debugBelch("%s.%s", ccs->cc->module, ccs->cc->label);
940 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
948 #endif /* PROFILING */