forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackTrace.cpp
More file actions
34 lines (30 loc) · 961 Bytes
/
StackTrace.cpp
File metadata and controls
34 lines (30 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "il2cpp-config.h"
#include "StackTrace.h"
namespace il2cpp
{
namespace os
{
static Il2CppBacktraceFunc s_StackBacktraceFunc = 0;
void StackTrace::WalkStack(WalkStackCallback callback, void* context, WalkOrder walkOrder)
{
if (s_StackBacktraceFunc == 0)
{
StackTrace::WalkStackNative(callback, context, walkOrder);
return;
}
const int kMaxStackFrames = 128;
Il2CppMethodPointer addrs[kMaxStackFrames];
size_t size = s_StackBacktraceFunc(addrs, kMaxStackFrames);
for (size_t i = 0; i < size; ++i)
{
const size_t index = (walkOrder == os::StackTrace::kFirstCalledToLastCalled) ? (size - i - 1) : i;
if (!callback(addrs[index], context))
break;
}
}
void StackTrace::OverrideStackBacktrace(Il2CppBacktraceFunc stackBacktraceFunc)
{
s_StackBacktraceFunc = stackBacktraceFunc;
}
}
}