2002-05-20 Martin Baulig <martin@gnome.org>
[mono.git] / mono / metadata / debug-symfile.h
1 #ifndef __MONO_DEBUG_SYMFILE_H__
2 #define __MONO_DEBUG_SYMFILE_H__
3
4 #include <glib.h>
5 #include <mono/metadata/class.h>
6 #include <mono/metadata/reflection.h>
7
8 typedef struct MonoDebugSymbolFile              MonoDebugSymbolFile;
9 typedef struct MonoDebugSymbolFileSection       MonoDebugSymbolFileSection;
10 typedef struct MonoDebugMethodInfo              MonoDebugMethodInfo;
11 typedef struct MonoDebugVarInfo                 MonoDebugVarInfo;
12 typedef struct MonoDebugILOffsetInfo            MonoDebugILOffsetInfo;
13
14 /* Machine dependent information about a method.
15  *
16  * This structure is created by the MonoDebugMethodInfoFunc callback of
17  * mono_debug_update_symbol_file (). */
18 struct MonoDebugMethodInfo {
19         MonoMethod *method;
20         char *code_start;
21         guint32 code_size;
22         guint32 num_params;
23         MonoDebugVarInfo *this_var;
24         MonoDebugVarInfo *params;
25         guint32 num_locals;
26         MonoDebugVarInfo *locals;
27         guint32 num_il_offsets;
28         MonoDebugILOffsetInfo *il_offsets;
29         guint32 prologue_end;
30         guint32 epilogue_begin;
31         gpointer _priv;
32 };
33
34 /*
35  * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
36  * where the variable is actually stored.
37  *
38  * See relocate_variable() in debug-symfile.c for more info.
39  */
40 #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS               0xf0000000
41
42 /* If "index" is zero, the variable is at stack offset "offset". */
43 #define MONO_DEBUG_VAR_ADDRESS_MODE_STACK               0
44
45 /* The variable is in the register whose number is contained in bits 0..4 of the
46  * "index" field plus an offset of "offset" (which can be zero).
47  */
48 #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER            0x10000000
49
50 /* The variables in in the two registers whose numbers are contained in bits 0..4
51  * and 5..9 of the "index" field plus an offset of "offset" (which can be zero).
52  */
53 #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS       0x20000000
54
55 struct MonoDebugVarInfo {
56         guint32 index;
57         guint32 offset;
58         guint32 begin_scope;
59         guint32 end_scope;
60 };
61
62 struct MonoDebugILOffsetInfo {
63         guint32 offset;
64         guint32 address;
65 };
66
67 struct MonoDebugSymbolFile {
68         int fd;
69         char *file_name;
70         MonoImage *image;
71         /* Pointer to the mmap()ed contents of the file. */
72         char *raw_contents;
73         size_t raw_contents_size;
74         /* Array of MONO_DEBUG_SYMBOL_SECTION_MAX elements. */
75         MonoDebugSymbolFileSection *section_offsets;
76         gpointer user_data;
77 };
78
79 struct MonoDebugSymbolFileSection {
80         int type;
81         gulong file_offset;
82         gulong size;
83 };
84
85 #define MONO_DEBUG_SYMBOL_FILE_VERSION                  10
86
87 /* Keep in sync with Mono.CSharp.Debugger.MonoDwarfFileWriter.Section */
88 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_INFO            0x01
89 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_ABBREV          0x02
90 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_LINE            0x03
91 #define MONO_DEBUG_SYMBOL_SECTION_MONO_RELOC_TABLE      0x04
92
93 #define MONO_DEBUG_SYMBOL_SECTION_MAX                   0x05
94
95 /* Tries to load `filename' as a debugging information file, if `emit_warnings" is set,
96  * use g_warning() to signal error messages on failure, otherwise silently return NULL. */
97 MonoDebugSymbolFile *mono_debug_open_symbol_file   (MonoImage                 *image,
98                                                     const char                *filename,
99                                                     gboolean                   emit_warnings);
100
101 /* This callback function needs to return a MonoDebugMethodInfo structure containing the
102  * machine-dependent information about method associated with the metadata_token.
103  * It's highly recommended to cache the generated data since this function can be called
104  * several times per method. */
105 typedef MonoDebugMethodInfo * (*MonoDebugMethodInfoFunc) (MonoDebugSymbolFile *symbol_file,
106                                                           guint32              metadata_token,
107                                                           gpointer             user_data);
108
109 void    mono_debug_update_symbol_file (MonoDebugSymbolFile      *symbol_file,
110                                        MonoDebugMethodInfoFunc   method_info_func,
111                                        gpointer                  user_data);
112
113 void    mono_debug_close_symbol_file  (MonoDebugSymbolFile      *symbol_file);
114
115 MonoReflectionType *
116 ves_icall_Debugger_MonoSymbolWriter_get_local_type_from_sig (MonoReflectionAssembly *assembly,
117                                                              MonoArray *signature);
118
119 MonoReflectionMethod *
120 ves_icall_Debugger_MonoSymbolWriter_method_from_token (MonoReflectionAssembly *assembly,
121                                                        guint32 token);
122
123 guint32
124 ves_icall_Debugger_DwarfFileWriter_get_type_token (MonoReflectionType *type);
125
126
127 #endif /* __MONO_DEBUG_SYMFILE_H__ */
128