1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 /* Stage 6 definitions for creating trace events */ 4 5 /* Reuse some of the stage 3 macros */ 6 #include "stage3_trace_output.h" 7 8 #undef __entry 9 #define __entry entry 10 11 #undef __field 12 #define __field(type, item) 13 14 #undef __field_struct 15 #define __field_struct(type, item) 16 17 #undef __array 18 #define __array(type, item, len) 19 20 #undef __dynamic_array 21 #define __dynamic_array(type, item, len) \ 22 __entry->__data_loc_##item = __data_offsets.item; 23 24 #undef __string 25 #define __string(item, src) __dynamic_array(char, item, -1) 26 27 #undef __string_len 28 #define __string_len(item, src, len) __dynamic_array(char, item, -1) 29 30 #undef __vstring 31 #define __vstring(item, fmt, ap) __dynamic_array(char, item, -1) 32 33 #undef __assign_str 34 #define __assign_str(dst, src) \ 35 strcpy(__get_str(dst), (src) ? (const char *)(src) : "(null)"); 36 37 #undef __assign_str_len 38 #define __assign_str_len(dst, src, len) \ 39 do { \ 40 memcpy(__get_str(dst), (src), (len)); \ 41 __get_str(dst)[len] = '\0'; \ 42 } while(0) 43 44 #undef __assign_vstr 45 #define __assign_vstr(dst, fmt, va) \ 46 do { \ 47 va_list __cp_va; \ 48 va_copy(__cp_va, *(va)); \ 49 vsnprintf(__get_str(dst), TRACE_EVENT_STR_MAX, fmt, __cp_va); \ 50 va_end(__cp_va); \ 51 } while (0) 52 53 #undef __bitmask 54 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) 55 56 #undef __get_bitmask 57 #define __get_bitmask(field) (char *)__get_dynamic_array(field) 58 59 #undef __assign_bitmask 60 #define __assign_bitmask(dst, src, nr_bits) \ 61 memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) 62 63 #undef __cpumask 64 #define __cpumask(item) __dynamic_array(unsigned long, item, -1) 65 66 #undef __get_cpumask 67 #define __get_cpumask(field) (char *)__get_dynamic_array(field) 68 69 #undef __assign_cpumask 70 #define __assign_cpumask(dst, src) \ 71 memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) 72 73 #undef __sockaddr 74 #define __sockaddr(field, len) __dynamic_array(u8, field, len) 75 76 #undef __get_sockaddr 77 #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) 78 79 #undef __assign_sockaddr 80 #define __assign_sockaddr(dest, src, len) \ 81 memcpy(__get_dynamic_array(dest), src, len) 82 83 #undef __rel_dynamic_array 84 #define __rel_dynamic_array(type, item, len) \ 85 __entry->__rel_loc_##item = __data_offsets.item; 86 87 #undef __rel_string 88 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) 89 90 #undef __rel_string_len 91 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) 92 93 #undef __assign_rel_str 94 #define __assign_rel_str(dst, src) \ 95 strcpy(__get_rel_str(dst), (src) ? (const char *)(src) : "(null)"); 96 97 #undef __assign_rel_str_len 98 #define __assign_rel_str_len(dst, src, len) \ 99 do { \ 100 memcpy(__get_rel_str(dst), (src), (len)); \ 101 __get_rel_str(dst)[len] = '\0'; \ 102 } while (0) 103 104 #undef __rel_bitmask 105 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) 106 107 #undef __get_rel_bitmask 108 #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) 109 110 #undef __assign_rel_bitmask 111 #define __assign_rel_bitmask(dst, src, nr_bits) \ 112 memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) 113 114 #undef __rel_cpumask 115 #define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) 116 117 #undef __get_rel_cpumask 118 #define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) 119 120 #undef __assign_rel_cpumask 121 #define __assign_rel_cpumask(dst, src) \ 122 memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) 123 124 #undef __rel_sockaddr 125 #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) 126 127 #undef __get_rel_sockaddr 128 #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) 129 130 #undef __assign_rel_sockaddr 131 #define __assign_rel_sockaddr(dest, src, len) \ 132 memcpy(__get_rel_dynamic_array(dest), src, len) 133 134 #undef TP_fast_assign 135 #define TP_fast_assign(args...) args 136 137 #undef __perf_count 138 #define __perf_count(c) (c) 139 140 #undef __perf_task 141 #define __perf_task(t) (t) 142