Author: martin
Date: 2007-11-20 14:34:12 -0500 (Tue, 20 Nov 2007)
New Revision: 90018
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/mono-debug-debugger.c
trunk/mono/mono/metadata/mono-debug-debugger.h
trunk/mono/mono/metadata/mono-debug.c
trunk/mono/mono/metadata/mono-debug.h
Log:
2007-11-20 Martin Baulig <[EMAIL PROTECTED]>
* mono-debug.h (MONO_DEBUGGER_VERSION): Bump to 65.
* mono-debug-debugger.c
(mono_debugger_insert_method_breakpoint): Moved here from debug-mini.c
(mono_debugger_remove_breakpoint): Likewise.
(mono_debugger_check_breakpoints): Likewise.
(mono_debugger_register_class_init_callback): New public method.
(mono_debugger_remove_class_init_callback): Likewise.
(mono_debugger_add_type): Likewise.
* mono-debug-debugger.h
(MonoDebuggerEvent): Add `MONO_DEBUGGER_EVENT_CLASS_INITIALIZED'.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2007-11-20 19:32:59 UTC (rev 90017)
+++ trunk/mono/mono/metadata/ChangeLog 2007-11-20 19:34:12 UTC (rev 90018)
@@ -1,4 +1,18 @@
+2007-11-20 Martin Baulig <[EMAIL PROTECTED]>
+ * mono-debug.h (MONO_DEBUGGER_VERSION): Bump to 65.
+
+ * mono-debug-debugger.c
+ (mono_debugger_insert_method_breakpoint): Moved here from debug-mini.c
+ (mono_debugger_remove_breakpoint): Likewise.
+ (mono_debugger_check_breakpoints): Likewise.
+ (mono_debugger_register_class_init_callback): New public method.
+ (mono_debugger_remove_class_init_callback): Likewise.
+ (mono_debugger_add_type): Likewise.
+
+ * mono-debug-debugger.h
+ (MonoDebuggerEvent): Add `MONO_DEBUGGER_EVENT_CLASS_INITIALIZED'.
+
Tue Nov 20 20:54:12 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>
* class.c: more interface implementations needed for the
Modified: trunk/mono/mono/metadata/mono-debug-debugger.c
===================================================================
--- trunk/mono/mono/metadata/mono-debug-debugger.c 2007-11-20 19:32:59 UTC
(rev 90017)
+++ trunk/mono/mono/metadata/mono-debug-debugger.c 2007-11-20 19:34:12 UTC
(rev 90018)
@@ -29,6 +29,22 @@
guint32 stop;
} MonoDebuggerExceptionInfo;
+typedef struct
+{
+ guint32 index;
+ MonoMethod *method;
+ MonoDebugMethodAddressList *address_list;
+} MethodBreakpointInfo;
+
+typedef struct {
+ guint64 index;
+ guint32 token;
+ gchar *name_space;
+ gchar *name;
+} ClassInitCallback;
+
+static GPtrArray *class_init_callbacks = NULL;
+
static int initialized = 0;
void
@@ -194,3 +210,183 @@
return retval;
}
+
+
+/*
+ * 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)
+{
+ MethodBreakpointInfo *info;
+
+ info = g_new0 (MethodBreakpointInfo, 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++) {
+ MethodBreakpointInfo *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;
+}
+
+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++) {
+ MethodBreakpointInfo *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);
+ }
+}
+
+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);
+ if (klass && klass->inited && klass->methods) {
+ mono_loader_unlock ();
+ return klass;
+ }
+
+ info = g_new0 (ClassInitCallback, 1);
+ 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 NULL;
+}
+
+void
+mono_debugger_remove_class_init_callback (int index)
+{
+ int i;
+
+ if (!class_init_callbacks)
+ return;
+
+ for (i = 0; i < class_init_callbacks->len; i++) {
+ ClassInitCallback *info = g_ptr_array_index
(class_init_callbacks, i);
+
+ if (info->index != index)
+ continue;
+
+ g_ptr_array_remove (class_init_callbacks, info);
+ if (info->name_space)
+ g_free (info->name_space);
+ else
+ g_free (info->name);
+ g_free (info);
+ }
+}
+
+void
+mono_debugger_add_type (MonoDebugHandle *symfile, MonoClass *klass)
+{
+ int i;
+
+ if (!class_init_callbacks)
+ return;
+
+ again:
+ for (i = 0; i < class_init_callbacks->len; i++) {
+ ClassInitCallback *info = g_ptr_array_index
(class_init_callbacks, i);
+
+ if (info->name_space && strcmp (info->name_space,
klass->name_space))
+ continue;
+ if (strcmp (info->name, klass->name))
+ continue;
+
+ mono_debugger_event (MONO_DEBUGGER_EVENT_CLASS_INITIALIZED,
+ (guint64) (gsize) klass, info->index);
+
+ if (info->token) {
+ int j;
+
+ for (j = 0; j < klass->method.count; j++) {
+ if (klass->methods [j]->token != info->token)
+ continue;
+
+ mono_debugger_insert_method_breakpoint
(klass->methods [j], info->index);
+ }
+ }
+
+ g_ptr_array_remove (class_init_callbacks, info);
+ if (info->name_space)
+ g_free (info->name_space);
+ else
+ g_free (info->name);
+ g_free (info);
+ goto again;
+ }
+}
Modified: trunk/mono/mono/metadata/mono-debug-debugger.h
===================================================================
--- trunk/mono/mono/metadata/mono-debug-debugger.h 2007-11-20 19:32:59 UTC
(rev 90017)
+++ trunk/mono/mono/metadata/mono-debug-debugger.h 2007-11-20 19:34:12 UTC
(rev 90018)
@@ -35,6 +35,7 @@
MONO_DEBUGGER_EVENT_UNLOAD_MODULE,
MONO_DEBUGGER_EVENT_DOMAIN_CREATE,
MONO_DEBUGGER_EVENT_DOMAIN_UNLOAD,
+ MONO_DEBUGGER_EVENT_CLASS_INITIALIZED,
/* Extended per-thread notifications */
MONO_DEBUGGER_EVENT_TRAMPOLINE = 256,
@@ -58,4 +59,23 @@
gchar *
mono_debugger_check_runtime_version (const char *filename);
+void
+mono_debugger_add_type (MonoDebugHandle *symfile, MonoClass *klass);
+
+MonoDebugMethodAddressList *
+mono_debugger_insert_method_breakpoint (MonoMethod *method, guint64 idx);
+
+int
+mono_debugger_remove_method_breakpoint (guint64 index);
+
+void
+mono_debugger_check_breakpoints (MonoMethod *method, MonoDebugMethodAddress
*debug_info);
+
+MonoClass *
+mono_debugger_register_class_init_callback (MonoImage *image, const gchar
*full_name,
+ guint32 token, guint32 index);
+
+void
+mono_debugger_remove_class_init_callback (int index);
+
#endif /* __MONO_DEBUG_DEBUGGER_H__ */
Modified: trunk/mono/mono/metadata/mono-debug.c
===================================================================
--- trunk/mono/mono/metadata/mono-debug.c 2007-11-20 19:32:59 UTC (rev
90017)
+++ trunk/mono/mono/metadata/mono-debug.c 2007-11-20 19:34:12 UTC (rev
90018)
@@ -841,6 +841,8 @@
if (!handle)
return;
+ mono_debugger_add_type (handle, klass);
+
if (klass->generic_class || klass->rank ||
(klass->byval_arg.type == MONO_TYPE_VAR) || (klass->byval_arg.type
== MONO_TYPE_MVAR))
return;
Modified: trunk/mono/mono/metadata/mono-debug.h
===================================================================
--- trunk/mono/mono/metadata/mono-debug.h 2007-11-20 19:32:59 UTC (rev
90017)
+++ trunk/mono/mono/metadata/mono-debug.h 2007-11-20 19:34:12 UTC (rev
90018)
@@ -143,7 +143,7 @@
MonoType *type;
};
-#define MONO_DEBUGGER_VERSION 64
+#define MONO_DEBUGGER_VERSION 65
#define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
extern MonoSymbolTable *mono_symbol_table;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches