2002-05-21 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/loader.h>
7 #include <mono/jit/jit.h>
8
9 typedef struct _MonoDebugHandle MonoDebugHandle;
10
11 typedef enum {
12         MONO_DEBUG_FORMAT_NONE,
13         MONO_DEBUG_FORMAT_STABS,
14         MONO_DEBUG_FORMAT_DWARF2,
15         MONO_DEBUG_FORMAT_DWARF2_PLUS
16 } MonoDebugFormat;
17
18 extern MonoDebugFormat mono_debug_format;
19 extern GList *mono_debug_methods;
20
21 /*
22  * This variable is intended to be set in a debugger.
23  *
24  * If it's non-zero, arch_compile_method() will insert a breakpoint next time
25  * it compiles a method.
26  *
27  * If it's positive, it acts as a counter which is decremented each time it's
28  * used. Set it to a negative value to make arch_compile_method() insert a
29  * breakpoint for each method.
30  *
31  * To use this, you should create a GDB macro like this:
32  *
33  *    define enter
34  *      set mono_debug_insert_breakpoint = 1
35  *      continue
36  *      set *mono_debug_last_breakpoint_address = 0x90
37  *      reload-symbol-files
38  *      frame
39  *    end
40  *
41  *    define reload-symbol-files
42  *      call mono_debug_make_symbols ()
43  *      add-symbol-file Test-debug.o
44  *      add-symbol-file /tmp/corlib.o
45  *    end
46  *
47  */
48 extern int mono_debug_insert_breakpoint;
49
50 /*
51  * This is set the the core address of the last inserted breakpoint. You can
52  * use this in GDB to unset the breakpoint.
53  */
54
55 extern gchar *mono_debug_last_breakpoint_address;
56
57 MonoDebugHandle* mono_debug_open_file (const char *filename, MonoDebugFormat format);
58
59 void           mono_debug_cleanup (void);
60
61 void           mono_debug_add_image (MonoDebugHandle* debug, MonoImage *image);
62
63 MonoDebugHandle* mono_debug_handle_from_class (MonoClass *klass);
64
65 void           mono_debug_add_method (MonoFlowGraph *cfg);
66
67 void           mono_debug_add_type (MonoClass *klass);
68
69 /* DEBUGGER PUBLIC FUNCTION:
70  *
71  * This is a public function which is supposed to be called from within a debugger
72  * each time the program stops. It's used to recreate the symbol file to tell the
73  * debugger about method addresses and such things. After calling this function,
74  * you must tell your debugger to reload its symbol file.
75  */
76 void           mono_debug_make_symbols (void);
77
78 void           mono_debug_write_symbols (MonoDebugHandle* debug);
79
80 #endif /* __MONO_JIT_DEBUG_H__ */