*** empty log message ***
[mono.git] / mono / jit / debug.h
1 #ifndef __MONO_JIT_DEBUG_H__
2 #define __MONO_JIT_DEBUG_H__
3
4 #include <glib.h>
5 #include <stdio.h>
6 #include <mono/metadata/debug-helpers.h>
7 #include <mono/metadata/debug-mono-symfile.h>
8 #include <mono/metadata/loader.h>
9 #include <mono/jit/jit.h>
10
11 typedef struct _MonoDebugHandle                 MonoDebugHandle;
12 typedef struct _MonoDebuggerSymbolFileTable     MonoDebuggerSymbolFileTable;
13 typedef struct _MonoDebuggerBreakpointInfo      MonoDebuggerBreakpointInfo;
14
15 typedef struct _MonoDebuggerIOLayer             MonoDebuggerIOLayer;
16
17 typedef enum {
18         MONO_DEBUG_FORMAT_NONE,
19         MONO_DEBUG_FORMAT_STABS,
20         MONO_DEBUG_FORMAT_DWARF2,
21         MONO_DEBUG_FORMAT_MONO
22 } MonoDebugFormat;
23
24 typedef enum {
25         MONO_DEBUGGER_EVENT_TYPE_ADDED,
26         MONO_DEBUGGER_EVENT_METHOD_ADDED,
27         MONO_DEBUGGER_EVENT_BREAKPOINT_TRAMPOLINE,
28         MONO_DEBUGGER_EVENT_THREAD_CREATED
29 } MonoDebuggerEvent;
30
31 #ifndef PLATFORM_WIN32
32
33 /*
34  * Functions we export to the debugger.
35  */
36 struct _MonoDebuggerIOLayer
37 {
38         void (*InitializeCriticalSection) (WapiCriticalSection *section);
39         void (*DeleteCriticalSection) (WapiCriticalSection *section);
40         gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
41         void (*EnterCriticalSection) (WapiCriticalSection *section);
42         void (*LeaveCriticalSection) (WapiCriticalSection *section);
43
44         guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
45         guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
46                                         guint32 timeout, gboolean alertable);
47         guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
48                                            gboolean waitall, guint32 timeout);
49
50         gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
51                                      gint32 initial, gint32 max,
52                                      const guchar *name);
53         gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
54
55         gpointer (*CreateThread) (WapiSecurityAttributes *security,
56                                   guint32 stacksize, WapiThreadStart start,
57                                   gpointer param, guint32 create, guint32 *tid);
58 };
59
60 extern MonoDebuggerIOLayer mono_debugger_io_layer;
61
62 #endif
63
64 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, gpointer data2);
65
66 extern MonoDebugFormat mono_debug_format;
67
68 MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format, const char **args);
69
70 void           mono_debug_cleanup (void);
71
72 void           mono_debug_add_method (MonoFlowGraph *cfg);
73
74 void           mono_debug_add_wrapper (MonoMethod *method, MonoMethod *wrapper_method);
75
76 void           mono_debug_add_type (MonoClass *klass);
77
78 gchar *        mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
79                                                         guint32 *line_number);
80
81 gint32         mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
82
83 gint32         mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
84
85 int            mono_method_has_breakpoint (MonoMethod* method, gboolean use_trampoline);
86
87 int            mono_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
88
89 int            mono_insert_breakpoint_full (MonoMethodDesc *desc, gboolean use_trampoline);
90
91 int            mono_remove_breakpoint (int breakpint_id);
92
93 void           mono_debugger_trampoline_breakpoint_callback (void);
94
95 void           mono_debugger_event (MonoDebuggerEvent event, gpointer data, gpointer data2);
96
97 gpointer       mono_debug_create_notification_function (gpointer *notification_address);
98
99 void           mono_debug_init (int running_in_the_mono_debugger);
100 void           mono_debug_lock (void);
101 void           mono_debug_unlock (void);
102 int            mono_debug_update_symbol_file_table (void);
103
104
105 /* DEBUGGER PUBLIC FUNCTION:
106  *
107  * This is a public function which is supposed to be called from within a debugger
108  * each time the program stops. It's used to recreate the symbol file to tell the
109  * debugger about method addresses and such things. After calling this function,
110  * you must tell your debugger to reload its symbol file.
111  */
112 void           mono_debug_make_symbols (void);
113
114 void           mono_debug_write_symbols (MonoDebugHandle* debug);
115
116 /*
117  * Address of the x86 trampoline code.  This is used by the debugger to check
118  * whether a method is a trampoline.
119  */
120 extern guint8 *mono_generic_trampoline_code;
121
122 /*
123  * Address of a special breakpoint code which is used by the debugger to get a breakpoint
124  * after compiling a method.
125  */
126 extern guint8 *mono_breakpoint_trampoline_code;
127
128 /* This is incremented each time the symbol table is modified.
129  * The debugger looks at this variable and if it has a higher value than its current
130  * copy of the symbol table, it must call debugger_update_symbol_file_table().
131  */
132 extern guint32 mono_debugger_symbol_file_table_generation;
133 extern guint32 mono_debugger_symbol_file_table_modified;
134
135 /* Caution: This variable may be accessed at any time from the debugger;
136  *          it is very important not to modify the memory it is pointing to
137  *          without previously setting this pointer back to NULL.
138  */
139 extern MonoDebuggerSymbolFileTable *mono_debugger_symbol_file_table;
140
141 struct _MonoDebuggerSymbolFileTable {
142         guint64 magic;
143         guint32 version;
144         guint32 total_size;
145         guint32 count;
146         guint32 generation;
147         MonoGlobalSymbolFile *global_symfile;
148         MonoSymbolFile *symfiles [MONO_ZERO_LEN_ARRAY];
149 };
150
151 struct _MonoDebuggerBreakpointInfo {
152         guint32 index;
153         gboolean use_trampoline;
154         MonoMethodDesc *desc;
155 };
156
157 #endif /* __MONO_JIT_DEBUG_H__ */