[2020-02] Fix leak in assembly-specific dllmap lookups (#21053)
[mono-project.git] / mono / metadata / mono-debug.h
blobb9948b6633964c6f801ec23424be397bd2dc3675
1 /**
2 * \file
3 * This header is only installed for use by the debugger:
4 * the structures and the API declared here are not supported.
5 */
7 #ifndef __MONO_DEBUG_H__
8 #define __MONO_DEBUG_H__
10 #include <mono/utils/mono-publib.h>
11 #include <mono/metadata/image.h>
12 #include <mono/metadata/appdomain.h>
14 MONO_BEGIN_DECLS
16 typedef struct _MonoSymbolTable MonoSymbolTable;
17 typedef struct _MonoDebugDataTable MonoDebugDataTable;
19 typedef struct _MonoSymbolFile MonoSymbolFile;
20 typedef struct _MonoPPDBFile MonoPPDBFile;
22 typedef struct _MonoDebugHandle MonoDebugHandle;
24 typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
26 typedef struct _MonoDebugVarInfo MonoDebugVarInfo;
27 typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
28 typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress;
29 typedef struct _MonoDebugMethodAddressList MonoDebugMethodAddressList;
30 typedef struct _MonoDebugClassEntry MonoDebugClassEntry;
32 typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo;
33 typedef struct _MonoDebugLocalsInfo MonoDebugLocalsInfo;
34 typedef struct _MonoDebugMethodAsyncInfo MonoDebugMethodAsyncInfo;
35 typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation;
37 typedef struct _MonoDebugList MonoDebugList;
39 typedef enum {
40 MONO_DEBUG_FORMAT_NONE,
41 MONO_DEBUG_FORMAT_MONO,
42 /* Deprecated, the mdb debugger is not longer supported. */
43 MONO_DEBUG_FORMAT_DEBUGGER
44 } MonoDebugFormat;
47 * NOTE:
48 * We intentionally do not use GList here since the debugger needs to know about
49 * the layout of the fields.
51 struct _MonoDebugList {
52 MonoDebugList *next;
53 const void* data;
56 struct _MonoSymbolTable {
57 uint64_t magic;
58 uint32_t version;
59 uint32_t total_size;
62 * Corlib and metadata info.
64 MonoDebugHandle *corlib;
65 MonoDebugDataTable *global_data_table;
66 MonoDebugList *data_tables;
69 * The symbol files.
71 MonoDebugList *symbol_files;
74 struct _MonoDebugHandle {
75 uint32_t index;
76 char *image_file;
77 MonoImage *image;
78 MonoDebugDataTable *type_table;
79 MonoSymbolFile *symfile;
80 MonoPPDBFile *ppdb;
83 struct _MonoDebugMethodJitInfo {
84 const mono_byte *code_start;
85 uint32_t code_size;
86 uint32_t prologue_end;
87 uint32_t epilogue_begin;
88 const mono_byte *wrapper_addr;
89 uint32_t num_line_numbers;
90 MonoDebugLineNumberEntry *line_numbers;
91 uint32_t has_var_info;
92 uint32_t num_params;
93 MonoDebugVarInfo *this_var;
94 MonoDebugVarInfo *params;
95 uint32_t num_locals;
96 MonoDebugVarInfo *locals;
97 MonoDebugVarInfo *gsharedvt_info_var;
98 MonoDebugVarInfo *gsharedvt_locals_var;
101 struct _MonoDebugMethodAddressList {
102 uint32_t size;
103 uint32_t count;
104 mono_byte data [MONO_ZERO_LEN_ARRAY];
107 struct _MonoDebugSourceLocation {
108 char *source_file;
109 uint32_t row, column;
110 uint32_t il_offset;
113 MONO_API mono_bool mono_debug_enabled (void);
116 * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
117 * where the variable is actually stored.
119 * See relocate_variable() in debug-symfile.c for more info.
121 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
123 /* The variable is in register "index". */
124 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
126 /* The variable is at offset "offset" from register "index". */
127 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
129 /* The variable is in the two registers "offset" and "index". */
130 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
132 /* The variable is dead. */
133 #define MONO_DEBUG_VAR_ADDRESS_MODE_DEAD 0x30000000
135 /* Same as REGOFFSET, but do an indirection */
136 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR 0x40000000
138 /* gsharedvt local */
139 #define MONO_DEBUG_VAR_ADDRESS_MODE_GSHAREDVT_LOCAL 0x50000000
141 /* variable is a vt address */
142 #define MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR 0x60000000
144 struct _MonoDebugVarInfo {
145 uint32_t index;
146 uint32_t offset;
147 uint32_t size;
148 uint32_t begin_scope;
149 uint32_t end_scope;
150 MonoType *type;
153 #define MONO_DEBUGGER_MAJOR_VERSION 81
154 #define MONO_DEBUGGER_MINOR_VERSION 6
155 #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
157 MONO_API void mono_debug_init (MonoDebugFormat format);
158 MONO_API void mono_debug_open_image_from_memory (MonoImage *image, const mono_byte *raw_contents, int size);
159 MONO_API void mono_debug_cleanup (void);
161 MONO_API void mono_debug_close_image (MonoImage *image);
163 MONO_API void mono_debug_domain_unload (MonoDomain *domain);
164 MONO_API void mono_debug_domain_create (MonoDomain *domain);
166 MONO_API MonoDebugMethodAddress *
167 mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
169 MONO_API void
170 mono_debug_remove_method (MonoMethod *method, MonoDomain *domain);
172 MONO_API MonoDebugMethodInfo *
173 mono_debug_lookup_method (MonoMethod *method);
175 MONO_API MonoDebugMethodAddressList *
176 mono_debug_lookup_method_addresses (MonoMethod *method);
178 MONO_API MonoDebugMethodJitInfo*
179 mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
181 MONO_API MonoDebugHandle *
182 mono_debug_get_handle (MonoImage *image);
184 MONO_API void
185 mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
188 MONO_API void
189 mono_debug_add_delegate_trampoline (void* code, int size);
191 MONO_API MonoDebugLocalsInfo*
192 mono_debug_lookup_locals (MonoMethod *method);
194 MonoDebugMethodAsyncInfo*
195 mono_debug_lookup_method_async_debug_info (MonoMethod *method);
197 // The intent here is really MONO_LLVM_INTERNAL but that is not necessarily available.
198 MONO_API
199 MonoDebugSourceLocation *
200 mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset);
203 * Line number support.
206 MONO_API MonoDebugSourceLocation *
207 mono_debug_lookup_source_location (MonoMethod *method, uint32_t address, MonoDomain *domain);
209 MONO_API int32_t
210 mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, uint32_t native_offset);
212 MONO_API void
213 mono_debug_free_source_location (MonoDebugSourceLocation *location);
215 MONO_API char *
216 mono_debug_print_stack_frame (MonoMethod *method, uint32_t native_offset, MonoDomain *domain);
219 * Mono Debugger support functions
221 * These methods are used by the JIT while running inside the Mono Debugger.
224 MONO_API int mono_debugger_method_has_breakpoint (MonoMethod *method);
225 MONO_API int mono_debugger_insert_breakpoint (const char *method_name, mono_bool include_namespace);
227 MONO_API void mono_set_is_debugger_attached (mono_bool attached);
228 MONO_API mono_bool mono_is_debugger_attached (void);
230 MONO_END_DECLS
232 #endif /* __MONO_DEBUG_H__ */