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"
20 #include "RetainerProfile.h"
21 #include "LdvProfile.h"
30 * Profiling allocation arena.
35 * Global variables used to assign unique IDs to cc's, ccs's, and
43 /* figures for the profiling report.
45 static ullong total_alloc;
46 static lnat total_prof_ticks;
48 /* Globals for opening the profiling log file(s)
50 static char *prof_filename; /* prof report file name = <program>.prof */
53 static char *hp_filename; /* heap profile (hp2ps style) log file */
56 /* The Current Cost Centre Stack (for attributing costs)
58 CostCentreStack *CCCS;
60 /* Linked lists to keep track of cc's and ccs's that haven't
61 * been declared in the log file yet
64 CostCentreStack *CCS_LIST;
67 * Built-in cost centres and cost-centre stacks:
69 * MAIN is the root of the cost-centre stack tree. If there are
70 * no _scc_s in the program, all costs will be attributed
73 * SYSTEM is the RTS in general (scheduler, etc.). All costs for
74 * RTS operations apart from garbage collection are attributed
77 * GC is the storage manager / garbage collector.
79 * OVERHEAD gets all costs generated by the profiling system
80 * itself. These are costs that would not be incurred
81 * during non-profiled execution of the program.
83 * SUBSUMED is the one-and-only CCS placed on top-level functions.
84 * It indicates that all costs are to be attributed to the
85 * enclosing cost centre stack. SUBSUMED never accumulates
86 * any costs. The is_caf flag is set on the subsumed cost
89 * DONT_CARE is a placeholder cost-centre we assign to static
90 * constructors. It should *never* accumulate any costs.
93 CC_DECLARE(CC_MAIN, "MAIN", "MAIN", CC_IS_BORING, );
94 CC_DECLARE(CC_SYSTEM, "SYSTEM", "MAIN", CC_IS_BORING, );
95 CC_DECLARE(CC_GC, "GC", "GC", CC_IS_BORING, );
96 CC_DECLARE(CC_OVERHEAD, "OVERHEAD_of", "PROFILING", CC_IS_CAF, );
97 CC_DECLARE(CC_SUBSUMED, "SUBSUMED", "MAIN", CC_IS_CAF, );
98 CC_DECLARE(CC_DONT_CARE, "DONT_CARE", "MAIN", CC_IS_BORING, );
100 CCS_DECLARE(CCS_MAIN, CC_MAIN, );
101 CCS_DECLARE(CCS_SYSTEM, CC_SYSTEM, );
102 CCS_DECLARE(CCS_GC, CC_GC, );
103 CCS_DECLARE(CCS_OVERHEAD, CC_OVERHEAD, );
104 CCS_DECLARE(CCS_SUBSUMED, CC_SUBSUMED, );
105 CCS_DECLARE(CCS_DONT_CARE, CC_DONT_CARE, );
108 * Uniques for the XML log-file format
113 #define HEAP_OBJ_UQ 4
114 #define TIME_UPD_UQ 5
115 #define HEAP_UPD_UQ 6
121 static CostCentreStack * ActualPush_ ( CostCentreStack *ccs, CostCentre *cc,
122 CostCentreStack *new_ccs );
123 static rtsBool ccs_to_ignore ( CostCentreStack *ccs );
124 static void count_ticks ( CostCentreStack *ccs );
125 static void inherit_costs ( CostCentreStack *ccs );
126 static void reportCCS ( CostCentreStack *ccs, nat indent );
127 static void DecCCS ( CostCentreStack *ccs );
128 static void DecBackEdge ( CostCentreStack *ccs,
129 CostCentreStack *oldccs );
130 static CostCentreStack * CheckLoop ( CostCentreStack *ccs, CostCentre *cc );
131 static CostCentreStack * pruneCCSTree ( CostCentreStack *ccs );
132 static CostCentreStack * ActualPush ( CostCentreStack *, CostCentre * );
133 static CostCentreStack * IsInIndexTable ( IndexTable *, CostCentre * );
134 static IndexTable * AddToIndexTable ( IndexTable *, CostCentreStack *,
135 CostCentre *, unsigned int );
136 static void ccsSetSelected ( CostCentreStack *ccs );
138 static void initTimeProfiling ( void );
139 static void initProfilingLogFile( void );
141 static void reportCCS_XML ( CostCentreStack *ccs );
143 /* -----------------------------------------------------------------------------
144 Initialise the profiling environment
145 -------------------------------------------------------------------------- */
148 initProfiling1 (void)
150 // initialise our arena
151 prof_arena = newArena();
153 /* for the benefit of allocate()... */
156 /* Initialize counters for IDs */
161 /* Initialize Declaration lists to NULL */
165 /* Register all the cost centres / stacks in the program
166 * CC_MAIN gets link = 0, all others have non-zero link.
168 REGISTER_CC(CC_MAIN);
169 REGISTER_CC(CC_SYSTEM);
171 REGISTER_CC(CC_OVERHEAD);
172 REGISTER_CC(CC_SUBSUMED);
173 REGISTER_CC(CC_DONT_CARE);
174 REGISTER_CCS(CCS_MAIN);
175 REGISTER_CCS(CCS_SYSTEM);
176 REGISTER_CCS(CCS_GC);
177 REGISTER_CCS(CCS_OVERHEAD);
178 REGISTER_CCS(CCS_SUBSUMED);
179 REGISTER_CCS(CCS_DONT_CARE);
183 /* cost centres are registered by the per-module
184 * initialisation code now...
189 initProfiling2 (void)
191 CostCentreStack *ccs, *next;
195 /* Set up the log file, and dump the header and cost centre
196 * information into it. */
197 initProfilingLogFile();
199 /* find all the "special" cost centre stacks, and make them children
202 ASSERT(CCS_MAIN->prevStack == 0);
203 CCS_MAIN->root = CC_MAIN;
204 ccsSetSelected(CCS_MAIN);
207 for (ccs = CCS_LIST; ccs != CCS_MAIN; ) {
208 next = ccs->prevStack;
210 ActualPush_(CCS_MAIN,ccs->cc,ccs);
215 if (RtsFlags.CcFlags.doCostCentres) {
219 if (RtsFlags.ProfFlags.doHeapProfile) {
224 // Decide whether closures with this CCS should contribute to the heap
227 ccsSetSelected( CostCentreStack *ccs )
229 if (RtsFlags.ProfFlags.modSelector) {
230 if (! strMatchesSelector( ccs->cc->module,
231 RtsFlags.ProfFlags.modSelector ) ) {
236 if (RtsFlags.ProfFlags.ccSelector) {
237 if (! strMatchesSelector( ccs->cc->label,
238 RtsFlags.ProfFlags.ccSelector ) ) {
243 if (RtsFlags.ProfFlags.ccsSelector) {
245 for (c = ccs; c != NULL; c = c->prevStack) {
246 if ( strMatchesSelector( c->cc->label,
247 RtsFlags.ProfFlags.ccsSelector )) {
263 initProfilingLogFile(void)
265 /* Initialise the log file name */
266 prof_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6);
267 sprintf(prof_filename, "%s.prof", prog_name);
269 /* open the log file */
270 if ((prof_file = fopen(prof_filename, "w")) == NULL) {
271 debugBelch("Can't open profiling report file %s\n", prof_filename);
272 RtsFlags.CcFlags.doCostCentres = 0;
273 // The following line was added by Sung; retainer/LDV profiling may need
274 // two output files, i.e., <program>.prof/hp.
275 if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER)
276 RtsFlags.ProfFlags.doHeapProfile = 0;
280 if (RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
281 /* dump the time, and the profiling interval */
282 fprintf(prof_file, "\"%s\"\n", time_str());
283 fprintf(prof_file, "\"%d ms\"\n", RtsFlags.MiscFlags.tickInterval);
285 /* declare all the cost centres */
288 for (cc = CC_LIST; cc != NULL; cc = cc->link) {
289 fprintf(prof_file, "%d %ld \"%s\" \"%s\"\n",
290 CC_UQ, cc->ccID, cc->label, cc->module);
295 if (RtsFlags.ProfFlags.doHeapProfile) {
296 /* Initialise the log file name */
297 hp_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6);
298 sprintf(hp_filename, "%s.hp", prog_name);
300 /* open the log file */
301 if ((hp_file = fopen(hp_filename, "w")) == NULL) {
302 debugBelch("Can't open profiling report file %s\n",
304 RtsFlags.ProfFlags.doHeapProfile = 0;
311 initTimeProfiling(void)
318 endProfiling ( void )
320 if (RtsFlags.CcFlags.doCostCentres) {
323 if (RtsFlags.ProfFlags.doHeapProfile) {
328 /* -----------------------------------------------------------------------------
329 Set cost centre stack when entering a function.
330 -------------------------------------------------------------------------- */
331 rtsBool entering_PAP;
334 EnterFunCCS ( CostCentreStack *ccsfn )
336 /* PAP_entry has already set CCCS for us */
338 entering_PAP = rtsFalse;
342 if (ccsfn->root->is_caf == CC_IS_CAF) {
343 CCCS = AppendCCS(CCCS,ccsfn);
349 /* -----------------------------------------------------------------------------
350 Cost-centre stack manipulation
351 -------------------------------------------------------------------------- */
354 CostCentreStack * _PushCostCentre ( CostCentreStack *ccs, CostCentre *cc );
356 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
357 #define PushCostCentre _PushCostCentre
360 traceBegin("pushing %s on ", cc->label);
364 return PushCostCentre(ccs,cc);
369 PushCostCentre ( CostCentreStack *ccs, CostCentre *cc )
371 CostCentreStack *temp_ccs;
373 if (ccs == EMPTY_STACK)
374 return ActualPush(ccs,cc);
379 /* check if we've already memoized this stack */
380 temp_ccs = IsInIndexTable(ccs->indexTable,cc);
382 if (temp_ccs != EMPTY_STACK)
385 temp_ccs = CheckLoop(ccs,cc);
386 if (temp_ccs != NULL) {
387 /* we have recursed to an older CCS. Mark this in
388 * the index table, and emit a "back edge" into the
391 ccs->indexTable = AddToIndexTable(ccs->indexTable,temp_ccs,cc,1);
392 DecBackEdge(temp_ccs,ccs);
395 return ActualPush(ccs,cc);
402 static CostCentreStack *
403 CheckLoop ( CostCentreStack *ccs, CostCentre *cc )
405 while (ccs != EMPTY_STACK) {
408 ccs = ccs->prevStack;
413 /* Append ccs1 to ccs2 (ignoring any CAF cost centre at the root of ccs1 */
416 CostCentreStack *_AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
418 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
419 #define AppendCCS _AppendCCS
423 debugBelch("Appending ");
428 return AppendCCS(ccs1,ccs2);
433 AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
435 CostCentreStack *ccs = NULL;
441 if (ccs2->cc->is_caf == CC_IS_CAF) {
445 if (ccs2->prevStack != NULL) {
446 ccs = AppendCCS(ccs1, ccs2->prevStack);
449 return PushCostCentre(ccs,ccs2->cc);
452 static CostCentreStack *
453 ActualPush ( CostCentreStack *ccs, CostCentre *cc )
455 CostCentreStack *new_ccs;
457 /* allocate space for a new CostCentreStack */
458 new_ccs = (CostCentreStack *) arenaAlloc(prof_arena, sizeof(CostCentreStack));
460 return ActualPush_(ccs, cc, new_ccs);
463 static CostCentreStack *
464 ActualPush_ ( CostCentreStack *ccs, CostCentre *cc, CostCentreStack *new_ccs )
466 /* assign values to each member of the structure */
467 new_ccs->ccsID = CCS_ID++;
469 new_ccs->prevStack = ccs;
471 new_ccs->indexTable = EMPTY_TABLE;
473 /* Initialise the various _scc_ counters to zero
475 new_ccs->scc_count = 0;
477 /* Initialize all other stats here. There should be a quick way
478 * that's easily used elsewhere too
480 new_ccs->time_ticks = 0;
481 new_ccs->mem_alloc = 0;
482 new_ccs->inherited_ticks = 0;
483 new_ccs->inherited_alloc = 0;
485 new_ccs->root = ccs->root;
487 // Set the selected field.
488 ccsSetSelected(new_ccs);
490 /* update the memoization table for the parent stack */
491 if (ccs != EMPTY_STACK)
492 ccs->indexTable = AddToIndexTable(ccs->indexTable, new_ccs, cc,
493 0/*not a back edge*/);
495 /* make sure this CC is declared at the next heap/time sample */
498 /* return a pointer to the new stack */
503 static CostCentreStack *
504 IsInIndexTable(IndexTable *it, CostCentre *cc)
506 while (it!=EMPTY_TABLE)
514 /* otherwise we never found it so return EMPTY_TABLE */
520 AddToIndexTable(IndexTable *it, CostCentreStack *new_ccs,
521 CostCentre *cc, unsigned int back_edge)
525 new_it = arenaAlloc(prof_arena, sizeof(IndexTable));
528 new_it->ccs = new_ccs;
530 new_it->back_edge = back_edge;
536 DecCCS(CostCentreStack *ccs)
538 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
539 if (ccs->prevStack == EMPTY_STACK)
540 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
541 ccs->ccsID, ccs->cc->ccID);
543 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
544 ccs->ccsID, ccs->cc->ccID, ccs->prevStack->ccsID);
549 DecBackEdge( CostCentreStack *ccs, CostCentreStack *oldccs )
551 if (prof_file && RtsFlags.CcFlags.doCostCentres == COST_CENTRES_XML) {
552 if (ccs->prevStack == EMPTY_STACK)
553 fprintf(prof_file, "%d %ld 1 %ld\n", CCS_UQ,
554 ccs->ccsID, ccs->cc->ccID);
556 fprintf(prof_file, "%d %ld 2 %ld %ld\n", CCS_UQ,
557 ccs->ccsID, ccs->cc->ccID, oldccs->ccsID);
561 /* -----------------------------------------------------------------------------
562 Generating a time & allocation profiling report.
563 -------------------------------------------------------------------------- */
565 /* We omit certain system-related CCs and CCSs from the default
566 * reports, so as not to cause confusion.
569 cc_to_ignore (CostCentre *cc)
571 if ( cc == CC_OVERHEAD
572 || cc == CC_DONT_CARE
574 || cc == CC_SYSTEM) {
582 ccs_to_ignore (CostCentreStack *ccs)
584 if ( ccs == CCS_OVERHEAD
585 || ccs == CCS_DONT_CARE
587 || ccs == CCS_SYSTEM) {
594 /* -----------------------------------------------------------------------------
595 Generating the aggregated per-cost-centre time/alloc report.
596 -------------------------------------------------------------------------- */
598 static CostCentre *sorted_cc_list;
601 aggregate_cc_costs( CostCentreStack *ccs )
605 ccs->cc->mem_alloc += ccs->mem_alloc;
606 ccs->cc->time_ticks += ccs->time_ticks;
608 for (i = ccs->indexTable; i != 0; i = i->next) {
610 aggregate_cc_costs(i->ccs);
616 insert_cc_in_sorted_list( CostCentre *new_cc )
618 CostCentre **prev, *cc;
620 prev = &sorted_cc_list;
621 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
622 if (new_cc->time_ticks > cc->time_ticks) {
635 report_per_cc_costs( void )
637 CostCentre *cc, *next;
639 aggregate_cc_costs(CCS_MAIN);
640 sorted_cc_list = NULL;
642 for (cc = CC_LIST; cc != NULL; cc = next) {
644 if (cc->time_ticks > total_prof_ticks/100
645 || cc->mem_alloc > total_alloc/100
646 || RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL) {
647 insert_cc_in_sorted_list(cc);
651 fprintf(prof_file, "%-30s %-20s", "COST CENTRE", "MODULE");
652 fprintf(prof_file, "%6s %6s", "%time", "%alloc");
653 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
654 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
656 fprintf(prof_file, "\n\n");
658 for (cc = sorted_cc_list; cc != NULL; cc = cc->link) {
659 if (cc_to_ignore(cc)) {
662 fprintf(prof_file, "%-30s %-20s", cc->label, cc->module);
663 fprintf(prof_file, "%6.1f %6.1f",
664 total_prof_ticks == 0 ? 0.0 : (cc->time_ticks / (StgFloat) total_prof_ticks * 100),
665 total_alloc == 0 ? 0.0 : (cc->mem_alloc / (StgFloat)
669 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
670 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
671 (StgWord64)(cc->time_ticks), cc->mem_alloc);
673 fprintf(prof_file, "\n");
676 fprintf(prof_file,"\n\n");
679 /* -----------------------------------------------------------------------------
680 Generate the cost-centre-stack time/alloc report
681 -------------------------------------------------------------------------- */
684 fprint_header( void )
686 fprintf(prof_file, "%-24s %-10s individual inherited\n", "", "");
688 fprintf(prof_file, "%-24s %-50s", "COST CENTRE", "MODULE");
689 fprintf(prof_file, "%6s %10s %5s %5s %5s %5s", "no.", "entries", "%time", "%alloc", "%time", "%alloc");
691 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
692 fprintf(prof_file, " %5s %9s", "ticks", "bytes");
693 #if defined(PROFILING_DETAIL_COUNTS)
694 fprintf(prof_file, " %8s %8s %8s %8s %8s %8s %8s",
695 "closures", "thunks", "funcs", "PAPs", "subfuns", "subcafs", "cafssub");
699 fprintf(prof_file, "\n\n");
703 reportCCSProfiling( void )
706 char temp[128]; /* sigh: magic constant */
710 total_prof_ticks = 0;
712 count_ticks(CCS_MAIN);
714 switch (RtsFlags.CcFlags.doCostCentres) {
717 case COST_CENTRES_XML:
724 fprintf(prof_file, "\t%s Time and Allocation Profiling Report (%s)\n",
725 time_str(), "Final");
727 fprintf(prof_file, "\n\t ");
728 fprintf(prof_file, " %s", prog_name);
729 fprintf(prof_file, " +RTS");
730 for (count = 0; rts_argv[count]; count++)
731 fprintf(prof_file, " %s", rts_argv[count]);
732 fprintf(prof_file, " -RTS");
733 for (count = 1; prog_argv[count]; count++)
734 fprintf(prof_file, " %s", prog_argv[count]);
735 fprintf(prof_file, "\n\n");
737 fprintf(prof_file, "\ttotal time = %11.2f secs (%lu ticks @ %d ms)\n",
738 (double) total_prof_ticks *
739 (double) RtsFlags.MiscFlags.tickInterval / 1000,
740 (unsigned long) total_prof_ticks,
741 (int) RtsFlags.MiscFlags.tickInterval);
743 fprintf(prof_file, "\ttotal alloc = %11s bytes",
744 ullong_format_string(total_alloc * sizeof(W_),
745 temp, rtsTrue/*commas*/));
747 #if defined(PROFILING_DETAIL_COUNTS)
748 fprintf(prof_file, " (%lu closures)", total_allocs);
750 fprintf(prof_file, " (excludes profiling overheads)\n\n");
752 report_per_cc_costs();
754 inherit_costs(CCS_MAIN);
757 reportCCS(pruneCCSTree(CCS_MAIN), 0);
761 reportCCS(CostCentreStack *ccs, nat indent)
768 /* Only print cost centres with non 0 data ! */
770 if ( RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL ||
771 ! ccs_to_ignore(ccs))
772 /* force printing of *all* cost centres if -P -P */
775 fprintf(prof_file, "%-*s%-*s %-50s",
776 indent, "", 24-indent, cc->label, cc->module);
778 fprintf(prof_file, "%6ld %11.0f %5.1f %5.1f %5.1f %5.1f",
779 ccs->ccsID, (double) ccs->scc_count,
780 total_prof_ticks == 0 ? 0.0 : ((double)ccs->time_ticks / (double)total_prof_ticks * 100.0),
781 total_alloc == 0 ? 0.0 : ((double)ccs->mem_alloc / (double)total_alloc * 100.0),
782 total_prof_ticks == 0 ? 0.0 : ((double)ccs->inherited_ticks / (double)total_prof_ticks * 100.0),
783 total_alloc == 0 ? 0.0 : ((double)ccs->inherited_alloc / (double)total_alloc * 100.0)
786 if (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_VERBOSE) {
787 fprintf(prof_file, " %5" FMT_Word64 " %9" FMT_Word64,
788 (StgWord64)(ccs->time_ticks), ccs->mem_alloc*sizeof(W_));
789 #if defined(PROFILING_DETAIL_COUNTS)
790 fprintf(prof_file, " %8ld %8ld %8ld %8ld %8ld %8ld %8ld",
791 ccs->mem_allocs, ccs->thunk_count,
792 ccs->function_count, ccs->pap_count,
793 ccs->subsumed_fun_count, ccs->subsumed_caf_count,
794 ccs->caffun_subsumed);
797 fprintf(prof_file, "\n");
800 for (i = ccs->indexTable; i != 0; i = i->next) {
802 reportCCS(i->ccs, indent+1);
808 /* Traverse the cost centre stack tree and accumulate
812 count_ticks(CostCentreStack *ccs)
816 if (!ccs_to_ignore(ccs)) {
817 total_alloc += ccs->mem_alloc;
818 total_prof_ticks += ccs->time_ticks;
820 for (i = ccs->indexTable; i != NULL; i = i->next)
826 /* Traverse the cost centre stack tree and inherit ticks & allocs.
829 inherit_costs(CostCentreStack *ccs)
833 if (ccs_to_ignore(ccs)) { return; }
835 ccs->inherited_ticks += ccs->time_ticks;
836 ccs->inherited_alloc += ccs->mem_alloc;
838 for (i = ccs->indexTable; i != NULL; i = i->next)
840 inherit_costs(i->ccs);
841 ccs->inherited_ticks += i->ccs->inherited_ticks;
842 ccs->inherited_alloc += i->ccs->inherited_alloc;
848 static CostCentreStack *
849 pruneCCSTree( CostCentreStack *ccs )
851 CostCentreStack *ccs1;
852 IndexTable *i, **prev;
854 prev = &ccs->indexTable;
855 for (i = ccs->indexTable; i != 0; i = i->next) {
856 if (i->back_edge) { continue; }
858 ccs1 = pruneCCSTree(i->ccs);
866 if ( (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL
867 /* force printing of *all* cost centres if -P -P */ )
869 || ( ccs->indexTable != 0 )
870 || ( ccs->scc_count || ccs->time_ticks || ccs->mem_alloc )
878 /* -----------------------------------------------------------------------------
879 Generate the XML time/allocation profile
880 -------------------------------------------------------------------------- */
883 gen_XML_logfile( void )
885 fprintf(prof_file, "%d %lu", TIME_UPD_UQ, total_prof_ticks);
887 reportCCS_XML(pruneCCSTree(CCS_MAIN));
889 fprintf(prof_file, " 0\n");
893 reportCCS_XML(CostCentreStack *ccs)
898 if (ccs_to_ignore(ccs)) { return; }
902 fprintf(prof_file, " 1 %ld %" FMT_Word64 " %" FMT_Word64 " %" FMT_Word64,
903 ccs->ccsID, ccs->scc_count, (StgWord64)(ccs->time_ticks), ccs->mem_alloc);
905 for (i = ccs->indexTable; i != 0; i = i->next) {
907 reportCCS_XML(i->ccs);
913 fprintCCS( FILE *f, CostCentreStack *ccs )
916 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
917 fprintf(f,"%s.%s", ccs->cc->module, ccs->cc->label);
918 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
925 /* For calling from .cmm code, where we can't reliably refer to stderr */
927 fprintCCS_stderr( CostCentreStack *ccs )
929 fprintCCS(stderr, ccs);
934 debugCCS( CostCentreStack *ccs )
937 for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
938 debugBelch("%s.%s", ccs->cc->module, ccs->cc->label);
939 if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
947 #endif /* PROFILING */