Author: martin
Date: 2007-07-04 21:46:04 -0400 (Wed, 04 Jul 2007)
New Revision: 81364

Modified:
   branches/martin/debugger-dublin/runtime/metadata/mono-debug.c
   branches/martin/debugger-dublin/runtime/metadata/mono-debug.h
   branches/martin/debugger-dublin/runtime/mini/debug-debugger.c
   branches/martin/debugger-dublin/runtime/mini/debug-debugger.h
   branches/martin/debugger-dublin/runtime/mini/debug-mini.c
Log:
Daily backup July 4th.

Modified: branches/martin/debugger-dublin/runtime/metadata/mono-debug.c
===================================================================
--- branches/martin/debugger-dublin/runtime/metadata/mono-debug.c       
2007-07-05 00:34:44 UTC (rev 81363)
+++ branches/martin/debugger-dublin/runtime/metadata/mono-debug.c       
2007-07-05 01:46:04 UTC (rev 81364)
@@ -31,14 +31,72 @@
        (*(type *)(addr) = (val))
 #endif
 
+typedef struct {
+       const guint8 *wrapper_addr;
+       const gchar *method_name;
+       const gchar *cil_code;
+       guint32 wrapper_type;
+} MonoDebugWrapperData;
+
+struct _MonoDebugMethodAddress {
+       guint32 size;
+       guint32 symfile_id;
+       guint32 domain_id;
+       guint32 method_id;
+       MonoMethod *method;
+       const guint8 *code_start;
+       MonoDebugWrapperData *wrapper_data;
+       guint32 code_size;
+       guint8 data [MONO_ZERO_LEN_ARRAY];
+};
+
+typedef struct {
+       guint32 size;
+       guint32 symfile_id;
+       guint32 domain_id;
+       guint32 method_id;
+       guint32 code_size;
+       guint32 dummy;
+       const guint8 *code_start;
+       const guint8 *wrapper_addr;
+       MonoDebugMethodJitInfo *jit;
+       guint8 data [MONO_ZERO_LEN_ARRAY];
+} MonoDebugOldMethodAddress;
+
+typedef struct {
+       guint32 size;
+       guint32 code_size;
+       MonoMethod *method;
+       const guint8 *code_start;
+       const gchar *name;
+       const gchar *cil_code;
+       guint8 data [MONO_ZERO_LEN_ARRAY];
+} MonoDebugOldWrapperData;
+
+typedef struct {
+       MonoMethod *method;
+       guint32 domain_id;
+} MonoDebugMethodHash;
+
+struct _MonoDebugMethodHeader {
+       MonoMethod *method;
+       MonoDomain *domain;
+       union {
+               MonoDebugMethodAddress *address;
+               MonoDebugOldMethodAddress *old_address;
+               MonoDebugOldWrapperData *old_wrapper;
+       } data;
+};
+
 MonoSymbolTable *mono_symbol_table = NULL;
 MonoDebugFormat mono_debug_format = MONO_DEBUG_FORMAT_NONE;
-guint32 mono_debug_debugger_version = -1;
+gint32 mono_debug_debugger_version = -1;
 
 static gboolean in_the_mono_debugger = FALSE;
 static gboolean mono_debug_initialized = FALSE;
 GHashTable *mono_debug_handles = NULL;
 
+static GHashTable *old_method_hash = NULL;
 static GHashTable *method_hash = NULL;
 
 static MonoDebugHandle     *mono_debug_open_image      (MonoImage *image, 
const guint8 *raw_contents, int size);
@@ -54,30 +112,25 @@
 extern void (*mono_debugger_class_init_func) (MonoClass *klass);
 extern void (*mono_debugger_start_class_init_func) (MonoClass *klass);
 
