18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 28c2ecf20Sopenharmony_ci#include <linux/log2.h> 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include "trace/beauty/generated/mmap_prot_array.c" 58c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY(mmap_prot, "PROT_"); 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cistatic size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bool show_prefix) 88c2ecf20Sopenharmony_ci{ 98c2ecf20Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot); 108c2ecf20Sopenharmony_ci} 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) 138c2ecf20Sopenharmony_ci{ 148c2ecf20Sopenharmony_ci unsigned long prot = arg->val; 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci if (prot == 0) 178c2ecf20Sopenharmony_ci return scnprintf(bf, size, "%sNONE", arg->show_string_prefix ? strarray__mmap_prot.prefix : ""); 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix); 208c2ecf20Sopenharmony_ci} 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include "trace/beauty/generated/mmap_flags_array.c" 258c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY(mmap_flags, "MAP_"); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, 338c2ecf20Sopenharmony_ci struct syscall_arg *arg) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci unsigned long flags = arg->val; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci if (flags & MAP_ANONYMOUS) 388c2ecf20Sopenharmony_ci arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); 418c2ecf20Sopenharmony_ci} 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#include "trace/beauty/generated/mremap_flags_array.c" 468c2ecf20Sopenharmony_cistatic DEFINE_STRARRAY(mremap_flags, "MREMAP_"); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags); 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci unsigned long flags = arg->val; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci if (!(flags & MREMAP_FIXED)) 588c2ecf20Sopenharmony_ci arg->mask |= (1 << 5); /* Mask 5th ('new_address') args, ignored */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci#include "trace/beauty/generated/madvise_behavior_array.c" 688c2ecf20Sopenharmony_ci static DEFINE_STRARRAY(madvise_advices, "MADV_"); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL) 718c2ecf20Sopenharmony_ci return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]); 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci return scnprintf(bf, size, "%#", behavior); 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, 778c2ecf20Sopenharmony_ci struct syscall_arg *arg) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci return madvise__scnprintf_behavior(arg->val, bf, size); 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior 83