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
31 #ifndef PLATFORM_WIN32
34 * Functions we export to the debugger.
36 struct _MonoDebuggerIOLayer
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);
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);
50 gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
51 gint32 initial, gint32 max,
53 gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
55 gpointer (*CreateThread) (WapiSecurityAttributes *security,
56 guint32 stacksize, WapiThreadStart start,
57 gpointer param, guint32 create, guint32 *tid);
60 extern MonoDebuggerIOLayer mono_debugger_io_layer;
64 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, gpointer data2);
66 extern MonoDebugFormat mono_debug_format;
68 MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format, const char **args);
70 void mono_debug_cleanup (void);
72 void mono_debug_add_method (MonoFlowGraph *cfg);
74 void mono_debug_add_wrapper (MonoMethod *method, MonoMethod *wrapper_method);
76 void mono_debug_add_type (MonoClass *klass);
78 gchar * mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
79 guint32 *line_number);
81 gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
83 gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
85 int mono_method_has_breakpoint (MonoMethod* method, gboolean use_trampoline);
87 int mono_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
89 int mono_insert_breakpoint_full (MonoMethodDesc *desc, gboolean use_trampoline);
91 int mono_remove_breakpoint (int breakpint_id);
93 void mono_debugger_trampoline_breakpoint_callback (void);
95 void mono_debugger_event (MonoDebuggerEvent event, gpointer data, gpointer data2);
97 gpointer mono_debug_create_notification_function (gpointer *notification_address);
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);
105 /* DEBUGGER PUBLIC FUNCTION:
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.
112 void mono_debug_make_symbols (void);
114 void mono_debug_write_symbols (MonoDebugHandle* debug);
117 * Address of the x86 trampoline code. This is used by the debugger to check
118 * whether a method is a trampoline.
120 extern guint8 *mono_generic_trampoline_code;
123 * Address of a special breakpoint code which is used by the debugger to get a breakpoint
124 * after compiling a method.
126 extern guint8 *mono_breakpoint_trampoline_code;
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().
132 extern guint32 mono_debugger_symbol_file_table_generation;
133 extern guint32 mono_debugger_symbol_file_table_modified;
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.
139 extern MonoDebuggerSymbolFileTable *mono_debugger_symbol_file_table;
141 struct _MonoDebuggerSymbolFileTable {
147 MonoGlobalSymbolFile *global_symfile;
148 MonoSymbolFile *symfiles [MONO_ZERO_LEN_ARRAY];
151 struct _MonoDebuggerBreakpointInfo {
153 gboolean use_trampoline;
154 MonoMethodDesc *desc;
157 #endif /* __MONO_JIT_DEBUG_H__ */