2005-05-13 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / metadata / mono-debug-debugger.h
1 /*
2  * This header is only installed for use by the debugger:
3  * the structures and the API declared here are not supported.
4  */
5
6 #ifndef __MONO_DEBUG_DEBUGGER_H__
7 #define __MONO_DEBUG_DEBUGGER_H__
8
9 #include <glib.h>
10 #include <mono/metadata/debug-helpers.h>
11 #include <mono/metadata/debug-mono-symfile.h>
12 #include <mono/io-layer/io-layer.h>
13
14 typedef struct _MonoDebuggerBreakpointInfo      MonoDebuggerBreakpointInfo;
15 typedef struct _MonoDebuggerIOLayer             MonoDebuggerIOLayer;
16
17 typedef enum {
18         MONO_DEBUGGER_EVENT_BREAKPOINT,
19         MONO_DEBUGGER_EVENT_ADD_MODULE,
20         MONO_DEBUGGER_EVENT_RELOAD_SYMTABS,
21         MONO_DEBUGGER_EVENT_UNHANDLED_EXCEPTION,
22         MONO_DEBUGGER_EVENT_EXCEPTION,
23         MONO_DEBUGGER_EVENT_THROW_EXCEPTION
24 } MonoDebuggerEvent;
25
26 struct _MonoDebuggerBreakpointInfo {
27         guint32 index;
28         MonoMethodDesc *desc;
29 };
30
31 /*
32  * Address of the x86 trampoline code.  This is used by the debugger to check
33  * whether a method is a trampoline.
34  */
35 extern guint8 *mono_generic_trampoline_code;
36
37 #ifndef PLATFORM_WIN32
38
39 /*
40  * Functions we export to the debugger.
41  */
42 struct _MonoDebuggerIOLayer
43 {
44         void (*InitializeCriticalSection) (WapiCriticalSection *section);
45         void (*DeleteCriticalSection) (WapiCriticalSection *section);
46         gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
47         void (*EnterCriticalSection) (WapiCriticalSection *section);
48         void (*LeaveCriticalSection) (WapiCriticalSection *section);
49
50         guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout, 
51                                         gboolean alertable);
52         guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
53                                         guint32 timeout, gboolean alertable);
54         guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
55                                       gboolean waitall, guint32 timeout, gboolean alertable);
56
57         gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
58                                      gint32 initial, gint32 max,
59                                      const gunichar2 *name);
60         gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
61
62         gpointer (*CreateThread) (WapiSecurityAttributes *security,
63                                   guint32 stacksize, WapiThreadStart start,
64                                   gpointer param, guint32 create, guint32 *tid);
65         guint32 (*GetCurrentThreadId) (void);
66 };
67
68 extern MonoDebuggerIOLayer mono_debugger_io_layer;
69
70 #endif
71
72 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, guint64 data, guint64 arg);
73
74 void            mono_debugger_initialize                  (gboolean use_debugger);
75 void            mono_debugger_cleanup                     (void);
76
77 void            mono_debugger_lock                        (void);
78 void            mono_debugger_unlock                      (void);
79 void            mono_debugger_event                       (MonoDebuggerEvent event, guint64 data, guint64 arg);
80
81 void            mono_debugger_add_symbol_file             (MonoDebugHandle *handle);
82 void            mono_debugger_start_add_type              (MonoDebugHandle *symfile, MonoClass *klass);
83 void            mono_debugger_add_type                    (MonoDebugHandle *symfile, MonoClass *klass);
84 void            mono_debugger_add_builtin_types           (MonoDebugHandle *symfile);
85
86 void            mono_debugger_add_method                  (MonoDebugMethodJitInfo *jit);
87
88 void            mono_debugger_add_wrapper                 (MonoMethod *wrapper,
89                                                            MonoDebugMethodJitInfo *jit,
90                                                            gpointer addr);
91
92
93 int             mono_debugger_insert_breakpoint_full      (MonoMethodDesc *desc);
94 int             mono_debugger_remove_breakpoint           (int breakpoint_id);
95 int             mono_debugger_insert_breakpoint           (const gchar *method_name, gboolean include_namespace);
96 int             mono_debugger_method_has_breakpoint       (MonoMethod *method);
97 void            mono_debugger_breakpoint_callback         (MonoMethod *method, guint32 idx);
98
99 gpointer        mono_debugger_create_notification_function (gpointer *notification_address);
100
101 MonoObject     *mono_debugger_runtime_invoke              (MonoMethod *method, void *obj,
102                                                            void **params, MonoObject **exc);
103
104 gboolean        mono_debugger_lookup_type                 (const gchar *type_name);
105 gint32          mono_debugger_lookup_assembly             (const gchar *name);
106 gboolean        mono_debugger_unhandled_exception         (gpointer addr, gpointer stack, MonoObject *exc);
107 void            mono_debugger_handle_exception            (gpointer addr, gpointer stack, MonoObject *exc);
108 gboolean        mono_debugger_throw_exception             (gpointer addr, gpointer stack, MonoObject *exc);
109
110
111
112 void *
113 mono_vtable_get_static_field_data (MonoVTable *vt);
114
115
116 MonoReflectionMethod *
117 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly, guint32 token);
118
119 int
120 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly, MonoReflectionMethod *method);
121
122 MonoReflectionType *
123 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly, MonoArray *signature);
124
125 MonoReflectionType *
126 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly, guint32 token);
127
128 gchar *
129 mono_debugger_check_runtime_version (const char *filename);
130
131 #endif /* __MONO_DEBUG_DEBUGGER_H__ */