Log all sdb log messages to the log file instead of stdout.
[mono.git] / mono / mini / xdebug.c
index 671f68451c577ba5feeb8289f1fd95288ba965b7..136c214c311d66bb63bf8133afde0f00130c3a5e 100644 (file)
@@ -106,15 +106,23 @@ struct jit_descriptor
 void MONO_NOINLINE __jit_debug_register_code(void);
 
 #if !defined(MONO_LLVM_LOADED) && defined(ENABLE_LLVM) && ((LLVM_MAJOR_VERSION == 2 && LLVM_MINOR_VERSION >= 7) || LLVM_MAJOR_VERSION > 2)
+
 /* LLVM already defines these */
 extern struct jit_descriptor __jit_debug_descriptor;
+
 #else
 
 /* Make sure to specify the version statically, because the
    debugger may check the version before we can set it.  */
 struct jit_descriptor __jit_debug_descriptor = { 1, 0, 0, 0 };
 
-void MONO_NOINLINE __jit_debug_register_code(void) { };
+/* gcc seems to inline/eliminate calls to noinline functions, thus the asm () */
+void MONO_NOINLINE __jit_debug_register_code(void) {
+#if defined(__GNUC__)
+       asm ("");
+#endif
+}
+
 #endif
 
 static MonoImageWriter *xdebug_w;
@@ -142,6 +150,11 @@ mono_xdebug_init (char *options)
 
        /* This file will contain the IL code for methods which don't have debug info */
        il_file = fopen ("xdb.il", "w");
+       if (il_file == NULL) {
+               use_gdb_interface = FALSE;
+               g_warning ("** Unable to create xdb.il. Managed symbol names won't be available.");
+               return;
+       }
 
        if (use_gdb_interface)
                return;
@@ -325,29 +338,30 @@ mono_save_xdebug_info (MonoCompile *cfg)
  * LOCKING: Acquires the loader lock.
  */
 void
-mono_save_trampoline_xdebug_info (const char *tramp_name, guint8 *code, guint32 code_size, GSList *unwind_info)
+mono_save_trampoline_xdebug_info (MonoTrampInfo *info)
 {
        if (use_gdb_interface) {
                MonoImageWriter *w;
                MonoDwarfWriter *dw;
 
-               mono_loader_lock ();
+               /* This can be called before the loader lock is initialized */
+               mono_loader_lock_if_inited ();
 
                xdebug_begin_emit (&w, &dw);
 
-               mono_dwarf_writer_emit_trampoline (dw, tramp_name, NULL, NULL, code, code_size, unwind_info);
+               mono_dwarf_writer_emit_trampoline (dw, info->name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
 
                xdebug_end_emit (w, dw, NULL);
                
-               mono_loader_unlock ();
+               mono_loader_unlock_if_inited ();
        } else {
                if (!xdebug_writer)
                        return;
 
-               mono_loader_lock ();
-               mono_dwarf_writer_emit_trampoline (xdebug_writer, tramp_name, NULL, NULL, code, code_size, unwind_info);
+               mono_loader_lock_if_inited ();
+               mono_dwarf_writer_emit_trampoline (xdebug_writer, info->name, NULL, NULL, info->code, info->code_size, info->unwind_ops);
                fflush (xdebug_fp);
-               mono_loader_unlock ();
+               mono_loader_unlock_if_inited ();
        }
 }
 
@@ -364,7 +378,7 @@ mono_save_xdebug_info (MonoCompile *cfg)
 }
 
 void
-mono_save_trampoline_xdebug_info (const char *tramp_name, guint8 *code, guint32 code_size, GSList *unwind_info)
+mono_save_trampoline_xdebug_info (MonoTrampInfo *info)
 {
 }