MemoryInformation.h
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#pragma once
#include "il2cpp-config.h"
struct Il2CppMetadataField
{
uint32_t offset;
uint32_t typeIndex;
const char* name;
bool isStatic;
};
enum Il2CppMetadataTypeFlags
{
kNone = 0,
kValueType = 1 << 0,
kArray = 1 << 1,
kArrayRankMask = 0xFFFF0000
};
struct Il2CppMetadataType
{
Il2CppMetadataTypeFlags flags; // If it's an array, rank is encoded in the upper 2 bytes
Il2CppMetadataField* fields;
uint32_t fieldCount;
uint32_t staticsSize;
uint8_t* statics;
uint32_t baseOrElementTypeIndex;
char* name;
const char* assemblyName;
uint64_t typeInfoAddress;
uint32_t size;
};
struct Il2CppMetadataSnapshot
{
uint32_t typeCount;
Il2CppMetadataType* types;
};
struct Il2CppManagedMemorySection
{
uint64_t sectionStartAddress;
uint32_t sectionSize;
uint8_t* sectionBytes;
};
struct Il2CppManagedHeap
{
uint32_t sectionCount;
Il2CppManagedMemorySection* sections;
};
struct Il2CppStacks
{
uint32_t stackCount;
Il2CppManagedMemorySection* stacks;
};
struct NativeObject
{
uint32_t gcHandleIndex;
uint32_t size;
uint32_t instanceId;
uint32_t classId;
uint32_t referencedNativeObjectIndicesCount;
uint32_t* referencedNativeObjectIndices;
};
struct Il2CppGCHandles
{
uint32_t trackedObjectCount;
uint64_t* pointersToObjects;
};
struct Il2CppRuntimeInformation
{
uint32_t pointerSize;
uint32_t objectHeaderSize;
uint32_t arrayHeaderSize;
uint32_t arrayBoundsOffsetInHeader;
uint32_t arraySizeOffsetInHeader;
uint32_t allocationGranularity;
};
struct Il2CppManagedMemorySnapshot
{
Il2CppManagedHeap heap;
Il2CppStacks stacks;
Il2CppMetadataSnapshot metadata;
Il2CppGCHandles gcHandles;
Il2CppRuntimeInformation runtimeInformation;
void* additionalUserInformation;
};
namespace il2cpp
{
namespace vm
{
namespace MemoryInformation
{
typedef void(*ClassReportFunc)(Il2CppClass* klass, void* context);
typedef void(*DataReportFunc)(void* data, void* context);
struct IterationContext
{
DataReportFunc callback;
void* userData;
};
void ReportIL2CppClasses(ClassReportFunc callback, void* context);
void ReportGcHeapSection(void* context, void* start, void* end);
void ReportGcHandleTarget(Il2CppObject* obj, void* context);
Il2CppManagedMemorySnapshot* CaptureManagedMemorySnapshot();
void FreeCapturedManagedMemorySnapshot(Il2CppManagedMemorySnapshot* snapshot);
}
}
}