+ }
+
+ if ( (RtsFlags.CcFlags.doCostCentres >= COST_CENTRES_ALL
+ /* force printing of *all* cost centres if -P -P */ )
+
+ || ( ccs->indexTable != 0 )
+ || ( ccs->scc_count || ccs->time_ticks || ccs->mem_alloc )
+ ) {
+ return ccs;
+ } else {
+ return NULL;
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ Generate the XML time/allocation profile
+ -------------------------------------------------------------------------- */
+
+void
+gen_XML_logfile( void )
+{
+ fprintf(prof_file, "%d %lu", TIME_UPD_UQ, total_prof_ticks);
+
+ reportCCS_XML(pruneCCSTree(CCS_MAIN));
+
+ fprintf(prof_file, " 0\n");
+
+ fclose(prof_file);
+}
+
+static void
+reportCCS_XML(CostCentreStack *ccs)
+{
+ CostCentre *cc;
+ IndexTable *i;
+
+ if (ccs_to_ignore(ccs)) { return; }
+
+ cc = ccs->cc;
+
+ fprintf(prof_file, " 1 %d %llu %llu %llu",
+ ccs->ccsID, ccs->scc_count, (StgWord64)(ccs->time_ticks), ccs->mem_alloc);
+
+ for (i = ccs->indexTable; i != 0; i = i->next) {
+ if (!i->back_edge) {
+ reportCCS_XML(i->ccs);
+ }
+ }
+}
+
+void
+fprintCCS( FILE *f, CostCentreStack *ccs )
+{
+ fprintf(f,"<");
+ for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
+ fprintf(f,"%s.%s", ccs->cc->module, ccs->cc->label);
+ if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
+ fprintf(f,",");
+ }
+ }
+ fprintf(f,">");
+}
+
+/* For calling from .cmm code, where we can't reliably refer to stderr */
+void
+fprintCCS_stderr( CostCentreStack *ccs )
+{
+ fprintCCS(stderr, ccs);
+}
+
+#ifdef DEBUG
+void
+debugCCS( CostCentreStack *ccs )
+{
+ debugBelch("<");
+ for (; ccs && ccs != CCS_MAIN; ccs = ccs->prevStack ) {
+ debugBelch("%s.%s", ccs->cc->module, ccs->cc->label);
+ if (ccs->prevStack && ccs->prevStack != CCS_MAIN) {
+ debugBelch(",");
+ }
+ }
+ debugBelch(">");