-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathframe_size.cpp
47 lines (38 loc) · 1 KB
/
frame_size.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
39
40
41
42
43
44
45
46
47
#define DEBUG_LEVEL 1
#include <co_async/std.hpp>
#include <co_async/co_async.hpp>
using namespace co_async;
using namespace std::literals;
extern "C" void *__libc_malloc(size_t size);
static void *my_malloc_hook(size_t n, void *caller) {
void *p = __libc_malloc(n);
printf("malloc(%zd) = %p\n", n, p);
return p;
}
static int malloc_hook_active = 1;
extern "C" void *malloc(size_t size) {
if (malloc_hook_active) {
malloc_hook_active = 0;
void *caller = __builtin_return_address(0);
void *ret = my_malloc_hook(size, caller);
malloc_hook_active = 1;
return ret;
}
return __libc_malloc(size);
}
[[gnu::noinline]] static int temp(int volatile const &x) {
return 0;
}
[[gnu::noinline]] static int resu() {
return 8;
}
static Task<> test() {
/* [[maybe_unused]] int volatile i = 55; */
/* [[maybe_unused]] int volatile j = 66; */
temp(static_cast<int const &>(resu()));
co_return;
}
int main() {
co_main(test());
return 0;
}