*** empty log message ***
[mono.git] / mono / jit / debug.h
index 133a97925f8a071a0f6f557b33a745b7ea056ae3..adc3fdc54439b17cd398e12b9973a5ea6c7c0df8 100644 (file)
@@ -3,70 +3,76 @@
 
 #include <glib.h>
 #include <stdio.h>
+#include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/debug-mono-symfile.h>
 #include <mono/metadata/loader.h>
 #include <mono/jit/jit.h>
 
-typedef struct _MonoDebugHandle MonoDebugHandle;
+typedef struct _MonoDebugHandle                        MonoDebugHandle;
+typedef struct _MonoDebuggerSymbolFileTable    MonoDebuggerSymbolFileTable;
+typedef struct _MonoDebuggerBreakpointInfo     MonoDebuggerBreakpointInfo;
+
+typedef struct _MonoDebuggerIOLayer            MonoDebuggerIOLayer;
 
 typedef enum {
        MONO_DEBUG_FORMAT_NONE,
        MONO_DEBUG_FORMAT_STABS,
        MONO_DEBUG_FORMAT_DWARF2,
-       MONO_DEBUG_FORMAT_DWARF2_PLUS,
        MONO_DEBUG_FORMAT_MONO
 } MonoDebugFormat;
 
-extern MonoDebugFormat mono_debug_format;
-extern GList *mono_debug_methods;
+typedef enum {
+       MONO_DEBUGGER_EVENT_TYPE_ADDED,
+       MONO_DEBUGGER_EVENT_METHOD_ADDED,
+       MONO_DEBUGGER_EVENT_BREAKPOINT_TRAMPOLINE,
+       MONO_DEBUGGER_EVENT_THREAD_CREATED
+} MonoDebuggerEvent;
 
-/*
- * This variable is intended to be set in a debugger.
- *
- * If it's non-zero, arch_compile_method() will insert a breakpoint next time
- * it compiles a method.
- *
- * If it's positive, it acts as a counter which is decremented each time it's
- * used. Set it to a negative value to make arch_compile_method() insert a
- * breakpoint for each method.
- *
- * To use this, you should create a GDB macro like this:
- *
- *    define enter
- *      set mono_debug_insert_breakpoint = 1
- *      continue
- *      set *mono_debug_last_breakpoint_address = 0x90
- *      reload-symbol-files
- *      frame
- *    end
- *
- *    define reload-symbol-files
- *      call mono_debug_make_symbols ()
- *      add-symbol-file Test-debug.o
- *      add-symbol-file /tmp/corlib.o
- *    end
- *
- */
-extern int mono_debug_insert_breakpoint;
+#ifndef PLATFORM_WIN32
 
 /*
- * This is set the the core address of the last inserted breakpoint. You can
- * use this in GDB to unset the breakpoint.
+ * Functions we export to the debugger.
  */
+struct _MonoDebuggerIOLayer
+{
+       void (*InitializeCriticalSection) (WapiCriticalSection *section);
+       void (*DeleteCriticalSection) (WapiCriticalSection *section);
+       gboolean (*TryEnterCriticalSection) (WapiCriticalSection *section);
+       void (*EnterCriticalSection) (WapiCriticalSection *section);
+       void (*LeaveCriticalSection) (WapiCriticalSection *section);
 
-extern gchar *mono_debug_last_breakpoint_address;
+       guint32 (*WaitForSingleObject) (gpointer handle, guint32 timeout);
+       guint32 (*SignalObjectAndWait) (gpointer signal_handle, gpointer wait,
+                                       guint32 timeout, gboolean alertable);
+       guint32 (*WaitForMultipleObjects) (guint32 numobjects, gpointer *handles,
+                                          gboolean waitall, guint32 timeout);
 
-MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format,
-                                 const char **args);
+       gpointer (*CreateSemaphore) (WapiSecurityAttributes *security,
+                                    gint32 initial, gint32 max,
+                                    const guchar *name);
+       gboolean (*ReleaseSemaphore) (gpointer handle, gint32 count, gint32 *prevcount);
 
