This source file includes following definitions.
- syscall_arg__scnprintf_mmap_prot
- mmap__scnprintf_flags
- syscall_arg__scnprintf_mmap_flags
- syscall_arg__scnprintf_mremap_flags
- madvise__scnprintf_behavior
- syscall_arg__scnprintf_madvise_behavior
1
2 #include <uapi/linux/mman.h>
3 #include <linux/log2.h>
4
5 static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
6 struct syscall_arg *arg)
7 {
8 const char *prot_prefix = "PROT_";
9 int printed = 0, prot = arg->val;
10 bool show_prefix = arg->show_string_prefix;
11
12 if (prot == PROT_NONE)
13 return scnprintf(bf, size, "%sNONE", show_prefix ? prot_prefix : "");
14 #define P_MMAP_PROT(n) \
15 if (prot & PROT_##n) { \
16 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prot_prefix :"", #n); \
17 prot &= ~PROT_##n; \
18 }
19
20 P_MMAP_PROT(READ);
21 P_MMAP_PROT(WRITE);
22 P_MMAP_PROT(EXEC);
23 P_MMAP_PROT(SEM);
24 P_MMAP_PROT(GROWSDOWN);
25 P_MMAP_PROT(GROWSUP);
26 #undef P_MMAP_PROT
27
28 if (prot)
29 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", prot);
30
31 return printed;
32 }
33
34 #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot
35
36 static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
37 {
38 #include "trace/beauty/generated/mmap_flags_array.c"
39 static DEFINE_STRARRAY(mmap_flags, "MAP_");
40
41 return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags);
42 }
43
44 static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
45 struct syscall_arg *arg)
46 {
47 unsigned long flags = arg->val;
48
49 if (flags & MAP_ANONYMOUS)
50 arg->mask |= (1 << 4) | (1 << 5);
51
52 return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
53 }
54
55 #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags
56
57 static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size,
58 struct syscall_arg *arg)
59 {
60 const char *flags_prefix = "MREMAP_";
61 bool show_prefix = arg->show_string_prefix;
62 int printed = 0, flags = arg->val;
63
64 #define P_MREMAP_FLAG(n) \
65 if (flags & MREMAP_##n) { \
66 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? flags_prefix : "", #n); \
67 flags &= ~MREMAP_##n; \
68 }
69
70 P_MREMAP_FLAG(MAYMOVE);
71 P_MREMAP_FLAG(FIXED);
72 #undef P_MREMAP_FLAG
73
74 if (flags)
75 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
76
77 return printed;
78 }
79
80 #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags
81
82 static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size)
83 {
84 #include "trace/beauty/generated/madvise_behavior_array.c"
85 static DEFINE_STRARRAY(madvise_advices, "MADV_");
86
87 if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL)
88 return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]);
89
90 return scnprintf(bf, size, "%#", behavior);
91 }
92
93 static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,
94 struct syscall_arg *arg)
95 {
96 return madvise__scnprintf_behavior(arg->val, bf, size);
97 }
98
99 #define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior