Author: martin
Date: 2007-11-20 14:34:24 -0500 (Tue, 20 Nov 2007)
New Revision: 90019

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/debug-debugger.c
   trunk/mono/mono/mini/debug-debugger.h
   trunk/mono/mono/mini/debug-mini.c
   trunk/mono/mono/mini/debug-mini.h
Log:
2007-11-20  Martin Baulig  <[EMAIL PROTECTED]>

        * debug-mini.c
        (mono_debugger_insert_method_breakpoint): Moved into 
mono-debug-debugger.c.
        (mono_debugger_remove_breakpoint): Likewise.
        (mono_debugger_check_breakpoints): Likewise.

        * debug-debugger.c: Implement the new breakpoint interface here.



Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-11-20 19:34:12 UTC (rev 90018)
+++ trunk/mono/mono/mini/ChangeLog      2007-11-20 19:34:24 UTC (rev 90019)
@@ -1,3 +1,12 @@
+2007-11-20  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * debug-mini.c
+       (mono_debugger_insert_method_breakpoint): Moved into 
mono-debug-debugger.c.
+       (mono_debugger_remove_breakpoint): Likewise.
+       (mono_debugger_check_breakpoints): Likewise.
+
+       * debug-debugger.c: Implement the new breakpoint interface here.
+
 2007-11-18  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * mini-amd64.c (mono_arch_output_basic_block): Unify the implementation 
of

Modified: trunk/mono/mono/mini/debug-debugger.c
===================================================================
--- trunk/mono/mono/mini/debug-debugger.c       2007-11-20 19:34:12 UTC (rev 
90018)
+++ trunk/mono/mono/mini/debug-debugger.c       2007-11-20 19:34:24 UTC (rev 
90019)
@@ -37,11 +37,16 @@
 static void debugger_initialize (void);
 
 static guint64 debugger_create_string (G_GNUC_UNUSED guint64 dummy, 
G_GNUC_UNUSED guint64 dummy2,
-                                      const gchar *string_argument);
+                                      G_GNUC_UNUSED guint64 dummy3, const 
gchar *string_argument);
 static gint64 debugger_lookup_class (guint64 image_argument, G_GNUC_UNUSED 
guint64 dummy,
-                                    gchar *full_name);
+                                    G_GNUC_UNUSED guint64 dummy2, gchar 
*full_name);
 static guint64 debugger_insert_method_breakpoint (guint64 method_argument, 
guint64 index);
-static void debugger_remove_method_breakpoint (G_GNUC_UNUSED guint64 dummy, 
guint64 index);
+static guint64 debugger_insert_source_breakpoint (guint64 image_argument, 
guint64 token,
+                                                 guint64 index, const gchar 
*class_name);
+static void debugger_remove_breakpoint (guint64 index, G_GNUC_UNUSED guint64 
dummy);
+static guint64 debugger_register_class_init_callback (guint64 image_argument, 
guint64 token,
+                                                     guint64 index, const 
gchar *class_name);
+static void debugger_remove_class_init_callback (guint64 index, G_GNUC_UNUSED 
guint64 dummy);
 
 static void (*mono_debugger_notification_function) (guint64 command, guint64 
data, guint64 data2);
 
@@ -112,9 +117,9 @@
        MONO_DEBUGGER_VERSION,
        sizeof (MonoDebuggerInfo),
        sizeof (MonoSymbolTable),
-       0,
+       MONO_TRAMPOLINE_NUM,
+       mono_trampoline_code,
        &mono_debugger_notification_function,
-       mono_trampoline_code,
        &mono_symbol_table,
        &debugger_metadata_info,
        &debugger_compile_method,
@@ -130,9 +135,14 @@
 
        &debugger_create_string,
        &debugger_lookup_class,
+
        &debugger_insert_method_breakpoint,
-       &debugger_remove_method_breakpoint,
+       &debugger_insert_source_breakpoint,
+       &debugger_remove_breakpoint,
 
+       &debugger_register_class_init_callback,
+       &debugger_remove_class_init_callback,
+
        &mono_debug_debugger_version,
        &mono_debugger_thread_table,
 
@@ -188,14 +198,14 @@
 
 static guint64
 debugger_create_string (G_GNUC_UNUSED guint64 dummy, G_GNUC_UNUSED guint64 
dummy2,
-                       const gchar *string_argument)
+                       G_GNUC_UNUSED guint64 dummy3, const gchar 
*string_argument)
 {
        return (guint64) (gsize) mono_string_new_wrapper (string_argument);
 }
 
 static gint64
 debugger_lookup_class (guint64 image_argument, G_GNUC_UNUSED guint64 dummy,
-                      gchar *full_name)
+                      G_GNUC_UNUSED guint64 dummy2, gchar *full_name)
 {
        MonoImage *image = (MonoImage *) GUINT_TO_POINTER ((gsize) 
image_argument);
        gchar *name_space, *name, *pos;
@@ -269,15 +279,89 @@
        return (guint64) (gsize) info;
 }
 
