StackTrace.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. #include "il2cpp-config.h"
  5. #include "il2cpp-metadata.h"
  6. #if IL2CPP_ENABLE_NATIVE_STACKTRACES
  7. struct MethodDefinitionKey
  8. {
  9. Il2CppMethodPointer method;
  10. MethodIndex methodIndex;
  11. };
  12. #endif
  13. namespace il2cpp
  14. {
  15. namespace vm
  16. {
  17. typedef std::vector<Il2CppStackFrameInfo> StackFrames;
  18. class LIBIL2CPP_CODEGEN_API StackTrace
  19. {
  20. public:
  21. static void InitializeStackTracesForCurrentThread();
  22. static void CleanupStackTracesForCurrentThread();
  23. // Current thread functions
  24. static const StackFrames* GetStackFrames();
  25. static bool GetStackFrameAt(int32_t depth, Il2CppStackFrameInfo& frame);
  26. static void WalkFrameStack(Il2CppFrameWalkFunc callback, void* context);
  27. inline static size_t GetStackDepth() { return GetStackFrames()->size(); }
  28. inline static bool GetTopStackFrame(Il2CppStackFrameInfo& frame) { return GetStackFrameAt(0, frame); }
  29. static void PushFrame(Il2CppStackFrameInfo& frame);
  30. static void PopFrame();
  31. // Remote thread functions
  32. static bool GetThreadStackFrameAt(Il2CppThread* thread, int32_t depth, Il2CppStackFrameInfo& frame);
  33. static void WalkThreadFrameStack(Il2CppThread* thread, Il2CppFrameWalkFunc callback, void* context);
  34. static int32_t GetThreadStackDepth(Il2CppThread* thread);
  35. static bool GetThreadTopStackFrame(Il2CppThread* thread, Il2CppStackFrameInfo& frame);
  36. };
  37. }
  38. }