mono-debug.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /**
  2. * \file
  3. * This header is only installed for use by the debugger:
  4. * the structures and the API declared here are not supported.
  5. */
  6. #ifndef __MONO_DEBUG_H__
  7. #define __MONO_DEBUG_H__
  8. #include <mono/utils/mono-publib.h>
  9. #include <mono/metadata/image.h>
  10. #include <mono/metadata/appdomain.h>
  11. MONO_BEGIN_DECLS
  12. typedef struct _MonoSymbolTable MonoSymbolTable;
  13. typedef struct _MonoDebugDataTable MonoDebugDataTable;
  14. typedef struct _MonoSymbolFile MonoSymbolFile;
  15. typedef struct _MonoPPDBFile MonoPPDBFile;
  16. typedef struct _MonoDebugHandle MonoDebugHandle;
  17. typedef struct _MonoDebugLineNumberEntry MonoDebugLineNumberEntry;
  18. typedef struct _MonoDebugVarInfo MonoDebugVarInfo;
  19. typedef struct _MonoDebugMethodJitInfo MonoDebugMethodJitInfo;
  20. typedef struct _MonoDebugMethodAddress MonoDebugMethodAddress;
  21. typedef struct _MonoDebugMethodAddressList MonoDebugMethodAddressList;
  22. typedef struct _MonoDebugClassEntry MonoDebugClassEntry;
  23. typedef struct _MonoDebugMethodInfo MonoDebugMethodInfo;
  24. typedef struct _MonoDebugLocalsInfo MonoDebugLocalsInfo;
  25. typedef struct _MonoDebugMethodAsyncInfo MonoDebugMethodAsyncInfo;
  26. typedef struct _MonoDebugSourceLocation MonoDebugSourceLocation;
  27. typedef struct _MonoDebugList MonoDebugList;
  28. typedef enum {
  29. MONO_DEBUG_FORMAT_NONE,
  30. MONO_DEBUG_FORMAT_MONO,
  31. /* Deprecated, the mdb debugger is not longer supported. */
  32. MONO_DEBUG_FORMAT_DEBUGGER
  33. } MonoDebugFormat;
  34. /*
  35. * NOTE:
  36. * We intentionally do not use GList here since the debugger needs to know about
  37. * the layout of the fields.
  38. */
  39. struct _MonoDebugList {
  40. MonoDebugList *next;
  41. const void* data;
  42. };
  43. struct _MonoSymbolTable {
  44. uint64_t magic;
  45. uint32_t version;
  46. uint32_t total_size;
  47. /*
  48. * Corlib and metadata info.
  49. */
  50. MonoDebugHandle *corlib;
  51. MonoDebugDataTable *global_data_table;
  52. MonoDebugList *data_tables;
  53. /*
  54. * The symbol files.
  55. */
  56. MonoDebugList *symbol_files;
  57. };
  58. struct _MonoDebugHandle {
  59. uint32_t index;
  60. char *image_file;
  61. MonoImage *image;
  62. MonoDebugDataTable *type_table;
  63. MonoSymbolFile *symfile;
  64. MonoPPDBFile *ppdb;
  65. };
  66. struct _MonoDebugMethodJitInfo {
  67. const mono_byte *code_start;
  68. uint32_t code_size;
  69. uint32_t prologue_end;
  70. uint32_t epilogue_begin;
  71. const mono_byte *wrapper_addr;
  72. uint32_t num_line_numbers;
  73. MonoDebugLineNumberEntry *line_numbers;
  74. uint32_t has_var_info;
  75. uint32_t num_params;
  76. MonoDebugVarInfo *this_var;
  77. MonoDebugVarInfo *params;
  78. uint32_t num_locals;
  79. MonoDebugVarInfo *locals;
  80. MonoDebugVarInfo *gsharedvt_info_var;
  81. MonoDebugVarInfo *gsharedvt_locals_var;
  82. };
  83. struct _MonoDebugMethodAddressList {
  84. uint32_t size;
  85. uint32_t count;
  86. mono_byte data [MONO_ZERO_LEN_ARRAY];
  87. };
  88. struct _MonoDebugSourceLocation {
  89. char *source_file;
  90. uint32_t row, column;
  91. uint32_t il_offset;
  92. };
  93. MONO_API mono_bool mono_debug_enabled (void);
  94. /*
  95. * These bits of the MonoDebugLocalInfo's "index" field are flags specifying
  96. * where the variable is actually stored.
  97. *
  98. * See relocate_variable() in debug-symfile.c for more info.
  99. */
  100. #define MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS 0xf0000000
  101. /* The variable is in register "index". */
  102. #define MONO_DEBUG_VAR_ADDRESS_MODE_REGISTER 0
  103. /* The variable is at offset "offset" from register "index". */
  104. #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET 0x10000000
  105. /* The variable is in the two registers "offset" and "index". */
  106. #define MONO_DEBUG_VAR_ADDRESS_MODE_TWO_REGISTERS 0x20000000
  107. /* The variable is dead. */
  108. #define MONO_DEBUG_VAR_ADDRESS_MODE_DEAD 0x30000000
  109. /* Same as REGOFFSET, but do an indirection */
  110. #define MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET_INDIR 0x40000000
  111. /* gsharedvt local */
  112. #define MONO_DEBUG_VAR_ADDRESS_MODE_GSHAREDVT_LOCAL 0x50000000
  113. /* variable is a vt address */
  114. #define MONO_DEBUG_VAR_ADDRESS_MODE_VTADDR 0x60000000
  115. struct _MonoDebugVarInfo {
  116. uint32_t index;
  117. uint32_t offset;
  118. uint32_t size;
  119. uint32_t begin_scope;
  120. uint32_t end_scope;
  121. MonoType *type;
  122. };
  123. #define MONO_DEBUGGER_MAJOR_VERSION 81
  124. #define MONO_DEBUGGER_MINOR_VERSION 6
  125. #define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
  126. MONO_API void mono_debug_init (MonoDebugFormat format);
  127. MONO_API void mono_debug_open_image_from_memory (MonoImage *image, const mono_byte *raw_contents, int size);
  128. MONO_API void mono_debug_cleanup (void);
  129. MONO_API void mono_debug_close_image (MonoImage *image);
  130. MONO_API void mono_debug_domain_unload (MonoDomain *domain);
  131. MONO_API void mono_debug_domain_create (MonoDomain *domain);
  132. MONO_API MonoDebugMethodAddress *
  133. mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDomain *domain);
  134. MONO_API void
  135. mono_debug_remove_method (MonoMethod *method, MonoDomain *domain);
  136. MONO_API MonoDebugMethodInfo *
  137. mono_debug_lookup_method (MonoMethod *method);
  138. MONO_API MonoDebugMethodAddressList *
  139. mono_debug_lookup_method_addresses (MonoMethod *method);
  140. MONO_API MonoDebugMethodJitInfo*
  141. mono_debug_find_method (MonoMethod *method, MonoDomain *domain);
  142. MONO_API MonoDebugHandle *
  143. mono_debug_get_handle (MonoImage *image);
  144. MONO_API void
  145. mono_debug_free_method_jit_info (MonoDebugMethodJitInfo *jit);
  146. MONO_API void
  147. mono_debug_add_delegate_trampoline (void* code, int size);
  148. MONO_API MonoDebugLocalsInfo*
  149. mono_debug_lookup_locals (MonoMethod *method);
  150. MonoDebugMethodAsyncInfo*
  151. mono_debug_lookup_method_async_debug_info (MonoMethod *method);
  152. // The intent here is really MONO_LLVM_INTERNAL but that is not necessarily available.
  153. MONO_API
  154. MonoDebugSourceLocation *
  155. mono_debug_method_lookup_location (MonoDebugMethodInfo *minfo, int il_offset);
  156. /*
  157. * Line number support.
  158. */
  159. MONO_API MonoDebugSourceLocation *
  160. mono_debug_lookup_source_location (MonoMethod *method, uint32_t address, MonoDomain *domain);
  161. MONO_API int32_t
  162. mono_debug_il_offset_from_address (MonoMethod *method, MonoDomain *domain, uint32_t native_offset);
  163. MONO_API void
  164. mono_debug_free_source_location (MonoDebugSourceLocation *location);
  165. MONO_API char *
  166. mono_debug_print_stack_frame (MonoMethod *method, uint32_t native_offset, MonoDomain *domain);
  167. /*
  168. * Mono Debugger support functions
  169. *
  170. * These methods are used by the JIT while running inside the Mono Debugger.
  171. */
  172. MONO_API int mono_debugger_method_has_breakpoint (MonoMethod *method);
  173. MONO_API int mono_debugger_insert_breakpoint (const char *method_name, mono_bool include_namespace);
  174. MONO_API void mono_set_is_debugger_attached (mono_bool attached);
  175. MONO_API mono_bool mono_is_debugger_attached (void);
  176. MONO_END_DECLS
  177. #endif /* __MONO_DEBUG_H__ */