Author: lupus
Date: 2007-10-08 04:10:20 -0400 (Mon, 08 Oct 2007)
New Revision: 87079

Modified:
   trunk/mono/mono/utils/ChangeLog
   trunk/mono/mono/utils/mono-counters.c
   trunk/mono/mono/utils/mono-counters.h
Log:


Mon Oct 8 10:21:47 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>

        * mono-counters.h, mono-counters.c: better formatting of the output
        and added a cleanup function.



Modified: trunk/mono/mono/utils/ChangeLog
===================================================================
--- trunk/mono/mono/utils/ChangeLog     2007-10-08 08:09:39 UTC (rev 87078)
+++ trunk/mono/mono/utils/ChangeLog     2007-10-08 08:10:20 UTC (rev 87079)
@@ -1,3 +1,9 @@
+
+Mon Oct 8 10:21:47 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>
+
+       * mono-counters.h, mono-counters.c: better formatting of the output
+       and added a cleanup function.
+
 2007-10-03  Miguel de Icaza  <[EMAIL PROTECTED]>
 
        * mono-compiler.h (trunc): Make the definition of trunk for MSC

Modified: trunk/mono/mono/utils/mono-counters.c
===================================================================
--- trunk/mono/mono/utils/mono-counters.c       2007-10-08 08:09:39 UTC (rev 
87078)
+++ trunk/mono/mono/utils/mono-counters.c       2007-10-08 08:10:20 UTC (rev 
87079)
@@ -13,6 +13,7 @@
 
 static MonoCounter *counters = NULL;
 static int valid_mask = 0;
+static int set_mask = 0;
 
 /**
  * mono_counters_enable:
@@ -33,6 +34,8 @@
  * @addr: The address to register.
  *
  * Register addr as the address of a counter of type type.
+ * Note that @name must be a valid string at all times until
+ * mono_counters_dump () is called.
  *
  * It may be a function pointer if MONO_COUNTER_CALLBACK is specified:
  * the function should return the value and take no arguments.
@@ -51,6 +54,8 @@
        counter->addr = addr;
        counter->next = NULL;
 
+       set_mask |= type;
+
        /* Append */
        if (counters) {
                MonoCounter *item = counters;
@@ -70,7 +75,7 @@
 typedef double (*DoubleFunc) (void);
 typedef char* (*StrFunc) (void);
 
-#define ENTRY_FMT "%-24s : "
+#define ENTRY_FMT "%-36s: "
 static void
 dump_counter (MonoCounter *counter, FILE *outfile) {
        int intval;
@@ -172,10 +177,27 @@
        if (!counters)
                return;
        for (j = 0, i = MONO_COUNTER_JIT; i < MONO_COUNTER_LAST_SECTION; j++, i 
<<= 1) {
-               if (section_mask & i) {
+               if ((section_mask & i) && (set_mask & i)) {
                        fprintf (outfile, "\n%s statistics\n", section_names 
[j]);
                        mono_counters_dump_section (i, outfile);
                }
        }
 }
 
+/**
+ * mono_counters_cleanup:
+ *
+ * Perform any needed cleanup at process exit.
+ */
+void
+mono_counters_cleanup (void)
+{
+       MonoCounter *counter = counters;
+       while (counter) {
+               MonoCounter *tmp = counters;
+               counter = counter->next;
+               free (tmp);
+       }
+       counters = NULL;
+}
+

Modified: trunk/mono/mono/utils/mono-counters.h
===================================================================
--- trunk/mono/mono/utils/mono-counters.h       2007-10-08 08:09:39 UTC (rev 
87078)
+++ trunk/mono/mono/utils/mono-counters.h       2007-10-08 08:10:20 UTC (rev 
87079)
@@ -37,5 +37,7 @@
  */
 void mono_counters_dump (int section_mask, FILE *outfile);
 
+void mono_counters_cleanup (void);
+
 #endif /* __MONO_COUNTERS_H__ */
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to