2002-03-23 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
7 typedef struct MonoDebugSymbolFile              MonoDebugSymbolFile;
8 typedef struct MonoDebugSymbolFileSection       MonoDebugSymbolFileSection;
9 typedef struct MonoDebugMethodInfo              MonoDebugMethodInfo;
10 typedef struct MonoDebugILOffsetInfo            MonoDebugILOffsetInfo;
11
12 /* Machine dependent information about a method.
13  *
14  * This structure is created by the MonoDebugMethodInfoFunc callback of
15  * mono_debug_update_symbol_file (). */
16 struct MonoDebugMethodInfo {
17         MonoMethod *method;
18         gpointer code_start;
19         guint32 code_size;
20         guint32 num_params;
21         guint32 *param_offsets;
22         guint32 num_locals;
23         guint32 *local_offsets;
24         guint32 num_il_offsets;
25         MonoDebugILOffsetInfo *il_offsets;
26         gpointer _priv;
27 };
28
29 struct MonoDebugILOffsetInfo {
30         guint32 offset;
31         guint32 address;
32 };
33
34 struct MonoDebugSymbolFile {
35         int fd;
36         char *file_name;
37         MonoImage *image;
38         /* Pointer to the mmap()ed contents of the file. */
39         void *raw_contents;
40         size_t raw_contents_size;
41         /* Array of MONO_DEBUG_SYMBOL_SECTION_MAX elements. */
42         MonoDebugSymbolFileSection *section_offsets;
43         gpointer user_data;
44 };
45
46 struct MonoDebugSymbolFileSection {
47         int type;
48         gulong file_offset;
49         gulong size;
50 };
51
52 #define MONO_DEBUG_SYMBOL_FILE_VERSION                  5
53
54 /* Keep in sync with Mono.CSharp.Debugger.MonoDwarfFileWriter.Section */
55 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_INFO            0x01
56 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_ABBREV          0x02
57 #define MONO_DEBUG_SYMBOL_SECTION_DEBUG_LINE            0x03
58 #define MONO_DEBUG_SYMBOL_SECTION_MONO_RELOC_TABLE      0x04
59
60 #define MONO_DEBUG_SYMBOL_SECTION_MAX                   0x05
61
62 /* Tries to load `filename' as a debugging information file, if `emit_warnings" is set,
63  * use g_warning() to signal error messages on failure, otherwise silently return NULL. */
64 MonoDebugSymbolFile *mono_debug_open_symbol_file   (MonoImage                 *image,
65                                                     const char                *filename,
66                                                     gboolean                   emit_warnings);
67
68 /* This callback function needs to return a MonoDebugMethodInfo structure containing the
69  * machine-dependent information about method associated with the metadata_token.
70  * It's highly recommended to cache the generated data since this function can be called
71  * several times per method. */
72 typedef MonoDebugMethodInfo * (*MonoDebugMethodInfoFunc) (MonoDebugSymbolFile *symbol_file,
73                                                           guint32              metadata_token,
74                                                           gpointer             user_data);
75
76 void    mono_debug_update_symbol_file (MonoDebugSymbolFile      *symbol_file,
77                                        MonoDebugMethodInfoFunc   method_info_func,
78                                        gpointer                  user_data);
79
80 void    mono_debug_close_symbol_file  (MonoDebugSymbolFile      *symbol_file);
81
82 #endif /* __MONO_DEBUG_SYMFILE_H__ */
83