]>
Commit | Line | Data |
---|---|---|
a645023d A |
1 | |
2 | #include <stdio.h> | |
3 | ||
4 | #define DTRACE_STRINGIFY(s) #s | |
5 | #define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s) | |
6 | ||
7 | #define DTRACE_NOPS \ | |
8 | "nop" "\n\t" \ | |
9 | "nop" "\n\t" \ | |
10 | "nop" "\n\t" | |
11 | ||
12 | ||
13 | #define DTRACE_LAB(p, n) \ | |
14 | "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n) | |
15 | ||
e456bf10 A |
16 | #if (defined __x86_64__ || defined __arm64__) |
17 | #define DTRACE_LABEL(p, n) \ | |
18 | ".section __DATA, __data\n\t" \ | |
19 | ".globl " DTRACE_LAB(p, n) "\n\t" \ | |
20 | DTRACE_LAB(p, n) ":" ".quad 1f""\n\t" \ | |
21 | ".text" "\n\t" \ | |
22 | "1:" | |
23 | #else | |
a645023d A |
24 | #define DTRACE_LABEL(p, n) \ |
25 | ".section __DATA, __data\n\t" \ | |
26 | ".globl " DTRACE_LAB(p, n) "\n\t" \ | |
27 | DTRACE_LAB(p, n) ":\n\t" ".long 1f""\n\t" \ | |
28 | ".text" "\n\t" \ | |
29 | "1:" | |
e456bf10 | 30 | #endif |
a645023d A |
31 | |
32 | #define DTRACE_CALL(p,n) \ | |
33 | DTRACE_LABEL(p,n) \ | |
34 | DTRACE_NOPS | |
35 | ||
36 | #define DTRACE_CALL0ARGS(provider, name) \ | |
37 | __asm volatile ( \ | |
38 | DTRACE_CALL(provider, name) \ | |
39 | : \ | |
40 | : \ | |
41 | ); | |
42 | ||
43 | int deadwood() | |
44 | { | |
45 | DTRACE_CALL0ARGS(__foo__, test2) | |
46 | return 0; | |
47 | } | |
48 | ||
49 | ||
50 | int main() { | |
51 | int a = 1; | |
52 | ||
53 | while(a) { | |
54 | DTRACE_CALL0ARGS(__foo__, test1) | |
55 | } | |
56 | ||
57 | return 0; | |
58 | } |