Share the log file between sgen and the stack marking code.
authorZoltan Varga <vargaz@gmail.com>
Tue, 5 Oct 2010 04:26:43 +0000 (06:26 +0200)
committerZoltan Varga <vargaz@gmail.com>
Mon, 3 Jan 2011 14:42:40 +0000 (15:42 +0100)
mono/metadata/sgen-gc.c
mono/metadata/sgen-gc.h
mono/mini/mini-gc.c
mono/mini/mini.c

index bb0f4b70390460e7a689cafaad2d04ed2051d66e..bb123a25c67c553d0a68f02203fd24e7abca34ca 100644 (file)
@@ -7756,4 +7756,10 @@ mono_sgen_debug_printf (int level, const char *format, ...)
        va_end (ap);
 }
 
+FILE*
+mono_sgen_get_logfile (void)
+{
+       return gc_debug_file;
+}
+
 #endif /* HAVE_SGEN_GC */
index f5aade57adc22ca1ba3d40a324e691694511f662..e8ac384be757aa54e0e58b67fa51c60f92e9dca1 100644 (file)
@@ -797,5 +797,9 @@ gboolean mono_sgen_ptr_is_in_los (char *ptr, char **start) MONO_INTERNAL;
 void mono_sgen_los_iterate_objects (IterateObjectCallbackFunc cb, void *user_data) MONO_INTERNAL;
 void mono_sgen_los_iterate_live_block_ranges (sgen_cardtable_block_callback callback) MONO_INTERNAL;
 void mono_sgen_los_scan_card_table (SgenGrayQueue *queue) MONO_INTERNAL;
+=======
+void sgen_collect_major_no_lock (const char *reason) MONO_INTERNAL;;
+FILE *mono_sgen_get_logfile (void) MONO_INTERNAL;
+>>>>>>> Share the log file between sgen and the stack marking code.
 
 #endif /* __MONO_SGENGC_H__ */
index 862e23e3e2ed0d076c7cf6f64e8a6ffaf42ff0c7..0f111fba5ab08a5c83521d2457a1b39705c95a29 100644 (file)
@@ -14,6 +14,7 @@
 //#if 0
 #ifdef HAVE_SGEN_GC
 
+#include <mono/metadata/sgen-gc.h>
 #include <mono/metadata/gc-internal.h>
 #include <mono/utils/mono-counters.h>
 
@@ -66,7 +67,8 @@ typedef struct {
 
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
 
-#if 0
+#if 1
+/* We don't support debug levels, its all-or-nothing */
 #define DEBUG(s) do { s; fflush (logfile); } while (0)
 #define DEBUG_ENABLED 1
 #else
@@ -87,8 +89,6 @@ typedef struct {
 #define DEBUG_GC_MAP(s)
 #endif
 
-#define GC_BITS_PER_WORD (sizeof (gsize) * 8)
-
 /*
  * Contains information collected during the conservative stack marking pass,
  * used during the precise pass. This helps to avoid doing a stack walk twice, which
@@ -2264,16 +2264,9 @@ parse_debug_options (void)
 
        opts = g_strsplit (env, ",", -1);
        for (ptr = opts; ptr && *ptr; ptr ++) {
-               char *opt = *ptr;
-
-               if (g_str_has_prefix (opt, "logfile=")) {
-                       char *arg = strchr (opt, '=') + 1;
-                       logfile = fopen (arg, "w");
-                       g_assert (logfile);
-               } else {
-                       fprintf (stderr, "Invalid format for the MONO_GCMAP_DEBUG env variable: '%s'\n", env);
-                       exit (1);
-               }
+               /* No options yet */
+               fprintf (stderr, "Invalid format for the MONO_GCMAP_DEBUG env variable: '%s'\n", env);
+               exit (1);
        }
        g_strfreev (opts);
 }
@@ -2291,7 +2284,8 @@ mini_gc_init (void)
        cb.thread_mark_func = thread_mark_func;
        mono_gc_set_gc_callbacks (&cb);
 
-       logfile = stdout;
+       logfile = mono_sgen_get_logfile ();
+
        parse_debug_options ();
 
        mono_counters_register ("GC Maps size",
index 33fd0063ea200a1481f1d9ae873a24210ce26b4b..b9b48ff3c93de1dfba6146b0502ee1212f368cf2 100644 (file)
@@ -6099,6 +6099,9 @@ mini_init (const char *filename, const char *runtime_version)
 
        mono_icall_init ();
 
+       /* This should come after mono_init () too */
+       mini_gc_init ();
+
        mono_add_internal_call ("System.Diagnostics.StackFrame::get_frame_info", 
                                ves_icall_get_frame_info);
        mono_add_internal_call ("System.Diagnostics.StackTrace::get_trace",