-typedef struct {
-       guint32 symfile_id;
-       guint32 domain_id;
-       guint32 method_id;
-} MethodHashEntry;
-
 static guint
 method_hash_hash (gconstpointer data)
 {
-       const MethodHashEntry *entry = (const MethodHashEntry *) data;
-       return entry->symfile_id | (entry->domain_id << 16);
+       const MonoDebugMethodHash *hash = (const MonoDebugMethodHash *) data;
+       return hash->method->token | (hash->domain_id << 16);
 }
 
 static gint
 method_hash_equal (gconstpointer ka, gconstpointer kb)
 {
-       const MethodHashEntry *a = (const MethodHashEntry *) ka;
-       const MethodHashEntry *b = (const MethodHashEntry *) kb;
+       const MonoDebugMethodHash *a = (const MonoDebugMethodHash *) ka;
+       const MonoDebugMethodHash *b = (const MonoDebugMethodHash *) kb;
 
-       if ((a->symfile_id != b->symfile_id) || (a->method_id != b->method_id) 
|| (a->domain_id != b->domain_id))
+       if ((a->method != b->method) || (a->domain_id != b->domain_id))
                return 0;
        return 1;
 }
 
+
 /*
  * Initialize debugging support.
  *
@@ -106,6 +159,7 @@
        mono_debug_handles = g_hash_table_new_full
                (NULL, NULL, NULL, (GDestroyNotify) mono_debug_close_image);
        method_hash = g_hash_table_new (method_hash_hash, method_hash_equal);
+       old_method_hash = g_hash_table_new (method_hash_hash, 
method_hash_equal);
 
        mono_debugger_start_class_init_func = mono_debug_start_add_type;
        mono_debugger_class_init_func = mono_debug_add_type;
@@ -397,11 +451,11 @@
        *rptr = ptr;
 }
 
-static MonoDebugWrapperData *
-mono_debug_add_wrapper (MonoMethod *method, MonoDebugMethodJitInfo *jit)
+static void
+mono_debug_old_add_wrapper (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain)
 {
-       MonoMethodHeader *header;
-       MonoDebugWrapperData *wrapper;
+       MonoMethodHeader *mheader;
+       MonoDebugOldWrapperData *wrapper;
        guint8 buffer [BUFSIZ];
        guint8 *ptr, *oldptr;
        guint32 i, size, total_size, max_size;
@@ -410,11 +464,11 @@
        guint32 il_codesize;
 
        if (!in_the_mono_debugger)
-               return NULL;
+               return;
 
        mono_debugger_lock ();
 
-       header = mono_method_get_header (method);
+       mheader = mono_method_get_header (method);
 
        max_size = 28 * jit->num_line_numbers;
        if (max_size > BUFSIZ)
@@ -439,7 +493,7 @@
 
        size = ptr - oldptr;
        g_assert (size < max_size);
-       total_size = size + sizeof (MonoDebugWrapperData);
+       total_size = size + sizeof (MonoDebugOldWrapperData);
 
        if (total_size + 9 >= DATA_TABLE_CHUNK_SIZE) {
                // FIXME: Maybe we should print a warning here.
@@ -447,10 +501,10 @@
                //        with more than 40.000 line numbers and more than 5.000
                //        local variables.
                mono_debugger_unlock ();
-               return NULL;
+               return;
        }
 
-       wrapper = (MonoDebugWrapperData *) allocate_data_item 
(MONO_DEBUG_DATA_ITEM_WRAPPER, total_size);
+       wrapper = (MonoDebugOldWrapperData *) allocate_data_item 
(MONO_DEBUG_DATA_ITEM_OLD_WRAPPER, total_size);
 
        wrapper->method = method;
        wrapper->size = total_size;
@@ -458,58 +512,54 @@
        wrapper->code_size = jit->code_size;
        wrapper->name = mono_method_full_name (method, TRUE);
 
-       il_code = mono_method_header_get_code (header, &il_codesize, NULL);
-       wrapper->cil_code = mono_disasm_code (
-               NULL, method, il_code, il_code + il_codesize);
+       il_code = mono_method_header_get_code (mheader, &il_codesize, NULL);
+       wrapper->cil_code = mono_disasm_code (NULL, method, il_code, il_code + 
il_codesize);
 
        memcpy (&wrapper->data, oldptr, size);
-
        if (max_size > BUFSIZ)
                g_free (oldptr);
 
        mono_debugger_unlock ();
-
-       return wrapper;
 }
 
 /*
  * This is called by the JIT to tell the debugging code about a newly
  * compiled method.
  */
-MonoDebugMethodAddress *
-mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain)
+static void
+mono_debug_old_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain)
 {
-       MonoDebugMethodAddress *address;
+       MonoDebugMethodHash *hash;
+       MonoDebugOldMethodAddress *address;
        guint8 buffer [BUFSIZ];
        guint8 *ptr, *oldptr;
        guint32 i, size, total_size, max_size;
        gint32 last_il_offset = 0, last_native_offset = 0;
        MonoDebugHandle *handle;
        MonoDebugMethodInfo *minfo;
-       MethodHashEntry *hash;
 
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
            (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
            (method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
            (method->wrapper_type != MONO_WRAPPER_NONE)) {
-               mono_debug_add_wrapper (method, jit);
-               return NULL;
+               mono_debug_old_add_wrapper (method, jit, domain);
+               return;
        }
 
        mono_debugger_lock ();
 
        handle = _mono_debug_get_image (method->klass->image);
        if (!handle || !handle->symfile || !handle->symfile->offset_table) {
-               mono_debug_add_wrapper (method, jit);
+               mono_debug_old_add_wrapper (method, jit, domain);
                mono_debugger_unlock ();
-               return NULL;
+               return;
        }
 
        minfo = _mono_debug_lookup_method (method);
        if (!minfo) {
                mono_debugger_unlock ();
-               return NULL;
+               return;
        }
 
        max_size = 24 + 8 * jit->num_line_numbers + 16 * 
minfo->num_lexical_blocks + 20 * (1 + jit->num_params + jit->num_locals);
@@ -577,7 +627,7 @@
 
        size = ptr - oldptr;
        g_assert (size < max_size);
-       total_size = size + sizeof (MonoDebugMethodAddress);
+       total_size = size + sizeof (MonoDebugOldMethodAddress);
 
        if (total_size + 9 >= DATA_TABLE_CHUNK_SIZE) {
                // FIXME: Maybe we should print a warning here.
@@ -585,10 +635,10 @@
                //        with more than 40.000 line numbers and more than 5.000
                //        local variables.
                mono_debugger_unlock ();
-               return NULL;
+               return;
        }
 
-       address = (MonoDebugMethodAddress *) allocate_data_item 
(MONO_DEBUG_DATA_ITEM_METHOD, total_size);
+       address = (MonoDebugOldMethodAddress *) allocate_data_item 
(MONO_DEBUG_DATA_ITEM_OLD_METHOD, total_size);
 
        address->size = total_size;
        address->symfile_id = handle->index;
@@ -599,19 +649,168 @@
        address->wrapper_addr = jit->wrapper_addr;
 
        memcpy (&address->data, oldptr, size);
+       if (max_size > BUFSIZ)
+               g_free (oldptr);
 
+       hash = g_new0 (MonoDebugMethodHash, 1);
+       hash->method = method;
+       hash->domain_id = mono_domain_get_id (domain);
+
+       g_hash_table_insert (old_method_hash, hash, address);
+
+       mono_debugger_unlock ();
+}
+
+MonoDebugMethodAddress *
+mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain)
+{
+       MonoDebugMethodHash *hash;
+       MonoDebugMethodAddress *address;
+       MonoDebugMethodInfo *minfo;
+       MonoDebugHandle *handle;
+       guint8 buffer [BUFSIZ];
+       guint8 *ptr, *oldptr;
+       guint32 i, size, total_size, max_size;
+       gint32 last_il_offset = 0, last_native_offset = 0;
+       gboolean is_wrapper = FALSE;
+
+       if (mono_debug_debugger_version < 2) {
+               mono_debug_old_add_method (method, jit, domain);
+               return NULL;
+       }
+
+       mono_debugger_lock ();
+
+       handle = _mono_debug_get_image (method->klass->image);
+       minfo = _mono_debug_lookup_method (method);
+
+       if (!minfo || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
+           (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
+           (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
+           (method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
+           (method->wrapper_type != MONO_WRAPPER_NONE)) {
+               is_wrapper = TRUE;
+       }
+
+       jit->num_lexical_blocks = minfo ? minfo->num_lexical_blocks : 0;
+
+       max_size = 24 + 8 * jit->num_line_numbers + 16 * 
jit->num_lexical_blocks +
+               20 * (1 + jit->num_params + jit->num_locals);
+
        if (max_size > BUFSIZ)
+               ptr = oldptr = g_malloc (max_size);
+       else
+               ptr = oldptr = buffer;
+
+       write_leb128 (jit->prologue_end, ptr, &ptr);
+       write_leb128 (jit->epilogue_begin, ptr, &ptr);
+
+       write_leb128 (jit->num_line_numbers, ptr, &ptr);
+       for (i = 0; i < jit->num_line_numbers; i++) {
+               MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
+
+               write_sleb128 (lne->il_offset - last_il_offset, ptr, &ptr);
+               write_sleb128 (lne->native_offset - last_native_offset, ptr, 
&ptr);
+
+               last_il_offset = lne->il_offset;
+               last_native_offset = lne->native_offset;
+       }
+
+       jit->lexical_blocks = g_new0 (MonoDebugLexicalBlockEntry, 
jit->num_lexical_blocks);
+       for (i = 0; i < jit->num_lexical_blocks; i ++) {
+               MonoDebugLexicalBlockEntry *jit_lbe = &jit->lexical_blocks [i];
+               MonoSymbolFileLexicalBlockEntry *minfo_lbe = 
&minfo->lexical_blocks [i];
+               jit_lbe->il_start_offset = read32 (&(minfo_lbe->_start_offset));
+               jit_lbe->native_start_offset = 
_mono_debug_address_from_il_offset (jit, jit_lbe->il_start_offset);
+
+               jit_lbe->il_end_offset = read32 (&(minfo_lbe->_end_offset));
+               jit_lbe->native_end_offset = _mono_debug_address_from_il_offset 
(jit, jit_lbe->il_end_offset);
+       }
+
+       last_il_offset = 0;
+       last_native_offset = 0;
+       write_leb128 (jit->num_lexical_blocks, ptr, &ptr);
+       for (i = 0; i < jit->num_lexical_blocks; i++) {
+               MonoDebugLexicalBlockEntry *lbe = &jit->lexical_blocks [i];
+
+               write_sleb128 (lbe->il_start_offset - last_il_offset, ptr, 
&ptr);
+               write_sleb128 (lbe->native_start_offset - last_native_offset, 
ptr, &ptr);
+
+               last_il_offset = lbe->il_start_offset;
+               last_native_offset = lbe->native_start_offset;
+
+               write_sleb128 (lbe->il_end_offset - last_il_offset, ptr, &ptr);
+               write_sleb128 (lbe->native_end_offset - last_native_offset, 
ptr, &ptr);
+
+               last_il_offset = lbe->il_end_offset;
+               last_native_offset = lbe->native_end_offset;
+       }
+
+       *ptr++ = jit->this_var ? 1 : 0;
+       if (jit->this_var)
+               write_variable (jit->this_var, ptr, &ptr);
+
+       write_leb128 (jit->num_params, ptr, &ptr);
+       for (i = 0; i < jit->num_params; i++)
+               write_variable (&jit->params [i], ptr, &ptr);
+
+       write_leb128 (jit->num_locals, ptr, &ptr);
+       for (i = 0; i < jit->num_locals; i++)
+               write_variable (&jit->locals [i], ptr, &ptr);
+
+       size = ptr - oldptr;
+       g_assert (size < max_size);
+       total_size = size + sizeof (MonoDebugOldMethodAddress);
+
+       if (total_size + 9 >= DATA_TABLE_CHUNK_SIZE) {
+               // FIXME: Maybe we should print a warning here.
+               //        This should only happen for very big methods, for 
instance
+               //        with more than 40.000 line numbers and more than 5.000
+               //        local variables.
+               g_warning (G_STRLOC);
+               mono_debugger_unlock ();
+               return NULL;
+       }
+
+       address = (MonoDebugMethodAddress *) allocate_data_item 
(MONO_DEBUG_DATA_ITEM_METHOD, total_size);
+
+       address->size = total_size;
+       address->symfile_id = handle ? handle->index : 0;
+       address->domain_id = mono_domain_get_id (domain);
+       address->method_id = is_wrapper ? 0 : minfo->index;
+
+       address->code_start = jit->code_start;
+       address->code_size = jit->code_size;
+       address->method = method;
+
+       if (is_wrapper) {
+               const unsigned char* il_code;
+               MonoMethodHeader *mheader;
+               MonoDebugWrapperData *wrapper;
+               guint32 il_codesize;
+
+               mheader = mono_method_get_header (method);
+               il_code = mono_method_header_get_code (mheader, &il_codesize, 
NULL);
+
+               address->wrapper_data = wrapper = g_new0 (MonoDebugWrapperData, 
1);
+
+               wrapper->wrapper_addr = jit->wrapper_addr;
+               wrapper->wrapper_type = method->wrapper_type;
+               wrapper->method_name = mono_method_full_name (method, TRUE);
+               wrapper->cil_code = mono_disasm_code (NULL, method, il_code, 
il_code + il_codesize);
+       }
+
+       memcpy (&address->data, oldptr, size);
+       if (max_size > BUFSIZ)
                g_free (oldptr);
 
-       hash = g_new0 (MethodHashEntry, 1);
-       hash->symfile_id = address->symfile_id;
-       hash->domain_id = address->domain_id;
-       hash->method_id = address->method_id;
+       hash = g_new0 (MonoDebugMethodHash, 1);
+       hash->method = method;
+       hash->domain_id = mono_domain_get_id (domain);
 
        g_hash_table_insert (method_hash, hash, address);
 
        mono_debugger_unlock ();
-
        return address;
 }
 
@@ -668,8 +867,8 @@
        *rptr = ptr;
 }
 
-MonoDebugMethodJitInfo *
-mono_debug_read_method (MonoDebugMethodAddress *address)
+static MonoDebugMethodJitInfo *
+mono_debug_old_read_method (MonoDebugOldMethodAddress *address)
 {
        MonoDebugMethodJitInfo *jit;
        guint32 i, il_offset = 0, native_offset = 0;
@@ -738,17 +937,71 @@
        return jit;
 }
 
-void
-mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit)
+static MonoDebugMethodJitInfo *
+mono_debug_read_method (MonoDebugMethodAddress *address)
 {
-       if (jit->address)
-               jit->address->jit = NULL;
+       MonoDebugMethodJitInfo *jit;
+       guint32 i, il_offset = 0, native_offset = 0;
+       guint8 *ptr;
 
-       g_free (jit->line_numbers);
-       g_free (jit->this_var);
-       g_free (jit->params);
-       g_free (jit->locals);
-       g_free (jit);
+       jit = g_new0 (MonoDebugMethodJitInfo, 1);
+       jit->code_start = address->code_start;
+       jit->code_size = address->code_size;
+       jit->wrapper_addr = address->wrapper_data ? 
address->wrapper_data->wrapper_addr : NULL;
+
+       ptr = (guint8 *) &address->data;
+
+       jit->prologue_end = read_leb128 (ptr, &ptr);
+       jit->epilogue_begin = read_leb128 (ptr, &ptr);
+
+       jit->num_line_numbers = read_leb128 (ptr, &ptr);
+       jit->line_numbers = g_new0 (MonoDebugLineNumberEntry, 
jit->num_line_numbers);
+       for (i = 0; i < jit->num_line_numbers; i++) {
+               MonoDebugLineNumberEntry *lne = &jit->line_numbers [i];
+
+               il_offset += read_sleb128 (ptr, &ptr);
+               native_offset += read_sleb128 (ptr, &ptr);
+
+               lne->il_offset = il_offset;
+               lne->native_offset = native_offset;
+       }
+
+       il_offset = 0;
+       native_offset = 0;
+       jit->num_lexical_blocks = read_leb128 (ptr, &ptr);
+       jit->lexical_blocks = g_new0 (MonoDebugLexicalBlockEntry, 
jit->num_lexical_blocks);
+       for (i = 0; i < jit->num_lexical_blocks; i ++) {
+               MonoDebugLexicalBlockEntry *lbe = &jit->lexical_blocks [i];
+
+               il_offset += read_sleb128 (ptr, &ptr);
+               native_offset += read_sleb128 (ptr, &ptr);
+
+               lbe->il_start_offset = il_offset;
+               lbe->native_start_offset = native_offset;
+
+               il_offset += read_sleb128 (ptr, &ptr);
+               native_offset += read_sleb128 (ptr, &ptr);
+
+               lbe->il_end_offset = il_offset;
+               lbe->native_end_offset = native_offset;
+       }
+
+       if (*ptr++) {
+               jit->this_var = g_new0 (MonoDebugVarInfo, 1);
+               read_variable (jit->this_var, ptr, &ptr);
+       }
+
+       jit->num_params = read_leb128 (ptr, &ptr);
+       jit->params = g_new0 (MonoDebugVarInfo, jit->num_params);
+       for (i = 0; i < jit->num_params; i++)
+               read_variable (&jit->params [i], ptr, &ptr);
+
+       jit->num_locals = read_leb128 (ptr, &ptr);
+       jit->locals = g_new0 (MonoDebugVarInfo, jit->num_locals);
+       for (i = 0; i < jit->num_locals; i++)
+               read_variable (&jit->locals [i], ptr, &ptr);
+
+       return jit;
 }
 
 /*
@@ -817,39 +1070,49 @@
 }
 
 static MonoDebugMethodJitInfo *
-find_method (MonoDebugMethodInfo *minfo, MonoDomain *domain)
+find_method (MonoMethod *method, MonoDomain *domain)
 {
-       MethodHashEntry lookup;
-       MonoDebugMethodAddress *address;
+       MonoDebugMethodHash lookup;
 
-       lookup.symfile_id = minfo->handle->index;
+       lookup.method = method;
        lookup.domain_id = mono_domain_get_id (domain);
-       lookup.method_id = minfo->index;
 
-       address = g_hash_table_lookup (method_hash, &lookup);
-       if (!address)
-               return NULL;
+       if (mono_debug_debugger_version < 2) {
+               MonoDebugOldMethodAddress *address;
 
-       return mono_debug_read_method (address);
+               address = g_hash_table_lookup (old_method_hash, &lookup);
+               if (!address)
+                       return NULL;
+
+               return mono_debug_old_read_method (address);
+       } else {
+               MonoDebugMethodAddress *address;
+
+               address = g_hash_table_lookup (method_hash, &lookup);
+               if (!address)
+                       return NULL;
+
+               return mono_debug_read_method (address);
+       }
 }
 
 MonoDebugMethodJitInfo *
-mono_debug_find_method (MonoDebugMethodInfo *minfo, MonoDomain *domain)
+mono_debug_find_method (MonoMethod *method, MonoDomain *domain)
 {
        MonoDebugMethodJitInfo *res;
        mono_debugger_lock ();
-       res = find_method (minfo, domain);
+       res = find_method (method, domain);
        mono_debugger_unlock ();
        return res;
 }
 
 static gint32
-il_offset_from_address (MonoDebugMethodInfo *minfo, MonoDomain *domain, 
guint32 native_offset)
+il_offset_from_address (MonoMethod *method, MonoDomain *domain, guint32 
native_offset)
 {
        MonoDebugMethodJitInfo *jit;
        int i;
 
-       jit = find_method (minfo, domain);
+       jit = find_method (method, domain);
        if (!jit || !jit->line_numbers)
                return -1;
 
@@ -891,7 +1154,7 @@
                return NULL;
        }
 
-       offset = il_offset_from_address (minfo, domain, address);
+       offset = il_offset_from_address (method, domain, address);
        if (offset < 0) {
                mono_debugger_unlock ();
                return NULL;

Modified: branches/martin/debugger-dublin/runtime/metadata/mono-debug.h
===================================================================
--- branches/martin/debugger-dublin/runtime/metadata/mono-debug.h       
2007-07-05 00:34:44 UTC (rev 81363)
+++ branches/martin/debugger-dublin/runtime/metadata/mono-debug.h       
2007-07-05 01:46:04 UTC (rev 81364)
@@ -24,7 +24,6 @@
 typedef struct _MonoDebugVarInfo               MonoDebugVarInfo;
 typedef struct _MonoDebugMethodJitInfo         MonoDebugMethodJitInfo;
 typedef struct _MonoDebugMethodAddress         MonoDebugMethodAddress;
-typedef struct _MonoDebugWrapperData           MonoDebugWrapperData;
 typedef struct _MonoDebugClassEntry            MonoDebugClassEntry;
 
 typedef struct _MonoDebugMethodInfo            MonoDebugMethodInfo;
@@ -95,9 +94,10 @@
 
 typedef enum {
        MONO_DEBUG_DATA_ITEM_UNKNOWN            = 0,
-       MONO_DEBUG_DATA_ITEM_METHOD,
+       MONO_DEBUG_DATA_ITEM_OLD_METHOD,
        MONO_DEBUG_DATA_ITEM_CLASS,
-       MONO_DEBUG_DATA_ITEM_WRAPPER
+       MONO_DEBUG_DATA_ITEM_OLD_WRAPPER,
+       MONO_DEBUG_DATA_ITEM_METHOD
 } MonoDebugDataItemType;
 
 struct _MonoDebugHandle {
@@ -109,7 +109,6 @@
 };
 
 struct _MonoDebugMethodJitInfo {
-       MonoDebugMethodAddress *address;
        const guint8 *code_start;
        guint32 code_size;
        guint32 prologue_end;
@@ -126,29 +125,6 @@
        MonoDebugVarInfo *locals;
 };
 
-struct _MonoDebugMethodAddress {
-       guint32 size;
-       guint32 symfile_id;
-       guint32 domain_id;
-       guint32 method_id;
-       guint32 code_size;
-       guint32 dummy;
-       const guint8 *code_start;
-       const guint8 *wrapper_addr;
-       MonoDebugMethodJitInfo *jit;
-       guint8 data [MONO_ZERO_LEN_ARRAY];
-};
-
-struct _MonoDebugWrapperData {
-       guint32 size;
-       guint32 code_size;
-       MonoMethod *method;
-       const guint8 *code_start;
-       const gchar *name;
-       const gchar *cil_code;
-       guint8 data [MONO_ZERO_LEN_ARRAY];
-};
-
 struct _MonoDebugClassEntry {
        guint32 size;
        guint32 symfile_id;
@@ -192,7 +168,7 @@
 extern MonoSymbolTable *mono_symbol_table;
 extern MonoDebugFormat mono_debug_format;
 extern GHashTable *mono_debug_handles;
-extern guint32 mono_debug_debugger_version;
+extern gint32 mono_debug_debugger_version;
 
 void mono_debug_init (MonoDebugFormat format);
 void mono_debug_init_1 (MonoDomain *domain);
@@ -202,15 +178,14 @@
 
 gboolean mono_debug_using_mono_debugger (void);
 
-MonoDebugMethodAddress *mono_debug_add_method (MonoMethod *method, 
MonoDebugMethodJitInfo *jit,
-                                              MonoDomain *domain);
-MonoDebugMethodJitInfo *mono_debug_read_method (MonoDebugMethodAddress 
*address);
-void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
+MonoDebugMethodAddress *
+mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, 
MonoDomain *domain);
 
-MonoDebugMethodInfo *mono_debug_lookup_method (MonoMethod *method);
+MonoDebugMethodInfo *
+mono_debug_lookup_method (MonoMethod *method);
 
 MonoDebugMethodJitInfo*
-mono_debug_find_method (MonoDebugMethodInfo *minfo, MonoDomain *domain);
+mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
 
 /*
  * Line number support.

Modified: branches/martin/debugger-dublin/runtime/mini/debug-debugger.c
===================================================================
--- branches/martin/debugger-dublin/runtime/mini/debug-debugger.c       
2007-07-05 00:34:44 UTC (rev 81363)
+++ branches/martin/debugger-dublin/runtime/mini/debug-debugger.c       
2007-07-05 01:46:04 UTC (rev 81364)
@@ -301,9 +301,9 @@
 {
        MonoMethod *method = GUINT_TO_POINTER ((gsize) method_argument);
        MonoDomain *domain = mono_get_root_domain ();
-       MonoJitInfo *info;
+       MonoDebugMethodAddress *address;
 
-       mono_domain_lock (domain);
+       mono_debugger_lock ();
 
        if (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) {
                const char *name = method->name;
@@ -319,20 +319,21 @@
                }
 
                if (!nm) {
-                       mono_domain_unlock (domain);
+                       mono_debugger_unlock ();
                        return -1;
                }
 
                method = nm;
        }
 
-       if ((info = mono_internal_hash_table_lookup (&domain->jit_code_hash, 
method))) {
-               mono_domain_unlock (domain);
-               return (gint64) (gssize) info->code_start;
+       address = mono_debug_find_method (method, domain);
+       if (address) {
+               mono_debugger_unlock ();
+               return (gint64) (gssize) address;
        }
 
        mono_debugger_insert_method_breakpoint (method, index);
-       mono_domain_unlock (domain);
+       mono_debugger_unlock ();
        return 0;
 }
 

Modified: branches/martin/debugger-dublin/runtime/mini/debug-debugger.h
===================================================================
--- branches/martin/debugger-dublin/runtime/mini/debug-debugger.h       
2007-07-05 00:34:44 UTC (rev 81363)
+++ branches/martin/debugger-dublin/runtime/mini/debug-debugger.h       
2007-07-05 01:46:04 UTC (rev 81364)
@@ -54,7 +54,7 @@
        void (*initialize) (void);
        void * (*get_lmf_addr) (void);
 
-       guint32 *debugger_version;
+       gint32 *debugger_version;
 
        guint64 (*create_string) (G_GNUC_UNUSED guint64 dummy1, G_GNUC_UNUSED 
guint64 dummy2,
                                  const gchar *string_argument);

Modified: branches/martin/debugger-dublin/runtime/mini/debug-mini.c
===================================================================
--- branches/martin/debugger-dublin/runtime/mini/debug-mini.c   2007-07-05 
00:34:44 UTC (rev 81363)
+++ branches/martin/debugger-dublin/runtime/mini/debug-mini.c   2007-07-05 
01:46:04 UTC (rev 81364)
@@ -41,7 +41,7 @@
 } MiniDebugMethodInfo;
 
 static void
-mono_debugger_check_breakpoints (MonoMethod *method, gconstpointer address);
+mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress 
*debug_info);
 
 static inline void
 record_line_number (MiniDebugMethodInfo *info, guint32 address, guint32 offset)
@@ -54,6 +54,16 @@
        g_array_append_val (info->line_numbers, lne);
 }
 
+static void
+mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit)
+{
+       g_free (jit->line_numbers);
+       g_free (jit->this_var);
+       g_free (jit->params);
+       g_free (jit->locals);
+       g_free (jit);
+}
+
 void
 mono_debug_init_method (MonoCompile *cfg, MonoBasicBlock *start_block, guint32 
breakpoint_id)
 {
@@ -259,7 +269,7 @@
        if (info->breakpoint_id)
                mono_debugger_breakpoint_callback (method, info->breakpoint_id);
 
-       mono_debugger_check_breakpoints (method, jit->code_start);
+       mono_debugger_check_breakpoints (method, debug_info);
 
        mono_debug_free_method_jit_info (jit);
        g_array_free (info->line_numbers, TRUE);
@@ -607,18 +617,13 @@
 {
        MonoDomain *domain = mono_domain_get ();
        MonoJitInfo *ji = mono_jit_info_table_find (domain, ip);
-       MonoDebugMethodInfo *minfo;
        MonoDebugMethodJitInfo *jit;
        int i;
 
        if (!ji)
                return;
 
-       minfo = mono_debug_lookup_method (mono_jit_info_get_method (ji));
-       if (!minfo)
-               return;
-
-       jit = mono_debug_find_method (minfo, domain);
+       jit = mono_debug_find_method (mono_jit_info_get_method (ji), domain);
        if (!jit)
                return;
 
@@ -688,7 +693,7 @@
 }
 
 static void
-mono_debugger_check_breakpoints (MonoMethod *method, gconstpointer address)
+mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress 
*debug_info)
 {
        gboolean first = TRUE;
        int i;
@@ -705,12 +710,12 @@
                if (first) {
                        mono_debugger_event (
                                MONO_DEBUGGER_EVENT_METHOD_COMPILED, (guint64) 
(gsize) method,
-                               (guint64) (gsize) address);
+                               (guint64) (gsize) debug_info);
                        first = FALSE;
                }
 
                mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
-                                    (guint64) (gsize) address, info->index);
+                                    (guint64) (gsize) debug_info, info->index);
        }
 }
 

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

Reply via email to