-
Notifications
You must be signed in to change notification settings - Fork 0
/
finstrument_sh_lib.c
42 lines (38 loc) · 1.05 KB
/
finstrument_sh_lib.c
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
#include "finstrument_sh_lib.h"
#define _GNU_SOURCE
#include <dlfcn.h>
//#undef _GNU_SOURCE
#include<stdio.h>
#include<stdbool.h>
#include"finstrument_sh_lib.h"
int spaces=0;
static void __attribute__((no_instrument_function))
_print_pretty(bool is_enter, int spaces, const char *fn)
{
for (int iter=0; iter<spaces; ++iter) {
printf(" ");
}
printf("[%s] %s\n", is_enter ? "+" : "-", fn);
}
static void __attribute__((no_instrument_function))
__cyg_profile_func_enter (void *this_fn,
void *call_site)
{
Dl_info info;
dladdr(__builtin_return_address(0), &info);
//printf("[+] %s\n", info.dli_sname);
_print_pretty(true, spaces++, info.dli_sname);
}
static void __attribute__((no_instrument_function))
__cyg_profile_func_exit (void *this_fn,
void *call_site)
{
Dl_info info;
dladdr(__builtin_return_address(0), &info);
//printf("[-] %s\n", info.dli_sname);
_print_pretty(false, --spaces, info.dli_sname);
}
int add2values(int a, int b)
{
return (a+b);
}