il2cpp-api-debugger.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. // This header defines an extension to the IL2CPP embedding API that the debugger code requires.
  4. // It should not include any Mono headers.
  5. #include "il2cpp-api.h"
  6. // These macros were used to build the debugger agent for the now unused Mono runtime backend.
  7. // We don't have tha backend any more, but we will keep these macros to avoid code churn.
  8. #define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain)
  9. #define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value)
  10. #define VM_DOMAIN_GET_FRIENDLY_NAME(domain) il2cpp_domain_get_friendly_name(domain)
  11. #define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method)
  12. #define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod)
  13. #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod)
  14. #define VM_OBJECT_GET_DOMAIN(object) mono_domain_get()
  15. #define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) il2cpp_generic_class_get_container_class(gklass)
  16. #define VM_DEFAULTS_OBJECT_CLASS il2cpp_defaults_object_class()
  17. #define VM_DEFAULTS_EXCEPTION_CLASS il2cpp_defaults_exception_class()
  18. #define VM_DEFAULTS_CORLIB_IMAGE il2cpp_defaults_corlib_image()
  19. #define VM_DEFAULTS_VOID_CLASS il2cpp_defaults_void_class()
  20. #define VM_DEFAULTS_RUNTIMETYPE_CLASS il2cpp_defaults_runtimetype_class()
  21. #define VM_GENERIC_INST_TYPE_ARGC(inst) il2cpp_generic_inst_get_argc(inst)
  22. #define VM_GENERIC_INST_TYPE_ARGV(inst, index) il2cpp_generic_inst_get_argv(inst, index)
  23. #define VM_IMAGE_GET_MODULE_NAME(image) il2cpp_image_get_name(image)
  24. #define VM_ASSEMBLY_IS_DYNAMIC(assembly) 0
  25. #define VM_CLASS_IS_INTERFACE(c) ((il2cpp_class_get_flags (c) & TYPE_ATTRIBUTE_INTERFACE) || mono_type_is_generic_parameter (il2cpp_class_get_byval_arg (c)))
  26. // These types are used in debugger-agent.c for field access
  27. // (not via an API), so we need to map them to the IL2CPP types
  28. // so that the field layout is correct.
  29. #define MonoArray Il2CppArraySize
  30. #define MonoAssembly Il2CppAssembly
  31. #define MonoGenericContainer Il2CppGenericContainer
  32. #define MonoInternalThread Il2CppInternalThread
  33. #define MonoMethod MethodInfo
  34. #define MonoObject Il2CppObject
  35. #define MonoThread Il2CppThread
  36. #define MonoType Il2CppType
  37. typedef struct Il2CppInternalThread Il2CppInternalThread;
  38. // These defines map objects that the debugger-agent.c code uses directly to there
  39. // IL2CPP counterparts.
  40. #define debug_options il2cpp_mono_debug_options
  41. #define mono_defaults il2cpp_defaults
  42. // These are some defines from Mono that the debugger-agent.c code uses.
  43. #define MONO_MAX_IREGS 1
  44. #define NOT_IMPLEMENTED do { g_assert_not_reached (); } while (0)
  45. #if IL2CPP_COMPILER_MSVC
  46. typedef int32_t (*MonoSuspendThreadCallback) (MonoThreadInfo *info, void* user_data);
  47. #else
  48. #if defined(__cplusplus)
  49. enum SuspendThreadResult : int32_t;
  50. #endif
  51. typedef SuspendThreadResult (*MonoSuspendThreadCallback) (MonoThreadInfo *info, void* user_data);
  52. #endif
  53. // This much match the layout of Mono's CattrNamedArg
  54. typedef struct
  55. {
  56. const Il2CppType *type;
  57. const FieldInfo *field;
  58. const PropertyInfo *prop;
  59. } Il2CppCattrNamedArg;
  60. typedef struct
  61. {
  62. const MonoMethod* ctor;
  63. Il2CppArray* typedArgs;
  64. Il2CppArray* namedArgs;
  65. Il2CppCattrNamedArg* argInfo;
  66. } Il2CppCustomAttributeData;
  67. typedef struct
  68. {
  69. int32_t numberOfAttributes;
  70. Il2CppCustomAttributeData attributeData[];
  71. } Il2CppCustomAttributeDataList;
  72. #if defined(__cplusplus)
  73. extern "C" {
  74. #endif
  75. // These functions expose the IL2CPP C++ API to C for the debugger using Mono's types.
  76. void il2cpp_start_debugger_thread();
  77. Il2CppSequencePoint* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter);
  78. MonoClass* il2cpp_defaults_object_class();
  79. uint8_t* il2cpp_field_get_address(MonoObject *obj, MonoClassField *monoField);
  80. MonoClass* il2cpp_defaults_exception_class();
  81. MonoImage* il2cpp_defaults_corlib_image();
  82. bool il2cpp_method_is_string_ctor(const MonoMethod * method);
  83. MonoClass* il2cpp_defaults_void_class();
  84. MonoClass* il2cpp_defaults_runtimetype_class();
  85. MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot);
  86. int32_t il2cpp_field_is_deleted(MonoClassField *field);
  87. MonoClass* il2cpp_iterate_loaded_classes(void* *iter);
  88. const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count);
  89. MonoMethod* il2cpp_method_get_generic_definition(MonoMethodInflated *imethod);
  90. MonoGenericInst* il2cpp_method_get_generic_class_inst(MonoMethodInflated *imethod);
  91. MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass);
  92. Il2CppSequencePoint* il2cpp_get_sequence_point(MonoImage* image, int id);
  93. char* il2cpp_assembly_get_full_name(MonoAssembly *assembly);
  94. const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint);
  95. const MonoClass* il2cpp_get_class_from_index(int index);
  96. const MonoType* il2cpp_get_type_from_method_context(MonoType* type, const MonoMethod* method);
  97. const MonoType* il2cpp_type_inflate(MonoType* type, const MonoGenericContext* context);
  98. void il2cpp_debugger_get_method_execution_context_and_header_info(const MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes);
  99. Il2CppThreadUnwindState* il2cpp_debugger_get_thread_context();
  100. const MonoAssembly* il2cpp_m_method_get_assembly(MonoMethod* method);
  101. Il2CppSequencePointSourceFile* il2cpp_debug_get_source_file(MonoImage* image, int index);
  102. Il2CppCatchPoint* il2cpp_get_method_catch_points(MonoMethod* method, void* *iter);
  103. Il2CppSequencePoint* il2cpp_get_seq_point_from_catch_point(Il2CppCatchPoint *cp);
  104. MonoMethod* il2cpp_get_generic_method_definition(MonoMethod* method);
  105. bool il2cpp_class_is_initialized(MonoClass* klass);
  106. void* il2cpp_domain_get_agent_info(MonoAppDomain* domain);
  107. void il2cpp_domain_set_agent_info(MonoAppDomain* domain, void* agentInfo);
  108. const char* il2cpp_domain_get_friendly_name(MonoAppDomain* domain);
  109. int il2cpp_generic_inst_get_argc(MonoGenericInst * inst);
  110. MonoType* il2cpp_generic_inst_get_argv(MonoGenericInst * inst, int index);
  111. MonoObject* il2cpp_assembly_get_object(MonoDomain * domain, MonoAssembly * assembly, MonoError * error);
  112. const MonoType* il2cpp_get_type_from_index(int index);
  113. void il2cpp_thread_info_safe_suspend_and_run(size_t id, int32_t interrupt_kernel, MonoSuspendThreadCallback callback, void* user_data);
  114. MonoGenericParam* il2cpp_generic_container_get_param(MonoGenericContainer * gc, int i);
  115. int32_t il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right);
  116. void il2cpp_field_static_get_value_checked(MonoVTable * vt, MonoClassField * field, void* value, MonoError * error);
  117. void il2cpp_field_static_get_value_for_thread(MonoInternalThread * thread, MonoVTable * vt, MonoClassField * field, void* value, MonoError * error);
  118. const Il2CppCustomAttributeDataList* il2cpp_get_custom_attribute_data_list(MonoClass* attr_klass, MonoCustomAttrInfo* cinfo, MonoImage* image);
  119. void il2cpp_free_custom_attribute_data_list(Il2CppCustomAttributeDataList* data);
  120. int32_t il2cpp_field_get_fixed_array_size(MonoClassField* field);
  121. MonoType* il2cpp_class_get_byval_arg(MonoClass* klass);
  122. #if defined(__cplusplus)
  123. }
  124. #endif