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) \ 35 do { \ 36 char *__str__ = __get_str(dst); \ 37 int __len__ = __get_dynamic_array_len(dst) - 1; \ 38 memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ 39 EVENT_NULL_STR, __len__); \ 40 __str__[__len__] = '\0'; \ 41 } while (0) 42 43 #undef __assign_vstr 44 #define __assign_vstr(dst, fmt, va) \ 45 do { \ 46 va_list __cp_va; \ 47 va_copy(__cp_va, *(va)); \ 48 vsnprintf(__get_str(dst), TRACE_EVENT_STR_MAX, fmt, __cp_va); \ 49 va_end(__cp_va); \ 50 } while (0) 51 52 #undef __bitmask 53 #define __bitmask(item, nr_bits) __dynamic_array(unsigned long, item, -1) 54 55 #undef __get_bitmask 56 #define __get_bitmask(field) (char *)__get_dynamic_array(field) 57 58 #undef __assign_bitmask 59 #define __assign_bitmask(dst, src, nr_bits) \ 60 memcpy(__get_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) 61 62 #undef __cpumask 63 #define __cpumask(item) __dynamic_array(unsigned long, item, -1) 64 65 #undef __get_cpumask 66 #define __get_cpumask(field) (char *)__get_dynamic_array(field) 67 68 #undef __assign_cpumask 69 #define __assign_cpumask(dst, src) \ 70 memcpy(__get_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) 71 72 #undef __sockaddr 73 #define __sockaddr(field, len) __dynamic_array(u8, field, len) 74 75 #undef __get_sockaddr 76 #define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field)) 77 78 #undef __assign_sockaddr 79 #define __assign_sockaddr(dest, src, len) \ 80 memcpy(__get_dynamic_array(dest), src, len) 81 82 #undef __rel_dynamic_array 83 #define __rel_dynamic_array(type, item, len) \ 84 __entry->__rel_loc_##item = __data_offsets.item; 85 86 #undef __rel_string 87 #define __rel_string(item, src) __rel_dynamic_array(char, item, -1) 88 89 #undef __rel_string_len 90 #define __rel_string_len(item, src, len) __rel_dynamic_array(char, item, -1) 91 92 #undef __assign_rel_str 93 #define __assign_rel_str(dst) \ 94 do { \ 95 char *__str__ = __get_rel_str(dst); \ 96 int __len__ = __get_rel_dynamic_array_len(dst) - 1; \ 97 memcpy(__str__, __data_offsets.dst##_ptr_ ? : \ 98 EVENT_NULL_STR, __len__); \ 99 __str__[__len__] = '\0'; \ 100 } while (0) 101 102 #undef __rel_bitmask 103 #define __rel_bitmask(item, nr_bits) __rel_dynamic_array(unsigned long, item, -1) 104 105 #undef __get_rel_bitmask 106 #define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field) 107 108 #undef __assign_rel_bitmask 109 #define __assign_rel_bitmask(dst, src, nr_bits) \ 110 memcpy(__get_rel_bitmask(dst), (src), __bitmask_size_in_bytes(nr_bits)) 111 112 #undef __rel_cpumask 113 #define __rel_cpumask(item) __rel_dynamic_array(unsigned long, item, -1) 114 115 #undef __get_rel_cpumask 116 #define __get_rel_cpumask(field) (char *)__get_rel_dynamic_array(field) 117 118 #undef __assign_rel_cpumask 119 #define __assign_rel_cpumask(dst, src) \ 120 memcpy(__get_rel_cpumask(dst), (src), __bitmask_size_in_bytes(nr_cpumask_bits)) 121 122 #undef __rel_sockaddr 123 #define __rel_sockaddr(field, len) __rel_dynamic_array(u8, field, len) 124 125 #undef __get_rel_sockaddr 126 #define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field)) 127 128 #undef __assign_rel_sockaddr 129 #define __assign_rel_sockaddr(dest, src, len) \ 130 memcpy(__get_rel_dynamic_array(dest), src, len) 131 132 #undef TP_fast_assign 133 #define TP_fast_assign(args...) args 134 135 #undef __perf_count 136 #define __perf_count(c) (c) 137 138 #undef __perf_task 139 #define __perf_task(t) (t) 140