Go to the documentation of this file. 23 #ifndef FOLLY_SDT_ARG_CONSTRAINT 24 #define FOLLY_SDT_ARG_CONSTRAINT "nor" 28 #define FOLLY_SDT_NOP nop 31 #define FOLLY_SDT_NOTE_NAME "stapsdt" 32 #define FOLLY_SDT_NOTE_TYPE 3 35 #define FOLLY_SDT_SEMAPHORE_SECTION ".probes" 39 #define FOLLY_SDT_ASM_ADDR .8byte 41 #define FOLLY_SDT_ASM_ADDR .4byte 45 #define FOLLY_SDT_S(x) #x 46 #define FOLLY_SDT_ASM_1(x) FOLLY_SDT_S(x) "\n" 47 #define FOLLY_SDT_ASM_2(a, b) FOLLY_SDT_S(a) "," FOLLY_SDT_S(b) "\n" 48 #define FOLLY_SDT_ASM_3(a, b, c) FOLLY_SDT_S(a) "," FOLLY_SDT_S(b) "," \ 50 #define FOLLY_SDT_ASM_STRING(x) FOLLY_SDT_ASM_1(.asciz FOLLY_SDT_S(x)) 53 #define FOLLY_SDT_IS_ARRAY_POINTER(x) ((__builtin_classify_type(x) == 14) || \ 54 (__builtin_classify_type(x) == 5)) 55 #define FOLLY_SDT_ARGSIZE(x) (FOLLY_SDT_IS_ARRAY_POINTER(x) \ 62 #define FOLLY_SDT_ARG(n, x) \ 63 [FOLLY_SDT_S##n] "n" ((size_t)FOLLY_SDT_ARGSIZE(x)), \ 64 [FOLLY_SDT_A##n] FOLLY_SDT_ARG_CONSTRAINT (x) 67 #define FOLLY_SDT_OPERANDS_0() [__sdt_dummy] "g" (0) 68 #define FOLLY_SDT_OPERANDS_1(_1) FOLLY_SDT_ARG(1, _1) 69 #define FOLLY_SDT_OPERANDS_2(_1, _2) \ 70 FOLLY_SDT_OPERANDS_1(_1), FOLLY_SDT_ARG(2, _2) 71 #define FOLLY_SDT_OPERANDS_3(_1, _2, _3) \ 72 FOLLY_SDT_OPERANDS_2(_1, _2), FOLLY_SDT_ARG(3, _3) 73 #define FOLLY_SDT_OPERANDS_4(_1, _2, _3, _4) \ 74 FOLLY_SDT_OPERANDS_3(_1, _2, _3), FOLLY_SDT_ARG(4, _4) 75 #define FOLLY_SDT_OPERANDS_5(_1, _2, _3, _4, _5) \ 76 FOLLY_SDT_OPERANDS_4(_1, _2, _3, _4), FOLLY_SDT_ARG(5, _5) 77 #define FOLLY_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6) \ 78 FOLLY_SDT_OPERANDS_5(_1, _2, _3, _4, _5), FOLLY_SDT_ARG(6, _6) 79 #define FOLLY_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7) \ 80 FOLLY_SDT_OPERANDS_6(_1, _2, _3, _4, _5, _6), FOLLY_SDT_ARG(7, _7) 81 #define FOLLY_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8) \ 82 FOLLY_SDT_OPERANDS_7(_1, _2, _3, _4, _5, _6, _7), FOLLY_SDT_ARG(8, _8) 83 #define FOLLY_SDT_OPERANDS_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) \ 84 FOLLY_SDT_OPERANDS_8(_1, _2, _3, _4, _5, _6, _7, _8), FOLLY_SDT_ARG(9, _9) 87 #define FOLLY_SDT_ARGFMT(no) %n[FOLLY_SDT_S##no]@%[FOLLY_SDT_A##no] 88 #define FOLLY_SDT_ARG_TEMPLATE_0 89 #define FOLLY_SDT_ARG_TEMPLATE_1 FOLLY_SDT_ARGFMT(1) 90 #define FOLLY_SDT_ARG_TEMPLATE_2 FOLLY_SDT_ARG_TEMPLATE_1 FOLLY_SDT_ARGFMT(2) 91 #define FOLLY_SDT_ARG_TEMPLATE_3 FOLLY_SDT_ARG_TEMPLATE_2 FOLLY_SDT_ARGFMT(3) 92 #define FOLLY_SDT_ARG_TEMPLATE_4 FOLLY_SDT_ARG_TEMPLATE_3 FOLLY_SDT_ARGFMT(4) 93 #define FOLLY_SDT_ARG_TEMPLATE_5 FOLLY_SDT_ARG_TEMPLATE_4 FOLLY_SDT_ARGFMT(5) 94 #define FOLLY_SDT_ARG_TEMPLATE_6 FOLLY_SDT_ARG_TEMPLATE_5 FOLLY_SDT_ARGFMT(6) 95 #define FOLLY_SDT_ARG_TEMPLATE_7 FOLLY_SDT_ARG_TEMPLATE_6 FOLLY_SDT_ARGFMT(7) 96 #define FOLLY_SDT_ARG_TEMPLATE_8 FOLLY_SDT_ARG_TEMPLATE_7 FOLLY_SDT_ARGFMT(8) 97 #define FOLLY_SDT_ARG_TEMPLATE_9 FOLLY_SDT_ARG_TEMPLATE_8 FOLLY_SDT_ARGFMT(9) 101 #define FOLLY_SDT_SEMAPHORE(provider, name) \ 102 folly_sdt_semaphore_##provider##_##name 104 #define FOLLY_SDT_DEFINE_SEMAPHORE(provider, name) \ 106 volatile unsigned short FOLLY_SDT_SEMAPHORE(provider, name) \ 107 __attribute__((section(FOLLY_SDT_SEMAPHORE_SECTION), used)) = 0; \ 110 #define FOLLY_SDT_DECLARE_SEMAPHORE(provider, name) \ 111 extern "C" volatile unsigned short FOLLY_SDT_SEMAPHORE(provider, name) 113 #define FOLLY_SDT_SEMAPHORE_NOTE_0(provider, name) \ 114 FOLLY_SDT_ASM_1( FOLLY_SDT_ASM_ADDR 0) \ 116 #define FOLLY_SDT_SEMAPHORE_NOTE_1(provider, name) \ 117 FOLLY_SDT_ASM_1(FOLLY_SDT_ASM_ADDR FOLLY_SDT_SEMAPHORE(provider, name)) 120 #define FOLLY_SDT_NOTE_CONTENT(provider, name, has_semaphore, arg_template) \ 121 FOLLY_SDT_ASM_1(990: FOLLY_SDT_NOP) \ 122 FOLLY_SDT_ASM_3( .pushsection .note.stapsdt,"","note") \ 123 FOLLY_SDT_ASM_1( .balign 4) \ 124 FOLLY_SDT_ASM_3( .4byte 992f-991f, 994f-993f, FOLLY_SDT_NOTE_TYPE) \ 125 FOLLY_SDT_ASM_1(991: .asciz FOLLY_SDT_NOTE_NAME) \ 126 FOLLY_SDT_ASM_1(992: .balign 4) \ 127 FOLLY_SDT_ASM_1(993: FOLLY_SDT_ASM_ADDR 990b) \ 128 FOLLY_SDT_ASM_1( FOLLY_SDT_ASM_ADDR 0) \ 129 FOLLY_SDT_SEMAPHORE_NOTE_##has_semaphore(provider, name) \ 130 FOLLY_SDT_ASM_STRING(provider) \ 131 FOLLY_SDT_ASM_STRING(name) \ 132 FOLLY_SDT_ASM_STRING(arg_template) \ 133 FOLLY_SDT_ASM_1(994: .balign 4) \ 134 FOLLY_SDT_ASM_1( .popsection) 137 #define FOLLY_SDT_PROBE(provider, name, has_semaphore, n, arglist) \ 138 __asm__ __volatile__ ( \ 139 FOLLY_SDT_NOTE_CONTENT( \ 140 provider, name, has_semaphore, FOLLY_SDT_ARG_TEMPLATE_##n) \ 141 :: FOLLY_SDT_OPERANDS_##n arglist \ 145 #define FOLLY_SDT_NARG_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N 146 #define FOLLY_SDT_NARG(...) \ 147 FOLLY_SDT_NARG_(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) 148 #define FOLLY_SDT_PROBE_N(provider, name, has_semaphore, N, ...) \ 149 FOLLY_SDT_PROBE(provider, name, has_semaphore, N, (__VA_ARGS__))