-void           mono_debug_cleanup (void);
+       gpointer (*CreateThread) (WapiSecurityAttributes *security,
+                                 guint32 stacksize, WapiThreadStart start,
+                                 gpointer param, guint32 create, guint32 *tid);
+};
+
+extern MonoDebuggerIOLayer mono_debugger_io_layer;
+
+#endif
 
-void           mono_debug_add_image (MonoDebugHandle* debug, MonoImage *image);
+extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, gpointer data2);
 
-MonoDebugHandle* mono_debug_handle_from_class (MonoClass *klass);
+extern MonoDebugFormat mono_debug_format;
+
+MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format, const char **args);
+
+void           mono_debug_cleanup (void);
 
 void           mono_debug_add_method (MonoFlowGraph *cfg);
 
+void           mono_debug_add_wrapper (MonoMethod *method, MonoMethod *wrapper_method);
+
 void           mono_debug_add_type (MonoClass *klass);
 
 gchar *        mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
@@ -76,6 +82,26 @@ gint32         mono_debug_il_offset_from_address (MonoMethod *method, gint32 add
 
 gint32         mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
 
+int            mono_method_has_breakpoint (MonoMethod* method, gboolean use_trampoline);
+
+int            mono_insert_breakpoint (const gchar *method_name, gboolean include_namespace);
+
+int            mono_insert_breakpoint_full (MonoMethodDesc *desc, gboolean use_trampoline);
+
+int            mono_remove_breakpoint (int breakpint_id);
+
+void           mono_debugger_trampoline_breakpoint_callback (void);
+
+void           mono_debugger_event (MonoDebuggerEvent event, gpointer data, gpointer data2);
+
+gpointer       mono_debug_create_notification_function (gpointer *notification_address);
+
+void           mono_debug_init (int running_in_the_mono_debugger);
+void           mono_debug_lock (void);
+void           mono_debug_unlock (void);
+int            mono_debug_update_symbol_file_table (void);
+
+
 /* DEBUGGER PUBLIC FUNCTION:
  *
  * This is a public function which is supposed to be called from within a debugger
@@ -88,13 +114,44 @@ void           mono_debug_make_symbols (void);
 void           mono_debug_write_symbols (MonoDebugHandle* debug);
 
 /*
- * Do not use these two functions unless you know exactly what you're doing.
- *
- * Returns a pointer to a region of memory within the JIT's address space.  The Mono
- * Debugger uses this data to get information about the symbol files.
+ * Address of the x86 trampoline code.  This is used by the debugger to check
+ * whether a method is a trampoline.
+ */
+extern guint8 *mono_generic_trampoline_code;
+
+/*
+ * Address of a special breakpoint code which is used by the debugger to get a breakpoint
+ * after compiling a method.
+ */
+extern guint8 *mono_breakpoint_trampoline_code;
+
+/* This is incremented each time the symbol table is modified.
+ * The debugger looks at this variable and if it has a higher value than its current
+ * copy of the symbol table, it must call debugger_update_symbol_file_table().
+ */
+extern guint32 mono_debugger_symbol_file_table_generation;
+extern guint32 mono_debugger_symbol_file_table_modified;
+
+/* Caution: This variable may be accessed at any time from the debugger;
+ *          it is very important not to modify the memory it is pointing to
+ *          without previously setting this pointer back to NULL.
  */
-MonoSymbolFile *mono_debugger_internal_get_symbol_files (void);
-void mono_debugger_internal_free_symbol_files (gpointer data);
-extern int mono_debugger_internal_symbol_files_changed;
+extern MonoDebuggerSymbolFileTable *mono_debugger_symbol_file_table;
+
+struct _MonoDebuggerSymbolFileTable {
+       guint64 magic;
+       guint32 version;
+       guint32 total_size;
+       guint32 count;
+       guint32 generation;
+       MonoGlobalSymbolFile *global_symfile;
+       MonoSymbolFile *symfiles [MONO_ZERO_LEN_ARRAY];
+};
+
+struct _MonoDebuggerBreakpointInfo {
+       guint32 index;
+       gboolean use_trampoline;
+       MonoMethodDesc *desc;
+};
 
 #endif /* __MONO_JIT_DEBUG_H__ */