162306a36Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 262306a36Sopenharmony_ci#include <linux/log2.h> 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#include "trace/beauty/generated/mmap_prot_array.c" 562306a36Sopenharmony_cistatic DEFINE_STRARRAY(mmap_prot, "PROT_"); 662306a36Sopenharmony_ci 762306a36Sopenharmony_cistatic size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bool show_prefix) 862306a36Sopenharmony_ci{ 962306a36Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot); 1062306a36Sopenharmony_ci} 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_cistatic size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) 1362306a36Sopenharmony_ci{ 1462306a36Sopenharmony_ci unsigned long prot = arg->val; 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci if (prot == 0) 1762306a36Sopenharmony_ci return scnprintf(bf, size, "%sNONE", arg->show_string_prefix ? strarray__mmap_prot.prefix : ""); 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix); 2062306a36Sopenharmony_ci} 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci#include "trace/beauty/generated/mmap_flags_array.c" 2562306a36Sopenharmony_cistatic DEFINE_STRARRAY(mmap_flags, "MAP_"); 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_cistatic size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) 2862306a36Sopenharmony_ci{ 2962306a36Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags); 3062306a36Sopenharmony_ci} 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistatic size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, 3362306a36Sopenharmony_ci struct syscall_arg *arg) 3462306a36Sopenharmony_ci{ 3562306a36Sopenharmony_ci unsigned long flags = arg->val; 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci if (flags & MAP_ANONYMOUS) 3862306a36Sopenharmony_ci arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */ 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); 4162306a36Sopenharmony_ci} 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#include "trace/beauty/generated/mremap_flags_array.c" 4662306a36Sopenharmony_cistatic DEFINE_STRARRAY(mremap_flags, "MREMAP_"); 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags); 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistatic size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) 5462306a36Sopenharmony_ci{ 5562306a36Sopenharmony_ci unsigned long flags = arg->val; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci if (!(flags & MREMAP_FIXED)) 5862306a36Sopenharmony_ci arg->mask |= (1 << 5); /* Mask 5th ('new_address') args, ignored */ 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); 6162306a36Sopenharmony_ci} 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_cistatic size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci#include "trace/beauty/generated/madvise_behavior_array.c" 6862306a36Sopenharmony_ci static DEFINE_STRARRAY(madvise_advices, "MADV_"); 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL) 7162306a36Sopenharmony_ci return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]); 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci return scnprintf(bf, size, "%#", behavior); 7462306a36Sopenharmony_ci} 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistatic size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, 7762306a36Sopenharmony_ci struct syscall_arg *arg) 7862306a36Sopenharmony_ci{ 7962306a36Sopenharmony_ci return madvise__scnprintf_behavior(arg->val, bf, size); 8062306a36Sopenharmony_ci} 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior 83