+static guint64
+debugger_insert_source_breakpoint (guint64 image_argument, guint64 token, 
guint64 index,
+                                  const gchar *class_name)
+{
+       MonoImage *image = GUINT_TO_POINTER ((gsize) image_argument);
+       MonoDebugMethodAddressList *info;
+       MonoClass *klass;
+       int i;
+
+       mono_debugger_lock ();
+
+       klass = mono_debugger_register_class_init_callback (image, class_name, 
token, index);
+       if (!klass) {
+               mono_debugger_unlock ();
+               return 0;
+       }
+
+       for (i = 0; i < klass->method.count; i++) {
+               MonoMethod *method = klass->methods [i];
+
+               if (method->token != token)
+                       continue;
+
+               if (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) {
+                       const char *name = method->name;
+                       MonoMethod *nm = NULL;
+
+                       if (method->klass->parent == 
mono_defaults.multicastdelegate_class) {
+                               if (*name == 'I' && (strcmp (name, "Invoke") == 
0))
+                                       nm = mono_marshal_get_delegate_invoke 
(method, NULL);
+                               else if (*name == 'B' && (strcmp (name, 
"BeginInvoke") == 0))
+                                       nm = 
mono_marshal_get_delegate_begin_invoke (method);
+                               else if (*name == 'E' && (strcmp (name, 
"EndInvoke") == 0))
+                                       nm = 
mono_marshal_get_delegate_end_invoke (method);
+                       }
+
+                       if (!nm) {
+                               mono_debugger_unlock ();
+                               return 0;
+                       }
+
+                       method = nm;
+               }
+
+               info = mono_debugger_insert_method_breakpoint (method, index);
+               mono_debugger_unlock ();
+               return (guint64) (gsize) info;
+       }
+
+       mono_debugger_unlock ();
+       return 0;
+}
+
 static void
-debugger_remove_method_breakpoint (G_GNUC_UNUSED guint64 dummy, guint64 index)
+debugger_remove_breakpoint (guint64 index, G_GNUC_UNUSED guint64 dummy)
 {
        mono_debugger_lock ();
        mono_debugger_remove_method_breakpoint (index);
        mono_debugger_unlock ();
 }
 
+static guint64
+debugger_register_class_init_callback (guint64 image_argument, guint64 token, 
guint64 index,
+                                      const gchar *class_name)
+{
+       MonoImage *image = GUINT_TO_POINTER ((gsize) image_argument);
+       MonoClass *klass;
+
+       mono_debugger_lock ();
+       klass = mono_debugger_register_class_init_callback (image, class_name, 
token, index);
+       mono_debugger_unlock ();
+       return (guint64) (gsize) klass;
+}
+
 static void
+debugger_remove_class_init_callback (guint64 index, G_GNUC_UNUSED guint64 
dummy)
+{
+       mono_debugger_lock ();
+       mono_debugger_remove_class_init_callback (index);
+       mono_debugger_unlock ();
+}
+
+static void
 debugger_event_handler (MonoDebuggerEvent event, guint64 data, guint64 arg)
 {
        mono_debugger_notification_function (event, data, arg);

Modified: trunk/mono/mono/mini/debug-debugger.h
===================================================================
--- trunk/mono/mono/mini/debug-debugger.h       2007-11-20 19:34:12 UTC (rev 
90018)
+++ trunk/mono/mono/mini/debug-debugger.h       2007-11-20 19:34:24 UTC (rev 
90019)
@@ -32,9 +32,9 @@
        guint32 version;
        guint32 total_size;
        guint32 symbol_table_size;
-       guint32 dummy;
+       guint32 mono_trampoline_num;
+       guint8 **mono_trampoline_code;
        gpointer notification_function;
-       guint8 **mono_trampoline_code;
        MonoSymbolTable **symbol_table;
        MonoDebuggerMetadataInfo *metadata_info;
        guint64 (*compile_method) (guint64 method_argument);
@@ -49,12 +49,19 @@
        void * (*get_lmf_addr) (void);
 
        guint64 (*create_string) (G_GNUC_UNUSED guint64 dummy1, G_GNUC_UNUSED 
guint64 dummy2,
-                                 const gchar *string_argument);
+                                 G_GNUC_UNUSED guint64 dummy3, const gchar 
*string_argument);
        gint64 (*lookup_class) (guint64 image_argument, G_GNUC_UNUSED guint64 
dummy,
-                               gchar *full_name);
-       guint64 (*insert_breakpoint) (guint64 method_argument, guint64 index);
-       void (*remove_breakpoint) (G_GNUC_UNUSED guint64 dummy, guint64 index);
+                               G_GNUC_UNUSED guint64 dummy2, gchar *full_name);
 
