2002-07-24 Tim Coleman <tim@timcoleman.com>
[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-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 } 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 (MonoAssembly *assembly, MonoDebugFormat format,
59                                   const char **args);
60
61 void           mono_debug_cleanup (void);
62
63 void           mono_debug_add_image (MonoDebugHandle* debug, MonoImage *image);
64
65 MonoDebugHandle* mono_debug_handle_from_class (MonoClass *klass);
66
67 void           mono_debug_add_method (MonoFlowGraph *cfg);
68
69 void           mono_debug_add_type (MonoClass *klass);
70
71 gchar *        mono_debug_source_location_from_address (MonoMethod *method, guint32 address,
72                                                         guint32 *line_number);
73
74 gint32         mono_debug_il_offset_from_address (MonoMethod *method, gint32 address);
75
76 gint32         mono_debug_address_from_il_offset (MonoMethod *method, gint32 il_offset);
77
78 /* DEBUGGER PUBLIC FUNCTION:
79  *
80  * This is a public function which is supposed to be called from within a debugger
81  * each time the program stops. It's used to recreate the symbol file to tell the
82  * debugger about method addresses and such things. After calling this function,
83  * you must tell your debugger to reload its symbol file.
84  */
85 void           mono_debug_make_symbols (void);
86
87 void           mono_debug_write_symbols (MonoDebugHandle* debug);
88
89 #endif /* __MONO_JIT_DEBUG_H__ */