18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * trace/beauty/kcmp.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "trace/beauty/beauty.h" 98c2ecf20Sopenharmony_ci#include <linux/kernel.h> 108c2ecf20Sopenharmony_ci#include <sys/types.h> 118c2ecf20Sopenharmony_ci#include <machine.h> 128c2ecf20Sopenharmony_ci#include <uapi/linux/kcmp.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include "trace/beauty/generated/kcmp_type_array.c" 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_cisize_t syscall_arg__scnprintf_kcmp_idx(char *bf, size_t size, struct syscall_arg *arg) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci unsigned long fd = arg->val; 198c2ecf20Sopenharmony_ci int type = syscall_arg__val(arg, 2); 208c2ecf20Sopenharmony_ci pid_t pid; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci if (type != KCMP_FILE) 238c2ecf20Sopenharmony_ci return syscall_arg__scnprintf_long(bf, size, arg); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci pid = syscall_arg__val(arg, arg->idx == 3 ? 0 : 1); /* idx1 -> pid1, idx2 -> pid2 */ 268c2ecf20Sopenharmony_ci return pid__scnprintf_fd(arg->trace, pid, fd, bf, size); 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic size_t kcmp__scnprintf_type(int type, char *bf, size_t size, bool show_prefix) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci static DEFINE_STRARRAY(kcmp_types, "KCMP_"); 328c2ecf20Sopenharmony_ci return strarray__scnprintf(&strarray__kcmp_types, bf, size, "%d", show_prefix, type); 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cisize_t syscall_arg__scnprintf_kcmp_type(char *bf, size_t size, struct syscall_arg *arg) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci unsigned long type = arg->val; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci if (type != KCMP_FILE) 408c2ecf20Sopenharmony_ci arg->mask |= (1 << 3) | (1 << 4); /* Ignore idx1 and idx2 */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci return kcmp__scnprintf_type(type, bf, size, arg->show_string_prefix); 438c2ecf20Sopenharmony_ci} 44