Tue Jun 22 16:48:02 CEST 2004 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / mono-debug.h
1 /*
2  * This header is only installed for use by the debugger:
3  * the structures and the API declared here are not supported.
4  */
5
6 #ifndef __MONO_DEBUG_H__
7 #define __MONO_DEBUG_H__
8
9 #include <glib.h>
10 #include <mono/metadata/image.h>
11 #include <mono/metadata/appdomain.h>
12
13 typedef struct _MonoSymbolFile                  MonoSymbolFile;
14 typedef struct _MonoSymbolFilePriv              MonoSymbolFilePriv;
15
16 typedef struct _MonoDebugHandle                 MonoDebugHandle;
17 typedef struct _MonoDebugHandlePriv             MonoDebugHandlePriv;
18 typedef struct _MonoDebugDomainData             MonoDebugDomainData;
19 typedef struct _MonoDebugDomainDataPriv         MonoDebugDomainDataPriv;
20
21 typedef struct _MonoDebugVarInfo                MonoDebugVarInfo;
22 typedef struct _MonoDebugMethodJitInfo          MonoDebugMethodJitInfo;
23
24 typedef enum {
25         MONO_DEBUG_FORMAT_NONE,
26         MONO_DEBUG_FORMAT_MONO,
27         MONO_DEBUG_FORMAT_DEBUGGER
28 } MonoDebugFormat;
29
30 struct _MonoDebugHandle {
31         const char *image_file;
32         MonoImage *image;
33         MonoSymbolFile *symfile;
34         MonoDebugHandlePriv *_priv;
35 };
36
37 struct _MonoDebugMethodJitInfo {
38         const guint8 *code_start;
39         guint32 code_size;
40         guint32 prologue_end;
41         guint32 epilogue_begin;
42         const guint8 *wrapper_addr;
43         // Array of MonoDebugLineNumberEntry
44         GArray *line_numbers;
45         guint32 num_params;
46         MonoDebugVarInfo *this_var;
47         MonoDebugVarInfo *params;
48         guint32 num_locals;
49         MonoDebugVarInfo *locals;
50 };
51
52 struct _MonoDebugDomainData {
53         guint32 domain_id;
54         MonoDebugMethodJitInfo **jit;
55         MonoDebugDomainDataPriv *_priv;
56 };
57
58 /*
59  * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
60  * where the variable is actually stored.
61  *
62  * See relocate_variable() in debug-symfile.c for more info.
63  */
64 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS               0xf0000000
65
66 /* The variable is in register "index". */
67 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER            0
68
69 /* The variable is at offset "offset" from register "index". */
70 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET           0x10000000
71
72 /* The variable is in the two registers "offset" and "index". */
73 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS       0x20000000
74
75 struct _MonoDebugVarInfo {
76         guint32 index;
77         guint32 offset;
78         guint32 size;
79         guint32 begin_scope;
80         guint32 end_scope;
81 };
82
83 #define MONO_DEBUGGER_VERSION                           43
84 #define MONO_DEBUGGER_MAGIC                             0x7aff65af4253d427ULL
85
86 extern MonoDebugFormat mono_debug_format;
87 extern GHashTable *mono_debug_handles;
88
89 void mono_debug_init (MonoDomain *domain, MonoDebugFormat format);
90 void mono_debug_init_2 (MonoAssembly *assembly);
91 void mono_debug_cleanup (void);
92 MonoDebugDomainData *mono_debug_get_domain_data (MonoDebugHandle *handle, MonoDomain *domain);
93 void mono_debug_add_wrapper (MonoMethod *method, MonoMethod *wrapper_method, MonoDomain *domain);
94 void mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
95 gchar *mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
96                                                 guint32 *line_number, MonoDomain *domain);
97 gchar *mono_debug_source_location_from_il_offset (MonoMethod *method, guint32 offset,
98                                                   guint32 *line_number);
99 gint32 mono_debug_il_offset_from_address (MonoMethod *method, gint32 address, MonoDomain *domain);
100 gint32 mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset, MonoDomain *domain);
101
102 #endif /* __MONO_DEBUG_H__ */