1 #ifndef __MONO_JIT_DEBUG_H__
2 #define __MONO_JIT_DEBUG_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>
11 typedef struct _MonoDebugHandle MonoDebugHandle;
12 typedef struct _MonoDebuggerSymbolFileTable MonoDebuggerSymbolFileTable;
13 typedef struct _MonoDebuggerBreakpointInfo MonoDebuggerBreakpointInfo;
15 typedef struct _MonoDebuggerIOLayer MonoDebuggerIOLayer;
18 MONO_DEBUG_FORMAT_NONE,
19 MONO_DEBUG_FORMAT_STABS,
20 MONO_DEBUG_FORMAT_DWARF2,
21 MONO_DEBUG_FORMAT_MONO
25 MONO_DEBUGGER_EVENT_TYPE_ADDED,
26 MONO_DEBUGGER_EVENT_METHOD_ADDED,
27 MONO_DEBUGGER_EVENT_BREAKPOINT_TRAMPOLINE,
28 MONO_DEBUGGER_EVENT_THREAD_CREATED
32 * Functions we export to the debugger.
34 struct _MonoDebuggerIOLayer
36 void (*InitializeCriticalSection) (WapiCriticalSection *section);
37 void (*DeleteCriticalSection) (WapiCriticalSection *section);
38 gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
39 void (*EnterCriticalSection) (WapiCriticalSection *section);
40 void (*LeaveCriticalSection) (WapiCriticalSection *section);
42 guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
43 guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
44 guint32 timeout, gboolean alertable);
45 guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
46 gboolean waitall, guint32 timeout);
48 gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
49 gint32 initial, gint32 max,
51 gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
53 gpointer (*CreateThread) (WapiSecurityAttributes *security,
54 guint32 stacksize, WapiThreadStart start,
55 gpointer param, guint32 create, guint32 *tid);
58 extern MonoDebuggerIOLayer mono_debugger_io_layer;
60 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, gpointer data2);
62 extern MonoDebugFormat mono_debug_format;
64 MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format, const char **args);
66 void mono_debug_cleanup (void);
68 void mono_debug_add_method (MonoFlowGraph *cfg);
70 void mono_debug_add_type (MonoClass *klass);
72 gchar * mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
73 guint32 *line_number);
75 gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
77 gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
79 int mono_method_has_breakpoint (MonoMethod* method, gboolean use_trampoline);
81 int mono_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
83 int mono_insert_breakpoint_full (MonoMethodDesc *desc, gboolean use_trampoline);
85 int mono_remove_breakpoint (int breakpint_id);
87 void mono_debugger_trampoline_breakpoint_callback (void);
89 void mono_debugger_event (MonoDebuggerEvent event, gpointer data, gpointer data2);
91 gpointer mono_debug_create_notification_function (gpointer *notification_address);
93 void mono_debug_init (void);
94 void mono_debug_lock (void);
95 void mono_debug_unlock (void);
96 int mono_debug_update_symbol_file_table (void);
99 /* DEBUGGER PUBLIC FUNCTION:
101 * This is a public function which is supposed to be called from within a debugger
102 * each time the program stops. It's used to recreate the symbol file to tell the
103 * debugger about method addresses and such things. After calling this function,
104 * you must tell your debugger to reload its symbol file.
106 void mono_debug_make_symbols (void);
108 void mono_debug_write_symbols (MonoDebugHandle* debug);
111 * Address of the x86 trampoline code. This is used by the debugger to check
112 * whether a method is a trampoline.
114 extern guint8 *mono_generic_trampoline_code;
117 * Address of a special breakpoint code which is used by the debugger to get a breakpoint
118 * after compiling a method.
120 extern guint8 *mono_breakpoint_trampoline_code;
122 /* This is incremented each time the symbol table is modified.
123 * The debugger looks at this variable and if it has a higher value than its current
124 * copy of the symbol table, it must call debugger_update_symbol_file_table().
126 extern guint32 mono_debugger_symbol_file_table_generation;
127 extern guint32 mono_debugger_symbol_file_table_modified;
129 /* Caution: This variable may be accessed at any time from the debugger;
130 * it is very important not to modify the memory it is pointing to
131 * without previously setting this pointer back to NULL.
133 extern MonoDebuggerSymbolFileTable *mono_debugger_symbol_file_table;
135 struct _MonoDebuggerSymbolFileTable {
141 MonoGlobalSymbolFile *global_symfile;
142 MonoSymbolFile *symfiles [MONO_ZERO_LEN_ARRAY];
145 struct _MonoDebuggerBreakpointInfo {
147 gboolean use_trampoline;
148 MonoMethodDesc *desc;
151 #endif /* __MONO_JIT_DEBUG_H__ */