2003-04-24 Martin Baulig <martin@ximian.com>
[mono.git] / mono / metadata / mono-debug-debugger.h
1 #ifndef __MONO_DEBUG_DEBUGGER_H__
2 #define __MONO_DEBUG_DEBUGGER_H__
3
4 #include <glib.h>
5 #include <mono/metadata/debug-helpers.h>
6 #include <mono/metadata/debug-mono-symfile.h>
7
8 typedef struct _MonoDebuggerBreakpointInfo      MonoDebuggerBreakpointInfo;
9 typedef struct _MonoDebuggerSymbolTable         MonoDebuggerSymbolTable;
10 typedef struct _MonoDebuggerSymbolFile          MonoDebuggerSymbolFile;
11 typedef struct _MonoDebuggerSymbolFilePriv      MonoDebuggerSymbolFilePriv;
12 typedef struct _MonoDebuggerRangeInfo           MonoDebuggerRangeInfo;
13 typedef struct _MonoDebuggerClassInfo           MonoDebuggerClassInfo;
14
15 typedef enum {
16         MONO_DEBUGGER_EVENT_TYPE_ADDED,
17         MONO_DEBUGGER_EVENT_METHOD_ADDED,
18         MONO_DEBUGGER_EVENT_BREAKPOINT_TRAMPOLINE
19 } MonoDebuggerEvent;
20
21 struct _MonoDebuggerBreakpointInfo {
22         guint32 index;
23         gboolean use_trampoline;
24         MonoMethodDesc *desc;
25 };
26
27 struct _MonoDebuggerSymbolTable {
28         guint64 magic;
29         guint32 version;
30         guint32 total_size;
31
32         /*
33          * Type table.
34          * This is intentionally not a GPtrArray to make it more easy to
35          * read for the debugger.  The `type_tables' field contains
36          * `num_type_tables' pointers to continuous memory areas of
37          * `type_table_chunk_size' bytes each.
38          *
39          * The type table is basically a big continuous blob, but we need
40          * to split it up into pieces because we don't know the total size
41          * in advance and using g_realloc() doesn't work because that may
42          * reallocate the block to a different address.
43          */
44         guint32 num_type_tables;
45         guint32 type_table_chunk_size;
46         gpointer *type_tables;
47         /*
48          * Current type table.
49          * The `current_type_table' points to a blob of `type_table_chunk_size'
50          * bytes.
51          */
52         gpointer current_type_table;
53         /*
54          * This is the total size of the type table, including all the tables
55          * in the `type_tables' vector.
56          */
57         guint32 type_table_size;
58         /*
59          * These are global offsets - the `current_type_table' starts at global
60          * offset `type_table_start' and we've already allocated stuff in it
61          * until offset `type_table_offset'.
62          */
63         guint32 type_table_offset;
64         guint32 type_table_start;
65
66         /*
67          * The symbol files.
68          */
69         guint32 num_symbol_files;
70         MonoDebuggerSymbolFile **symbol_files;
71 };
72
73 struct _MonoDebuggerSymbolFile {
74         MonoSymbolFile *symfile;
75         const char *image_file;
76         /* Pointer to the malloced range table. */
77         guint32 locked;
78         guint32 generation;
79         MonoDebuggerRangeInfo *range_table;
80         guint32 range_entry_size;
81         guint32 num_range_entries;
82         /* Pointer to the malloced class table. */
83         MonoDebuggerClassInfo *class_table;
84         guint32 class_entry_size;
85         guint32 num_class_entries;
86         /* Private. */
87         MonoDebuggerSymbolFilePriv *_priv;
88 };
89
90 struct _MonoDebuggerRangeInfo {
91         const guint8 *start_address;
92         const guint8 *end_address;
93         guint32 index;
94         gpointer dynamic_data;
95         guint32 dynamic_size;
96 };
97
98 struct _MonoDebuggerClassInfo {
99         MonoClass *klass;
100         guint32 rank;
101         guint32 token;
102         guint32 type_info;
103 };
104
105 extern MonoDebuggerSymbolTable *mono_debugger_symbol_table;
106
107 extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, gpointer data, gpointer data2);
108
109 void            mono_debugger_initialize              (void);
110 void            mono_debugger_cleanup                 (void);
111
112 void            mono_debugger_lock                    (void);
113 void            mono_debugger_unlock                  (void);
114 void            mono_debugger_event                   (MonoDebuggerEvent event, gpointer data, gpointer data2);
115
116 MonoDebuggerSymbolFile *mono_debugger_add_symbol_file (MonoSymbolFile *symfile);
117 void            mono_debugger_add_type                (MonoDebuggerSymbolFile *symfile, MonoClass *klass);
118 void            mono_debugger_add_method              (MonoDebuggerSymbolFile *symfile, MonoMethod *method);
119
120 int             mono_debugger_insert_breakpoint_full  (MonoMethodDesc *desc, gboolean use_trampoline);
121 int             mono_debugger_remove_breakpoint       (int breakpoint_id);
122 int             mono_debugger_insert_breakpoint       (const gchar *method_name, gboolean include_namespace);
123 int             mono_debugger_method_has_breakpoint   (MonoMethod* method, gboolean use_trampoline);
124 void            mono_debugger_trampoline_breakpoint_callback (void);
125
126 gpointer        mono_debugger_create_notification_function (gpointer *notification_address);
127
128 MonoReflectionMethod *
129 ves_icall_MonoDebugger_GetMethod (MonoReflectionAssembly *assembly, guint32 token);
130
131 int
132 ves_icall_MonoDebugger_GetMethodToken (MonoReflectionAssembly *assembly, MonoReflectionMethod *method);
133
134 MonoReflectionType *
135 ves_icall_MonoDebugger_GetLocalTypeFromSignature (MonoReflectionAssembly *assembly, MonoArray *signature);
136
137 MonoReflectionType *
138 ves_icall_MonoDebugger_GetType (MonoReflectionAssembly *assembly, guint32 token);
139
140 #endif /* __MONO_DEBUG_DEBUGGER_H__ */