StackTrace.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. #include "il2cpp-config.h"
  5. #include "il2cpp-metadata.h"
  6. #if IL2CPP_TINY_DEBUGGER
  7. #include <string>
  8. #endif
  9. namespace il2cpp
  10. {
  11. namespace vm
  12. {
  13. typedef std::vector<Il2CppStackFrameInfo> StackFrames;
  14. class LIBIL2CPP_CODEGEN_API StackTrace
  15. {
  16. public:
  17. static void InitializeStackTracesForCurrentThread();
  18. static void CleanupStackTracesForCurrentThread();
  19. #if IL2CPP_TINY_DEBUGGER
  20. static const char* GetStackTrace();
  21. #endif
  22. // Current thread functions
  23. static const StackFrames* GetStackFrames();
  24. static const StackFrames* GetCachedStackFrames(int32_t depth);
  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. static const void* GetStackPointer();
  32. // Remote thread functions
  33. static bool GetThreadStackFrameAt(Il2CppThread* thread, int32_t depth, Il2CppStackFrameInfo& frame);
  34. static void WalkThreadFrameStack(Il2CppThread* thread, Il2CppFrameWalkFunc callback, void* context);
  35. static int32_t GetThreadStackDepth(Il2CppThread* thread);
  36. static bool GetThreadTopStackFrame(Il2CppThread* thread, Il2CppStackFrameInfo& frame);
  37. };
  38. }
  39. }