Tue Sep 11 16:08:08 CEST 2007 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / mono-debug.h
index 41de11ae69eb914d6ee9fb61c39cc9a4a4abe033..852a0f3e25e282fbd937c7d8bae8f2153c5009f0 100644 (file)
@@ -11,6 +11,7 @@
 #include <mono/metadata/appdomain.h>
 
 typedef struct _MonoSymbolTable                        MonoSymbolTable;
+typedef struct _MonoDebugDataTable             MonoDebugDataTable;
 
 typedef struct _MonoSymbolFile                 MonoSymbolFile;
 typedef struct _MonoSymbolFilePriv             MonoSymbolFilePriv;
@@ -24,9 +25,13 @@ typedef struct _MonoDebugLexicalBlockEntry   MonoDebugLexicalBlockEntry;
 typedef struct _MonoDebugVarInfo               MonoDebugVarInfo;
 typedef struct _MonoDebugMethodJitInfo         MonoDebugMethodJitInfo;
 typedef struct _MonoDebugMethodAddress         MonoDebugMethodAddress;
+typedef struct _MonoDebugMethodAddressList     MonoDebugMethodAddressList;
 typedef struct _MonoDebugClassEntry            MonoDebugClassEntry;
 
-typedef struct _MonoDebuggerMetadataInfo       MonoDebuggerMetadataInfo;
+typedef struct _MonoDebugMethodInfo            MonoDebugMethodInfo;
+typedef struct _MonoDebugSourceLocation                MonoDebugSourceLocation;
+
+typedef struct _MonoDebugList                  MonoDebugList;
 
 typedef enum {
        MONO_DEBUG_FORMAT_NONE,
@@ -49,6 +54,16 @@ typedef enum {
        MONO_DEBUGGER_TYPE_KIND_REFERENCE
 } MonoDebuggerTypeKind;
 
+/*
+ * NOTE:
+ * We intentionally do not use GList here since the debugger needs to know about
+ * the layout of the fields.
+*/
+struct _MonoDebugList {
+       MonoDebugList *next;
+       gconstpointer data;
+};
+
 struct _MonoSymbolTable {
        guint64 magic;
        guint32 version;
@@ -58,56 +73,25 @@ struct _MonoSymbolTable {
         * Corlib and metadata info.
         */
        MonoDebugHandle *corlib;
-       MonoDebuggerMetadataInfo *metadata_info;
 
-       /*
-        * The symbol files.
-        */
-       MonoDebugHandle **symbol_files;
-       guint32 num_symbol_files;
+       MonoDebugList *data_tables;
+       MonoDebugDataTable *type_table;
 
        /*
-        * Data table.
-        * This is intentionally not a GPtrArray to make it more easy to
-        * read for the debugger.  The `data_tables' field contains
-        * `num_data_tables' pointers to continuous memory areas.
-        *
-        * The data table is basically a big continuous blob, but we need
-        * to split it up into pieces because we don't know the total size
-        * in advance and using g_realloc() doesn't work because that may
-        * reallocate the block to a different address.
-        */
-       guint32 num_data_tables;
-       gpointer *data_tables;
-       /*
-        * Current data table.
-        * The `current_data_table' points to a blob of `current_data_table_size'
-        * bytes.
-        */
-       gpointer current_data_table;
-       guint32 current_data_table_size;
-       /*
-        * The offset in the `current_data_table'.
+        * The symbol files.
         */
-       guint32 current_data_table_offset;
+       MonoDebugList *symbol_files;
 };
 
-typedef enum {
-       MONO_DEBUG_DATA_ITEM_UNKNOWN            = 0,
-       MONO_DEBUG_DATA_ITEM_METHOD,
-       MONO_DEBUG_DATA_ITEM_CLASS
-} MonoDebugDataItemType;
-
 struct _MonoDebugHandle {
        guint32 index;
-       const char *image_file;
+       char *image_file;
        MonoImage *image;
        MonoSymbolFile *symfile;
        MonoDebugHandlePriv *_priv;
 };
 
 struct _MonoDebugMethodJitInfo {
-       MonoDebugMethodAddress *address;
        const guint8 *code_start;
        guint32 code_size;
        guint32 prologue_end;
@@ -124,16 +108,9 @@ struct _MonoDebugMethodJitInfo {
        MonoDebugVarInfo *locals;
 };
 
-struct _MonoDebugMethodAddress {
+struct _MonoDebugMethodAddressList {
        guint32 size;
-       guint32 symfile_id;
-       guint32 domain_id;
-       guint32 method_id;
-       guint32 code_size;
-       guint32 dummy;
-       const guint8 *code_start;
-       const guint8 *wrapper_addr;
-       MonoDebugMethodJitInfo *jit;
+       guint32 count;
        guint8 data [MONO_ZERO_LEN_ARRAY];
 };
 
@@ -143,6 +120,12 @@ struct _MonoDebugClassEntry {
        guint8 data [MONO_ZERO_LEN_ARRAY];
 };
 
+struct _MonoDebugSourceLocation {
+       gchar *source_file;
+       guint32 row, column;
+       guint32 il_offset;
+};
+
 /*
  * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
  * where the variable is actually stored.
@@ -168,27 +151,63 @@ struct _MonoDebugVarInfo {
        guint32 end_scope;
 };
 
-#define MONO_DEBUGGER_VERSION                          50
+#define MONO_DEBUGGER_VERSION                          60
 #define MONO_DEBUGGER_MAGIC                            0x7aff65af4253d427ULL
 
 extern MonoSymbolTable *mono_symbol_table;
 extern MonoDebugFormat mono_debug_format;
 extern GHashTable *mono_debug_handles;
+extern gint32 mono_debug_debugger_version;
+
+void mono_debug_list_add (MonoDebugList **list, gconstpointer data);
+void mono_debug_list_remove (MonoDebugList **list, gconstpointer data);
 
 void mono_debug_init (MonoDebugFormat format);
-void mono_debug_init_1 (MonoDomain *domain);
-void mono_debug_init_2 (MonoAssembly *assembly);
+void mono_debug_open_image_from_memory (MonoImage *image, const guint8 *raw_contents, int size);
 void mono_debug_cleanup (void);
 
-MonoDebugMethodAddress *mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit,
-                                              MonoDomain *domain);
-MonoDebugMethodJitInfo *mono_debug_read_method (MonoDebugMethodAddress *address);
-void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
-gchar *mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
-                                               guint32 *line_number, MonoDomain *domain);
-gchar *mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset,
-                                                 guint32 *line_number);
-gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address, MonoDomain *domain);
-gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset, MonoDomain *domain);
+void mono_debug_close_image (MonoImage *image);
+
+void mono_debug_domain_unload (MonoDomain *domain);
+void mono_debug_domain_create (MonoDomain *domain);
+
+gboolean mono_debug_using_mono_debugger (void);
+
+MonoDebugMethodAddress *
+mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
+
+MonoDebugMethodInfo *
+mono_debug_lookup_method (MonoMethod *method);
+
+MonoDebugMethodAddressList *
+mono_debug_lookup_method_addresses (MonoMethod *method);
+
+MonoDebugMethodJitInfo*
+mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
+
+/*
+ * Line number support.
+ */
+
+MonoDebugSourceLocation *
+mono_debug_lookup_source_location (MonoMethod *method, guint32 address, MonoDomain *domain);
+
+void
+mono_debug_free_source_location (MonoDebugSourceLocation *location);
+
+gchar *
+mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDomain *domain);
+
+/*
+ * Mono Debugger support functions
+ *
+ * These methods are used by the JIT while running inside the Mono Debugger.
+ */
+
+int             mono_debugger_method_has_breakpoint       (MonoMethod *method);
+int             mono_debugger_insert_breakpoint           (const gchar *method_name, gboolean include_namespace);
+gboolean        mono_debugger_unhandled_exception         (gpointer addr, gpointer stack, MonoObject *exc);
+void            mono_debugger_handle_exception            (gpointer addr, gpointer stack, MonoObject *exc);
+gboolean        mono_debugger_throw_exception             (gpointer addr, gpointer stack, MonoObject *exc);
 
 #endif /* __MONO_DEBUG_H__ */