/* * mono_save_xdebug_info: * * Emit debugging info for METHOD into an assembly file which can be assembled * and loaded into gdb to provide debugging info for JITted code. * LOCKING: Acquires the loader lock. */ void mono_save_xdebug_info (MonoCompile *cfg) { MonoDebugMethodJitInfo *dmji; if (use_gdb_interface) { mono_loader_lock (); if (!xdebug_syms) xdebug_syms = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); /* * gdb is not designed to handle 1000s of symbol files (one per method). So we * group them into groups of 100. */ if ((xdebug_method_count % 100) == 0) mono_xdebug_flush (); xdebug_method_count ++; dmji = mono_debug_find_method (cfg->jit_info->method, mono_domain_get ());; mono_dwarf_writer_emit_method (xdebug_writer, cfg, cfg->jit_info->method, NULL, NULL, cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji); mono_debug_free_method_jit_info (dmji); #if 0 /* * Emit a symbol for the code by emitting it at the beginning of the text * segment, and setting the text segment to have an absolute address. * This symbol can be used to set breakpoints in gdb. * FIXME: This doesn't work when multiple methods are emitted into the same file. */ sym = get_debug_sym (cfg->jit_info->method, "", xdebug_syms); img_writer_emit_section_change (w, ".text", 0); if (!xdebug_text_addr) { xdebug_text_addr = cfg->jit_info->code_start; img_writer_set_section_addr (w, (gssize)xdebug_text_addr); } img_writer_emit_global_with_size (w, sym, cfg->jit_info->code_size, TRUE); img_writer_emit_label (w, sym); img_writer_emit_bytes (w, cfg->jit_info->code_start, cfg->jit_info->code_size); g_free (sym); #endif mono_loader_unlock (); } else { if (!xdebug_writer) return; mono_loader_lock (); dmji = mono_debug_find_method (cfg->jit_info->method, mono_domain_get ());; mono_dwarf_writer_emit_method (xdebug_writer, cfg, cfg->jit_info->method, NULL, NULL, cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, dmji); mono_debug_free_method_jit_info (dmji); fflush (xdebug_fp); mono_loader_unlock (); } }
/** * mono_gc_get_managed_allocator_id: * * Return a type for the managed allocator method MANAGED_ALLOC which can later be passed * to mono_gc_get_managed_allocator_by_type () to get back this allocator method. This can be * used by the AOT code to encode references to managed allocator methods. */ int mono_gc_get_managed_allocator_type (MonoMethod *managed_alloc) { int i; mono_loader_lock (); for (i = 0; i < ATYPE_NUM; ++i) { if (alloc_method_cache [i] == managed_alloc) { mono_loader_unlock (); return i; } } mono_loader_unlock (); return -1; }
/** * mono_gc_get_managed_allocator_by_type: * * Return a managed allocator method corresponding to allocator type ATYPE. */ MonoMethod* mono_gc_get_managed_allocator_by_type (int atype) { int offset = -1; MonoMethod *res; MONO_THREAD_VAR_OFFSET (GC_thread_tls, offset); mono_loader_lock (); res = alloc_method_cache [atype]; if (!res) res = alloc_method_cache [atype] = create_allocator (atype, offset); mono_loader_unlock (); return res; }
MonoMethod* mono_gc_get_managed_allocator_by_type (int atype) { #ifdef MANAGED_ALLOCATION MonoMethod *res; if (!mono_runtime_has_tls_get ()) return NULL; mono_loader_lock (); res = alloc_method_cache [atype]; if (!res) res = alloc_method_cache [atype] = create_allocator (atype); mono_loader_unlock (); return res; #else return NULL; #endif }
MonoClass * mono_debugger_register_class_init_callback (MonoImage *image, const gchar *full_name, guint32 method_token, guint32 index) { ClassInitCallback *info; MonoClass *klass; gchar *name_space, *name, *pos; name = g_strdup (full_name); pos = strrchr (name, '.'); if (pos) { name_space = name; *pos = 0; name = pos + 1; } else { name_space = NULL; } mono_loader_lock (); klass = mono_class_from_name (image, name_space ? name_space : "", name); info = g_new0 (ClassInitCallback, 1); info->image = image; info->index = index; info->token = method_token; info->name_space = name_space; info->name = name; if (!class_init_callbacks) class_init_callbacks = g_ptr_array_new (); g_ptr_array_add (class_init_callbacks, info); mono_loader_unlock (); return klass; }