Permalink
Browse files

Free debug info for dynamic methods by storing it in malloc-ed memory…

… instead of the normal debugger tables. Fixes #731579.
  • Loading branch information...
1 parent 6177d7a commit 64d35e3940f7b0e1839c1906855c29862e6ab8c1 @vargaz vargaz committed Nov 20, 2011
Showing with 46 additions and 3 deletions.
  1. +41 −3 mono/metadata/mono-debug.c
  2. +3 −0 mono/metadata/mono-debug.h
  3. +2 −0 mono/mini/mini.c
View
@@ -653,8 +653,12 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma
g_assert (size < max_size);
total_size = size + sizeof (MonoDebugMethodAddress);
- address = (MonoDebugMethodAddress *) allocate_data_item (
- table, MONO_DEBUG_DATA_ITEM_METHOD, total_size);
+ if (method->dynamic) {
+ address = g_malloc0 (total_size);
+ } else {
+ address = (MonoDebugMethodAddress *) allocate_data_item (
+ table, MONO_DEBUG_DATA_ITEM_METHOD, total_size);
+ }
address->header.size = total_size;
address->header.symfile_id = handle ? handle->index : 0;
@@ -692,13 +696,47 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma
g_hash_table_insert (table->method_address_hash, method, address);
- write_data_item (table, (guint8 *) address);
+ if (!method->dynamic)
+ write_data_item (table, (guint8 *) address);
mono_debugger_unlock ();
return address;
}
void
+mono_debug_remove_method (MonoMethod *method, MonoDomain *domain)
+{
+ MonoMethod *declaring;
+ MonoDebugDataTable *table;
+ MonoDebugMethodHeader *header;
+ MonoDebugMethodAddress *address;
+
+ g_assert (method->dynamic);
+
+ mono_debugger_lock ();
+
+ table = lookup_data_table (domain);
+
+ declaring = method->is_inflated ? ((MonoMethodInflated *) method)->declaring : method;
+ g_hash_table_remove (table->method_hash, declaring);
+
+ address = g_hash_table_lookup (table->method_address_hash, method);
+ if (address) {
+ header = &address->header;
+
+ if (header->wrapper_data) {
+ g_free ((char*)header->wrapper_data->method_name);
+ g_free (header->wrapper_data);
+ }
+ g_free (address);
+ }
+
+ g_hash_table_remove (table->method_address_hash, method);
+
+ mono_debugger_unlock ();
+}
+
+void
mono_debug_add_delegate_trampoline (gpointer code, int size)
{
MonoDebugDelegateTrampolineEntry *entry;
@@ -157,6 +157,9 @@ mono_bool mono_debug_using_mono_debugger (void);
MonoDebugMethodAddress *
mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
+void
+mono_debug_remove_method (MonoMethod *method, MonoDomain *domain);
+
MonoDebugMethodInfo *
mono_debug_lookup_method (MonoMethod *method);
View
@@ -5456,6 +5456,8 @@ mono_jit_free_method (MonoDomain *domain, MonoMethod *method)
if (!ji)
return;
+ mono_debug_remove_method (method, domain);
+
mono_domain_lock (domain);
g_hash_table_remove (domain_jit_info (domain)->dynamic_code_hash, method);
mono_internal_hash_table_remove (&domain->jit_code_hash, method);

0 comments on commit 64d35e3

Please sign in to comment.