2002-08-27 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_DWARF2_PLUS,
17         MONO_DEBUG_FORMAT_MONO
18 } MonoDebugFormat;
19
20 extern MonoDebugFormat mono_debug_format;
21 extern GList *mono_debug_methods;
22
23 /*
24  * This variable is intended to be set in a debugger.
25  *
26  * If it's non-zero, arch_compile_method() will insert a breakpoint next time
27  * it compiles a method.
28  *
29  * If it's positive, it acts as a counter which is decremented each time it's
30  * used. Set it to a negative value to make arch_compile_method() insert a
31  * breakpoint for each method.
32  *
33  * To use this, you should create a GDB macro like this:
34  *
35  *    define enter
36  *      set mono_debug_insert_breakpoint = 1
37  *      continue
38  *      set *mono_debug_last_breakpoint_address = 0x90
39  *      reload-symbol-files
40  *      frame
41  *    end
42  *
43  *    define reload-symbol-files
44  *      call mono_debug_make_symbols ()
45  *      add-symbol-file Test-debug.o
46  *      add-symbol-file /tmp/corlib.o
47  *    end
48  *
49  */
50 extern int mono_debug_insert_breakpoint;
51
52 /*
53  * This is set the the core address of the last inserted breakpoint. You can
54  * use this in GDB to unset the breakpoint.
55  */
56
57 extern gchar *mono_debug_last_breakpoint_address;
58
59 MonoDebugHandle* mono_debug_open (MonoAssembly *assembly, MonoDebugFormat format,
60                                   const char **args);
61
62 void           mono_debug_cleanup (void);
63
64 void           mono_debug_add_image (MonoDebugHandle* debug, MonoImage *image);
65
66 MonoDebugHandle* mono_debug_handle_from_class (MonoClass *klass);
67
68 void           mono_debug_add_method (MonoFlowGraph *cfg);
69
70 void           mono_debug_add_type (MonoClass *klass);
71
72 gchar *        mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
73                                                         guint32 *line_number);
74
75 gint32         mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
76
77 gint32         mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
78
79 /* DEBUGGER PUBLIC FUNCTION:
80  *
81  * This is a public function which is supposed to be called from within a debugger
82  * each time the program stops. It's used to recreate the symbol file to tell the
83  * debugger about method addresses and such things. After calling this function,
84  * you must tell your debugger to reload its symbol file.
85  */
86 void           mono_debug_make_symbols (void);
87
88 void           mono_debug_write_symbols (MonoDebugHandle* debug);
89
90 /*
91  * Do not use these two functions unless you know exactly what you're doing.
92  *
93  * Returns a pointer to a region of memory within the JIT's address space.  The Mono
94  * Debugger uses this data to get information about the symbol files.
95  */
96 MonoSymbolFile *mono_debugger_internal_get_symbol_files (void);
97 void mono_debugger_internal_free_symbol_files (gpointer data);
98 extern int mono_debugger_internal_symbol_files_changed;
99
100 #endif /* __MONO_JIT_DEBUG_H__ */