2 * This header is only installed for use by the debugger:
3 * the structures and the API declared here are not supported.
6 #ifndef __MONO_DEBUG_H__
7 #define __MONO_DEBUG_H__
10 #include <mono/metadata/image.h>
11 #include <mono/metadata/appdomain.h>
13 typedef struct _MonoSymbolTable MonoSymbolTable
;
15 typedef struct _MonoSymbolFile MonoSymbolFile
;
16 typedef struct _MonoSymbolFilePriv MonoSymbolFilePriv
;
18 typedef struct _MonoDebugHandle MonoDebugHandle
;
19 typedef struct _MonoDebugHandlePriv MonoDebugHandlePriv
;
21 typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry
;
22 typedef struct _MonoDebugLexicalBlockEntry MonoDebugLexicalBlockEntry
;
24 typedef struct _MonoDebugVarInfo MonoDebugVarInfo
;
25 typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo
;
26 typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress
;
27 typedef struct _MonoDebugWrapperData MonoDebugWrapperData
;
28 typedef struct _MonoDebugClassEntry MonoDebugClassEntry
;
30 typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo
;
31 typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation
;
34 MONO_DEBUG_FORMAT_NONE
,
35 MONO_DEBUG_FORMAT_MONO
,
36 MONO_DEBUG_FORMAT_DEBUGGER
40 MONO_DEBUGGER_TYPE_KIND_UNKNOWN
= 1,
41 MONO_DEBUGGER_TYPE_KIND_FUNDAMENTAL
,
42 MONO_DEBUGGER_TYPE_KIND_STRING
,
43 MONO_DEBUGGER_TYPE_KIND_SZARRAY
,
44 MONO_DEBUGGER_TYPE_KIND_ARRAY
,
45 MONO_DEBUGGER_TYPE_KIND_POINTER
,
46 MONO_DEBUGGER_TYPE_KIND_ENUM
,
47 MONO_DEBUGGER_TYPE_KIND_OBJECT
,
48 MONO_DEBUGGER_TYPE_KIND_STRUCT
,
49 MONO_DEBUGGER_TYPE_KIND_CLASS
,
50 MONO_DEBUGGER_TYPE_KIND_CLASS_INFO
,
51 MONO_DEBUGGER_TYPE_KIND_REFERENCE
52 } MonoDebuggerTypeKind
;
54 struct _MonoSymbolTable
{
60 * Corlib and metadata info.
62 MonoDebugHandle
*corlib
;
67 MonoDebugHandle
**symbol_files
;
68 guint32 num_symbol_files
;
72 * This is intentionally not a GPtrArray to make it more easy to
73 * read for the debugger. The `data_tables' field contains
74 * `num_data_tables' pointers to continuous memory areas.
76 * The data table is basically a big continuous blob, but we need
77 * to split it up into pieces because we don't know the total size
78 * in advance and using g_realloc() doesn't work because that may
79 * reallocate the block to a different address.
81 guint32 num_data_tables
;
82 gpointer
*data_tables
;
85 * The `current_data_table' points to a blob of `current_data_table_size'
88 gpointer current_data_table
;
89 guint32 current_data_table_size
;
91 * The offset in the `current_data_table'.
93 guint32 current_data_table_offset
;
97 MONO_DEBUG_DATA_ITEM_UNKNOWN
= 0,
98 MONO_DEBUG_DATA_ITEM_METHOD
,
99 MONO_DEBUG_DATA_ITEM_CLASS
,
100 MONO_DEBUG_DATA_ITEM_WRAPPER
101 } MonoDebugDataItemType
;
103 struct _MonoDebugHandle
{
107 MonoSymbolFile
*symfile
;
108 MonoDebugHandlePriv
*_priv
;
111 struct _MonoDebugMethodJitInfo
{
112 MonoDebugMethodAddress
*address
;
113 const guint8
*code_start
;
115 guint32 prologue_end
;
116 guint32 epilogue_begin
;
117 const guint8
*wrapper_addr
;
118 guint32 num_line_numbers
;
119 MonoDebugLineNumberEntry
*line_numbers
;
120 guint32 num_lexical_blocks
;
121 MonoDebugLexicalBlockEntry
*lexical_blocks
;
123 MonoDebugVarInfo
*this_var
;
124 MonoDebugVarInfo
*params
;
126 MonoDebugVarInfo
*locals
;
129 struct _MonoDebugMethodAddress
{
136 const guint8
*code_start
;
137 const guint8
*wrapper_addr
;
138 MonoDebugMethodJitInfo
*jit
;
139 guint8 data
[MONO_ZERO_LEN_ARRAY
];
142 struct _MonoDebugWrapperData
{
146 const guint8
*code_start
;
148 const gchar
*cil_code
;
149 guint8 data
[MONO_ZERO_LEN_ARRAY
];
152 struct _MonoDebugClassEntry
{
155 guint8 data
[MONO_ZERO_LEN_ARRAY
];
158 struct _MonoDebugSourceLocation
{
165 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
166 * where the variable is actually stored.
168 * See relocate_variable() in debug-symfile.c for more info.
170 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
172 /* The variable is in register "index". */
173 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
175 /* The variable is at offset "offset" from register "index". */
176 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
178 /* The variable is in the two registers "offset" and "index". */
179 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
181 struct _MonoDebugVarInfo
{
189 #define MONO_DEBUGGER_VERSION 58
190 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
192 extern MonoSymbolTable
*mono_symbol_table
;
193 extern MonoDebugFormat mono_debug_format
;
194 extern GHashTable
*mono_debug_handles
;
196 void mono_debug_init (MonoDebugFormat format
);
197 void mono_debug_init_1 (MonoDomain
*domain
);
198 void mono_debug_init_2 (MonoAssembly
*assembly
);
199 void mono_debug_init_2_memory (MonoImage
*image
, const guint8
*raw_contents
, int size
);
200 void mono_debug_cleanup (void);
202 gboolean
mono_debug_using_mono_debugger (void);
204 MonoDebugMethodAddress
*mono_debug_add_method (MonoMethod
*method
, MonoDebugMethodJitInfo
*jit
,
206 MonoDebugMethodJitInfo
*mono_debug_read_method (MonoDebugMethodAddress
*address
);
207 void mono_debug_free_method_jit_info (MonoDebugMethodJitInfo
*jit
);
209 MonoDebugMethodInfo
*mono_debug_lookup_method (MonoMethod
*method
);
211 MonoDebugMethodJitInfo
*
212 mono_debug_find_method (MonoDebugMethodInfo
*minfo
, MonoDomain
*domain
);
215 * Line number support.
218 MonoDebugSourceLocation
*
219 mono_debug_lookup_source_location (MonoMethod
*method
, guint32 address
, MonoDomain
*domain
);
222 mono_debug_free_source_location (MonoDebugSourceLocation
*location
);
225 mono_debug_print_stack_frame (MonoMethod
*method
, guint32 native_offset
, MonoDomain
*domain
);
228 * Mono Debugger support functions
230 * These methods are used by the JIT while running inside the Mono Debugger.
233 int mono_debugger_method_has_breakpoint (MonoMethod
*method
);
234 int mono_debugger_insert_breakpoint (const gchar
*method_name
, gboolean include_namespace
);
235 gboolean
mono_debugger_unhandled_exception (gpointer addr
, gpointer stack
, MonoObject
*exc
);
236 void mono_debugger_handle_exception (gpointer addr
, gpointer stack
, MonoObject
*exc
);
237 gboolean
mono_debugger_throw_exception (gpointer addr
, gpointer stack
, MonoObject
*exc
);
239 #endif /* __MONO_DEBUG_H__ */