StackTrace.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #if IL2CPP_ENABLE_NATIVE_STACKTRACES
  10. struct MethodDefinitionKey
  11. {
  12. Il2CppMethodPointer method;
  13. MethodIndex methodIndex;
  14. };
  15. #endif
  16. namespace il2cpp
  17. {
  18. namespace vm
  19. {
  20. typedef std::vector<Il2CppStackFrameInfo> StackFrames;
  21. class LIBIL2CPP_CODEGEN_API StackTrace
  22. {
  23. public:
  24. static void InitializeStackTracesForCurrentThread();
  25. static void CleanupStackTracesForCurrentThread();
  26. #if IL2CPP_TINY_DEBUGGER
  27. static std::string GetStackTrace();
  28. #endif
  29. // Current thread functions
  30. static const StackFrames* GetStackFrames();
  31. static const StackFrames* GetCachedStackFrames(int32_t depth);
  32. static bool GetStackFrameAt(int32_t depth, Il2CppStackFrameInfo& frame);
  33. static void WalkFrameStack(Il2CppFrameWalkFunc callback, void* context);
  34. inline static size_t GetStackDepth() { return GetStackFrames()->size(); }
  35. inline static bool GetTopStackFrame(Il2CppStackFrameInfo& frame) { return GetStackFrameAt(0, frame); }
  36. static void PushFrame(Il2CppStackFrameInfo& frame);
  37. static void PopFrame();
  38. static const void* GetStackPointer();
  39. // Remote thread functions
  40. static bool GetThreadStackFrameAt(Il2CppThread* thread, int32_t depth, Il2CppStackFrameInfo& frame);
  41. static void WalkThreadFrameStack(Il2CppThread* thread, Il2CppFrameWalkFunc callback, void* context);
  42. static int32_t GetThreadStackDepth(Il2CppThread* thread);
  43. static bool GetThreadTopStackFrame(Il2CppThread* thread, Il2CppStackFrameInfo& frame);
  44. };
  45. }
  46. }