2005-06-27 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / metadata / mono-debug.h
index 6956ca7e6efb16689e51146cc89c6f8632e81a64..41de11ae69eb914d6ee9fb61c39cc9a4a4abe033 100644 (file)
@@ -1,3 +1,8 @@
+/*
+ * This header is only installed for use by the debugger:
+ * the structures and the API declared here are not supported.
+ */
+
 #ifndef __MONO_DEBUG_H__
 #define __MONO_DEBUG_H__
 
 #include <mono/metadata/image.h>
 #include <mono/metadata/appdomain.h>
 
+typedef struct _MonoSymbolTable                        MonoSymbolTable;
+
 typedef struct _MonoSymbolFile                 MonoSymbolFile;
 typedef struct _MonoSymbolFilePriv             MonoSymbolFilePriv;
 
 typedef struct _MonoDebugHandle                        MonoDebugHandle;
 typedef struct _MonoDebugHandlePriv            MonoDebugHandlePriv;
-typedef struct _MonoDebugDomainData            MonoDebugDomainData;
-typedef struct _MonoDebugDomainDataPriv                MonoDebugDomainDataPriv;
+
+typedef struct _MonoDebugLineNumberEntry       MonoDebugLineNumberEntry;
+typedef struct _MonoDebugLexicalBlockEntry     MonoDebugLexicalBlockEntry;
 
 typedef struct _MonoDebugVarInfo               MonoDebugVarInfo;
 typedef struct _MonoDebugMethodJitInfo         MonoDebugMethodJitInfo;
+typedef struct _MonoDebugMethodAddress         MonoDebugMethodAddress;
+typedef struct _MonoDebugClassEntry            MonoDebugClassEntry;
+
+typedef struct _MonoDebuggerMetadataInfo       MonoDebuggerMetadataInfo;
 
 typedef enum {
        MONO_DEBUG_FORMAT_NONE,
@@ -22,7 +34,72 @@ typedef enum {
        MONO_DEBUG_FORMAT_DEBUGGER
 } MonoDebugFormat;
 
+typedef enum {
+       MONO_DEBUGGER_TYPE_KIND_UNKNOWN = 1,
+       MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL,
+       MONO_DEBUGGER_TYPE_KIND_STRING,
+       MONO_DEBUGGER_TYPE_KIND_SZARRAY,
+       MONO_DEBUGGER_TYPE_KIND_ARRAY,
+       MONO_DEBUGGER_TYPE_KIND_POINTER,
+       MONO_DEBUGGER_TYPE_KIND_ENUM,
+       MONO_DEBUGGER_TYPE_KIND_OBJECT,
+       MONO_DEBUGGER_TYPE_KIND_STRUCT,
+       MONO_DEBUGGER_TYPE_KIND_CLASS,
+       MONO_DEBUGGER_TYPE_KIND_CLASS_INFO,
+       MONO_DEBUGGER_TYPE_KIND_REFERENCE
+} MonoDebuggerTypeKind;
+
+struct _MonoSymbolTable {
+       guint64 magic;
+       guint32 version;
+       guint32 total_size;
+
+       /*
+        * Corlib and metadata info.
+        */
+       MonoDebugHandle *corlib;
+       MonoDebuggerMetadataInfo *metadata_info;
+
+       /*
+        * The symbol files.
+        */
+       MonoDebugHandle **symbol_files;
+       guint32 num_symbol_files;
+
+       /*
+        * 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'.
+        */
+       guint32 current_data_table_offset;
+};
+
+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;
        MonoImage *image;
        MonoSymbolFile *symfile;
@@ -30,13 +107,16 @@ struct _MonoDebugHandle {
 };
 
 struct _MonoDebugMethodJitInfo {
+       MonoDebugMethodAddress *address;
        const guint8 *code_start;
        guint32 code_size;
        guint32 prologue_end;
        guint32 epilogue_begin;
        const guint8 *wrapper_addr;
-       // Array of MonoDebugLineNumberEntry
-       GArray *line_numbers;
+       guint32 num_line_numbers;
+       MonoDebugLineNumberEntry *line_numbers;
+       guint32 num_lexical_blocks;
+       MonoDebugLexicalBlockEntry *lexical_blocks;
        guint32 num_params;
        MonoDebugVarInfo *this_var;
        MonoDebugVarInfo *params;
@@ -44,10 +124,23 @@ struct _MonoDebugMethodJitInfo {
        MonoDebugVarInfo *locals;
 };
 
-struct _MonoDebugDomainData {
+struct _MonoDebugMethodAddress {
+       guint32 size;
+       guint32 symfile_id;
        guint32 domain_id;
-       MonoDebugMethodJitInfo **jit;
-       MonoDebugDomainDataPriv *_priv;
+       guint32 method_id;
+       guint32 code_size;
+       guint32 dummy;
+       const guint8 *code_start;
+       const guint8 *wrapper_addr;
+       MonoDebugMethodJitInfo *jit;
+       guint8 data [MONO_ZERO_LEN_ARRAY];
+};
+
+struct _MonoDebugClassEntry {
+       guint32 size;
+       guint32 symfile_id;
+       guint8 data [MONO_ZERO_LEN_ARRAY];
 };
 
 /*
@@ -75,18 +168,22 @@ struct _MonoDebugVarInfo {
        guint32 end_scope;
 };
 
-#define MONO_DEBUGGER_VERSION                          32
-#define MONO_DEBUGGER_MAGIC                            0x7aff65af4253d427
+#define MONO_DEBUGGER_VERSION                          50
+#define MONO_DEBUGGER_MAGIC                            0x7aff65af4253d427ULL
 
+extern MonoSymbolTable *mono_symbol_table;
 extern MonoDebugFormat mono_debug_format;
 extern GHashTable *mono_debug_handles;
 
-void mono_debug_init (MonoDomain *domain, MonoDebugFormat format);
+void mono_debug_init (MonoDebugFormat format);
+void mono_debug_init_1 (MonoDomain *domain);
 void mono_debug_init_2 (MonoAssembly *assembly);
 void mono_debug_cleanup (void);
-MonoDebugDomainData *mono_debug_get_domain_data (MonoDebugHandle *handle, MonoDomain *domain);
-void mono_debug_add_wrapper (MonoMethod *method, MonoMethod *wrapper_method, MonoDomain *domain);
-void mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
+
+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,