2002-09-03 Martin Baulig <martin@gnome.org>
[mono.git] / mono / jit / debug.h
1 #ifndef __MONO_JIT_DEBUG_H__
2 #define __MONO_JIT_DEBUG_H__
3
4 #include <glib.h>
5 #include <stdio.h>
6 #include <mono/metadata/debug-mono-symfile.h>
7 #include <mono/metadata/loader.h>
8 #include <mono/jit/jit.h>
9
10 typedef struct _MonoDebugHandle MonoDebugHandle;
11
12 typedef enum {
13         MONO_DEBUG_FORMAT_NONE,
14         MONO_DEBUG_FORMAT_STABS,
15         MONO_DEBUG_FORMAT_DWARF2,
16         MONO_DEBUG_FORMAT_MONO
17 } MonoDebugFormat;
18
19 extern MonoDebugFormat mono_debug_format;
20 extern GList *mono_debug_methods;
21
22 /*
23  * This variable is intended to be set in a debugger.
24  *
25  * If it's non-zero, arch_compile_method() will insert a breakpoint next time
26  * it compiles a method.
27  *
28  * If it's positive, it acts as a counter which is decremented each time it's
29  * used. Set it to a negative value to make arch_compile_method() insert a
30  * breakpoint for each method.
31  *
32  * To use this, you should create a GDB macro like this:
33  *
34  *    define enter
35  *      set mono_debug_insert_breakpoint = 1
36  *      continue
37  *      set *mono_debug_last_breakpoint_address = 0x90
38  *      reload-symbol-files
39  *      frame
40  *    end
41  *
42  *    define reload-symbol-files
43  *      call mono_debug_make_symbols ()
44  *      add-symbol-file Test-debug.o
45  *      add-symbol-file /tmp/corlib.o
46  *    end
47  *
48  */
49 extern int mono_debug_insert_breakpoint;
50
51 /*
52  * This is set the the core address of the last inserted breakpoint. You can
53  * use this in GDB to unset the breakpoint.
54  */
55
56 extern gchar *mono_debug_last_breakpoint_address;
57
58 MonoDebugHandle* mono_debug_open (const char *name, MonoDebugFormat format, const char **args);
59
60 void           mono_debug_cleanup (void);
61
62 void           mono_debug_add_image (MonoDebugHandle* debug, MonoImage *image);
63
64 MonoDebugHandle* mono_debug_handle_from_class (MonoClass *klass);
65
66 void           mono_debug_add_method (MonoFlowGraph *cfg);
67
68 void           mono_debug_add_type (MonoClass *klass);
69
70 gchar *        mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
71                                                         guint32 *line_number);
72
73 gint32         mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
74
75 gint32         mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
76
77 /* DEBUGGER PUBLIC FUNCTION:
78  *
79  * This is a public function which is supposed to be called from within a debugger
80  * each time the program stops. It's used to recreate the symbol file to tell the
81  * debugger about method addresses and such things. After calling this function,
82  * you must tell your debugger to reload its symbol file.
83  */
84 void           mono_debug_make_symbols (void);
85
86 void           mono_debug_write_symbols (MonoDebugHandle* debug);
87
88 /* Update all symbol files.  Returns TRUE if the symbol have changed and FALSE if not. */
89 int            mono_debugger_update_symbol_file_table (void);
90
91 /*
92  * Address of the x86 trampoline code.  This is used by the debugger to check
93  * whether a method is a trampoline.
94  */
95 extern guint8 *mono_generic_trampoline_code;
96
97 /* This is incremented each time the symbol table is modified.
98  * The debugger looks at this variable and if it has a higher value than its current
99  * copy of the symbol table, it must call mono_debugger_update_symbol_file_table().
100  */
101
102 extern guint32 mono_debugger_symbol_file_table_generation;
103
104 /* Caution: This variable may be accessed at any time from the debugger;
105  *          it is very important not to modify the memory it is pointing to
106  *          without previously setting this pointer back to NULL.
107  */
108 extern guint8 *mono_debugger_symbol_file_table;
109
110 #endif /* __MONO_JIT_DEBUG_H__ */