summaryrefslogtreecommitdiff
path: root/Runtime/Mono/MonoHeapShotWriter.h
blob: 0e869966dff0f7ad59c5c46760bb088159ce02bf (plain)
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
#ifndef MONOHEAPSHOTWRITER_H
#define MONOHEAPSHOTWRITER_H

#include "Runtime/Mono/MonoTypes.h"
#include "Runtime/Scripting/ScriptingUtility.h"
#include "MonoHeapShot.h"

#if ENABLE_MONO_HEAPSHOT


class MonoHeapShotWriter
{
public:
	MonoHeapShotWriter();
	~MonoHeapShotWriter();

	void Start(HeapShotData* data);

	void End();

	void DumpObjectsReferencedByUnity();

	void BeginObjectDump(MonoObject* obj, MonoClass* klass);
	
	void EndObjectDump();
	
	void DumpReference(gpointer ref, gpointer field);
	
	inline const UInt8* GetData() const 
	{
		return &(*m_Data)[0];
	}
	inline UInt32 GetDataSize() const
	{
		return m_Data->size();
	}

private:
	void WriteByte (UInt8 x);

	void WritePointer (void* x);

	void WriteInt32 (SInt32 x);

	void WriteUInt32 (UInt32 x);

	void WriteVInt (UInt32 x);

	void WriteString (const char *str);

	typedef std::vector<UInt8> Data;
	HeapShotData* m_Data;
	ClassHash* m_SeenItems;
	int		m_TypeCount;
    int		m_ObjecCount;
    int		m_ReferenceCount;
    int		m_FieldCount;
    long	m_SavedOutfileOffset;
};

#endif

#endif