diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Mono/MonoHeapShotWriter.h |
Diffstat (limited to 'Runtime/Mono/MonoHeapShotWriter.h')
-rw-r--r-- | Runtime/Mono/MonoHeapShotWriter.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Runtime/Mono/MonoHeapShotWriter.h b/Runtime/Mono/MonoHeapShotWriter.h new file mode 100644 index 0000000..0e86996 --- /dev/null +++ b/Runtime/Mono/MonoHeapShotWriter.h @@ -0,0 +1,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 + |