-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-cxx.cpp
38 lines (33 loc) · 888 Bytes
/
test-cxx.cpp
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
35
36
37
38
// (c) Michael Hept 2022. See LICENSE.txt
#include "slowstacktrace.h"
#include <cstdio>
template <int A> int recursiveCall(int maxDepth, int depth = 0) {
if (depth >= maxDepth) {
print_thread_stacktrace("%m %o");
print_thread_stacktrace(" #%n %p %F %L");
return maxDepth;
}
depth++;
switch (depth % 4) {
case 0:
return recursiveCall<0>(maxDepth, depth);
case 1:
return recursiveCall<1>(maxDepth, depth);
case 2:
return recursiveCall<2>(maxDepth, depth);
case 3:
return recursiveCall<3>(maxDepth, depth);
}
while (1);
}
int main() {
std::puts("test begin\n");
print_thread_stacktrace("%b %n %p %m %o %f %q %s");
print_thread_stacktrace("%l %c %F %S %l %M");
char buf[1024 * 8]{};
get_thread_stacktrace(buf, sizeof(buf), " #%n %p %F %L");
std::puts(buf);
recursiveCall<0>(32);
std::puts("test end\n");
return 0;
}