+       guint64 (*insert_method_breakpoint) (guint64 method_argument, guint64 
index);
+       guint64 (*insert_source_breakpoint) (guint64 image_argument, guint64 
token,
+                                            guint64 index, const gchar 
*class_name);
+       void (*remove_breakpoint) (guint64 index, G_GNUC_UNUSED guint64 dummy);
+
+       guint64 (*rgister_class_init_callback) (guint64 image_argument, guint64 
token,
+                                               guint64 index, const gchar 
*class_name);
+       void (*remove_class_init_callback) (guint64 index, G_GNUC_UNUSED 
guint64 dummy);
+
        gint32 *debugger_version;
        MonoDebuggerThreadInfo **thread_table;
 

Modified: trunk/mono/mono/mini/debug-mini.c
===================================================================
--- trunk/mono/mono/mini/debug-mini.c   2007-11-20 19:34:12 UTC (rev 90018)
+++ trunk/mono/mono/mini/debug-mini.c   2007-11-20 19:34:24 UTC (rev 90019)
@@ -35,13 +35,6 @@
 
 typedef struct
 {
-       guint64 index;
-       MonoMethod *method;
-       MonoDebugMethodAddressList *address_list;
-} MiniDebugMethodBreakpointInfo;
-
-typedef struct
-{
        MonoDebugMethodJitInfo *jit;
        GArray *line_numbers;
        guint32 has_line_numbers;
@@ -75,9 +68,6 @@
 
 MonoDebuggerThreadInfo *mono_debugger_thread_table = NULL;
 
-static void
-mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress 
*debug_info);
-
 static inline void
 record_line_number (MiniDebugMethodInfo *info, guint32 address, guint32 offset)
 {
@@ -676,82 +666,7 @@
        }
 }
 
-
 /*
- * Debugger breakpoint interface.
- *
- * This interface is used to insert breakpoints on methods which are not yet 
JITed.
- * The debugging code keeps a list of all such breakpoints and automatically 
inserts the
- * breakpoint when the method is JITed.
- */
-
-static GPtrArray *method_breakpoints = NULL;
-
-MonoDebugMethodAddressList *
-mono_debugger_insert_method_breakpoint (MonoMethod *method, guint64 index)
-{
-       MiniDebugMethodBreakpointInfo *info;
-
-       info = g_new0 (MiniDebugMethodBreakpointInfo, 1);
-       info->method = method;
-       info->index = index;
-
-       info->address_list = mono_debug_lookup_method_addresses (method);
-
-       if (!method_breakpoints)
-               method_breakpoints = g_ptr_array_new ();
-
-       g_ptr_array_add (method_breakpoints, info);
-
-       return info->address_list;
-}
-
-int
-mono_debugger_remove_method_breakpoint (guint64 index)
-{
-       int i;
-
-       if (!method_breakpoints)
-               return 0;
-
-       for (i = 0; i < method_breakpoints->len; i++) {
-               MiniDebugMethodBreakpointInfo *info = g_ptr_array_index 
(method_breakpoints, i);
-
-               if (info->index != index)
-                       continue;
-
-               g_ptr_array_remove (method_breakpoints, info);
-               g_free (info->address_list);
-               g_free (info);
-               return 1;
-       }
-
-       return 0;
-}
-
-static void
-mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress 
*debug_info)
-{
-       int i;
-
-       if (!method_breakpoints)
-               return;
-
-       if (method->is_inflated)
-               method = ((MonoMethodInflated *) method)->declaring;
-
-       for (i = 0; i < method_breakpoints->len; i++) {
-               MiniDebugMethodBreakpointInfo *info = g_ptr_array_index 
(method_breakpoints, i);
-
-               if (method != info->method)
-                       continue;
-
-               mono_debugger_event (MONO_DEBUGGER_EVENT_JIT_BREAKPOINT,
-                                    (guint64) (gsize) debug_info, info->index);
-       }
-}
-
-/*
  * The old Debugger breakpoint interface.
  *
  * This interface is used to insert breakpoints on methods which are not yet 
JITed.

Modified: trunk/mono/mono/mini/debug-mini.h
===================================================================
--- trunk/mono/mono/mini/debug-mini.h   2007-11-20 19:34:12 UTC (rev 90018)
+++ trunk/mono/mono/mini/debug-mini.h   2007-11-20 19:34:24 UTC (rev 90019)
@@ -6,12 +6,6 @@
 
 #include "mini.h"
 
-MonoDebugMethodAddressList *
-mono_debugger_insert_method_breakpoint (MonoMethod *method, guint64 idx);
-
-int
-mono_debugger_remove_method_breakpoint (guint64 index);
-
 typedef struct _MonoDebuggerThreadInfo MonoDebuggerThreadInfo;
 extern MonoDebuggerThreadInfo *mono_debugger_thread_table;
 

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

Reply via email to