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