1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _PERF_TRACE_BEAUTY_H 3 #define _PERF_TRACE_BEAUTY_H 4 5 #include <linux/kernel.h> 6 #include <linux/types.h> 7 #include <sys/types.h> 8 9 struct strarray { 10 int offset; 11 int nr_entries; 12 const char **entries; 13 }; 14 15 #define DEFINE_STRARRAY(array) struct strarray strarray__##array = { \ 16 .nr_entries = ARRAY_SIZE(array), \ 17 .entries = array, \ 18 } 19 20 #define DEFINE_STRARRAY_OFFSET(array, off) struct strarray strarray__##array = { \ 21 .offset = off, \ 22 .nr_entries = ARRAY_SIZE(array), \ 23 .entries = array, \ 24 } 25 26 size_t strarray__scnprintf(struct strarray *sa, char *bf, size_t size, const char *intfmt, int val); 27 28 struct trace; 29 struct thread; 30 31 size_t pid__scnprintf_fd(struct trace *trace, pid_t pid, int fd, char *bf, size_t size); 32 33 /** 34 * @val: value of syscall argument being formatted 35 * @args: All the args, use syscall_args__val(arg, nth) to access one 36 * @thread: tid state (maps, pid, tid, etc) 37 * @trace: 'perf trace' internals: all threads, etc 38 * @parm: private area, may be an strarray, for instance 39 * @idx: syscall arg idx (is this the first?) 40 * @mask: a syscall arg may mask another arg, see syscall_arg__scnprintf_futex_op 41 */ 42 43 struct syscall_arg { 44 unsigned long val; 45 unsigned char *args; 46 struct thread *thread; 47 struct trace *trace; 48 void *parm; 49 u8 idx; 50 u8 mask; 51 }; 52 53 unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx); 54 55 size_t syscall_arg__scnprintf_strarrays(char *bf, size_t size, struct syscall_arg *arg); 56 #define SCA_STRARRAYS syscall_arg__scnprintf_strarrays 57 58 size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg); 59 #define SCA_FD syscall_arg__scnprintf_fd 60 61 size_t syscall_arg__scnprintf_hex(char *bf, size_t size, struct syscall_arg *arg); 62 #define SCA_HEX syscall_arg__scnprintf_hex 63 64 size_t syscall_arg__scnprintf_int(char *bf, size_t size, struct syscall_arg *arg); 65 #define SCA_INT syscall_arg__scnprintf_int 66 67 size_t syscall_arg__scnprintf_long(char *bf, size_t size, struct syscall_arg *arg); 68 #define SCA_LONG syscall_arg__scnprintf_long 69 70 size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg); 71 #define SCA_PID syscall_arg__scnprintf_pid 72 73 size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg); 74 #define SCA_CLONE_FLAGS syscall_arg__scnprintf_clone_flags 75 76 size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg); 77 #define SCA_FCNTL_CMD syscall_arg__scnprintf_fcntl_cmd 78 79 size_t syscall_arg__scnprintf_fcntl_arg(char *bf, size_t size, struct syscall_arg *arg); 80 #define SCA_FCNTL_ARG syscall_arg__scnprintf_fcntl_arg 81 82 size_t syscall_arg__scnprintf_flock(char *bf, size_t size, struct syscall_arg *arg); 83 #define SCA_FLOCK syscall_arg__scnprintf_flock 84 85 size_t syscall_arg__scnprintf_ioctl_cmd(char *bf, size_t size, struct syscall_arg *arg); 86 #define SCA_IOCTL_CMD syscall_arg__scnprintf_ioctl_cmd 87 88 size_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_arg *arg); 89 #define SCA_KCMP_TYPE syscall_arg__scnprintf_kcmp_type 90 91 size_t syscall_arg__scnprintf_kcmp_idx(char *bf, size_t size, struct syscall_arg *arg); 92 #define SCA_KCMP_IDX syscall_arg__scnprintf_kcmp_idx 93 94 size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg); 95 #define SCA_PKEY_ALLOC_ACCESS_RIGHTS syscall_arg__scnprintf_pkey_alloc_access_rights 96 97 size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, struct syscall_arg *arg); 98 #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags 99 100 size_t syscall_arg__scnprintf_prctl_option(char *bf, size_t size, struct syscall_arg *arg); 101 #define SCA_PRCTL_OPTION syscall_arg__scnprintf_prctl_option 102 103 size_t syscall_arg__scnprintf_prctl_arg2(char *bf, size_t size, struct syscall_arg *arg); 104 #define SCA_PRCTL_ARG2 syscall_arg__scnprintf_prctl_arg2 105 106 size_t syscall_arg__scnprintf_prctl_arg3(char *bf, size_t size, struct syscall_arg *arg); 107 #define SCA_PRCTL_ARG3 syscall_arg__scnprintf_prctl_arg3 108 109 size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg); 110 #define SCA_SK_PROTO syscall_arg__scnprintf_socket_protocol 111 112 size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg); 113 #define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags 114 115 size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg); 116 #define SCA_STATX_MASK syscall_arg__scnprintf_statx_mask 117 118 size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size); 119 120 void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg, 121 size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg)); 122 123 const char *arch_syscalls__strerrno(const char *arch, int err); 124 125 #endif /* _PERF_TRACE_BEAUTY_H */ 126