StackTrace.h 1.8 KB

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