2 * mono-debug-debugger.c:
5 * Mono Project (http://www.mono-project.com)
7 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
8 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
14 #include <mono/metadata/assembly.h>
15 #include <mono/metadata/metadata.h>
16 #include <mono/metadata/tabledefs.h>
17 #include <mono/metadata/tokentype.h>
18 #include <mono/metadata/appdomain.h>
19 #include <mono/metadata/gc-internal.h>
20 #include <mono/metadata/threads.h>
21 #include <mono/metadata/gc-internal.h>
22 #include <mono/metadata/object-internals.h>
23 #include <mono/metadata/class-internals.h>
24 #include <mono/metadata/domain-internals.h>
25 #include <mono/metadata/exception.h>
26 #include <mono/metadata/mono-debug.h>
27 #include <mono/metadata/mono-debug-debugger.h>
28 #include <mono/metadata/mono-endian.h>
30 static guint32 debugger_lock_level = 0;
31 static CRITICAL_SECTION debugger_lock_mutex;
37 MonoDebugMethodAddressList *address_list;
38 } MethodBreakpointInfo;
40 static int initialized = 0;
43 mono_debugger_lock (void)
45 g_assert (initialized);
46 EnterCriticalSection (&debugger_lock_mutex);
47 debugger_lock_level++;
51 mono_debugger_unlock (void)
53 g_assert (initialized);
54 debugger_lock_level--;
55 LeaveCriticalSection (&debugger_lock_mutex);
59 mono_debugger_initialize ()
61 InitializeCriticalSection (&debugger_lock_mutex);
66 * Debugger breakpoint interface.
68 * This interface is used to insert breakpoints on methods which are not yet JITed.
69 * The debugging code keeps a list of all such breakpoints and automatically inserts the
70 * breakpoint when the method is JITed.
73 static GPtrArray *method_breakpoints = NULL;
75 MonoDebugMethodAddressList *
76 mono_debugger_insert_method_breakpoint (MonoMethod *method, guint64 index)
78 MethodBreakpointInfo *info;
80 info = g_new0 (MethodBreakpointInfo, 1);
81 info->method = method;
84 info->address_list = mono_debug_lookup_method_addresses (method);
86 if (!method_breakpoints)
87 method_breakpoints = g_ptr_array_new ();
89 g_ptr_array_add (method_breakpoints, info);
91 return info->address_list;
95 mono_debugger_remove_method_breakpoint (guint64 index)
99 if (!method_breakpoints)
102 for (i = 0; i < method_breakpoints->len; i++) {
103 MethodBreakpointInfo *info = g_ptr_array_index (method_breakpoints, i);
105 if (info->index != index)
108 g_ptr_array_remove (method_breakpoints, info);
109 g_free (info->address_list);