1 // SPDX-License-Identifier: GPL-2.0
2 #include <uapi/linux/mman.h>
4 static size_t syscall_arg__scnprintf_mmap_prot(char *bf
, size_t size
,
5 struct syscall_arg
*arg
)
7 int printed
= 0, prot
= arg
->val
;
10 return scnprintf(bf
, size
, "NONE");
11 #define P_MMAP_PROT(n) \
12 if (prot & PROT_##n) { \
13 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
21 P_MMAP_PROT(GROWSDOWN
);
26 printed
+= scnprintf(bf
+ printed
, size
- printed
, "%s%#x", printed
? "|" : "", prot
);
31 #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot
33 static size_t syscall_arg__scnprintf_mmap_flags(char *bf
, size_t size
,
34 struct syscall_arg
*arg
)
36 int printed
= 0, flags
= arg
->val
;
38 if (flags
& MAP_ANONYMOUS
)
39 arg
->mask
|= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */
41 #define P_MMAP_FLAG(n) \
42 if (flags & MAP_##n) { \
43 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
52 P_MMAP_FLAG(ANONYMOUS
);
53 P_MMAP_FLAG(DENYWRITE
);
54 P_MMAP_FLAG(EXECUTABLE
);
57 P_MMAP_FLAG(GROWSDOWN
);
60 P_MMAP_FLAG(NONBLOCK
);
61 P_MMAP_FLAG(NORESERVE
);
62 P_MMAP_FLAG(POPULATE
);
64 P_MMAP_FLAG(UNINITIALIZED
);
71 printed
+= scnprintf(bf
+ printed
, size
- printed
, "%s%#x", printed
? "|" : "", flags
);
76 #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags
78 static size_t syscall_arg__scnprintf_mremap_flags(char *bf
, size_t size
,
79 struct syscall_arg
*arg
)
81 int printed
= 0, flags
= arg
->val
;
83 #define P_MREMAP_FLAG(n) \
84 if (flags & MREMAP_##n) { \
85 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
86 flags &= ~MREMAP_##n; \
89 P_MREMAP_FLAG(MAYMOVE
);
94 printed
+= scnprintf(bf
+ printed
, size
- printed
, "%s%#x", printed
? "|" : "", flags
);
99 #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags
101 static size_t madvise__scnprintf_behavior(int behavior
, char *bf
, size_t size
)
103 #include "trace/beauty/generated/madvise_behavior_array.c"
104 static DEFINE_STRARRAY(madvise_advices
);
106 if (behavior
< strarray__madvise_advices
.nr_entries
&& strarray__madvise_advices
.entries
[behavior
] != NULL
)
107 return scnprintf(bf
, size
, "MADV_%s", strarray__madvise_advices
.entries
[behavior
]);
109 return scnprintf(bf
, size
, "%#", behavior
);
112 static size_t syscall_arg__scnprintf_madvise_behavior(char *bf
, size_t size
,
113 struct syscall_arg
*arg
)
115 return madvise__scnprintf_behavior(arg
->val
, bf
, size
);
118 #define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior