StackTrace.h 971 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #include <string>
  4. #include <vector>
  5. namespace il2cpp
  6. {
  7. namespace os
  8. {
  9. typedef bool(*WalkStackCallback)(Il2CppMethodPointer frame, void* context);
  10. class StackTrace
  11. {
  12. public:
  13. enum WalkOrder
  14. {
  15. kFirstCalledToLastCalled,
  16. kLastCalledToFirstCalled
  17. };
  18. // Walks the stack calling callback for each frame in the stack
  19. // Stops when callback returns false
  20. static void WalkStack(WalkStackCallback callback, void* context, WalkOrder walkOrder);
  21. #if IL2CPP_ENABLE_NATIVE_STACKTRACES
  22. static std::string NativeStackTrace();
  23. #endif
  24. // Returns SP value or nullptr if not implemented
  25. static const void* GetStackPointer();
  26. static void OverrideStackBacktrace(Il2CppBacktraceFunc stackBacktraceFunc);
  27. private:
  28. static void WalkStackNative(WalkStackCallback callback, void* context, WalkOrder walkOrder);
  29. };
  30. }
  31. }