.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0 |
---|
2 | | -#include <uapi/linux/mman.h> |
---|
| 1 | +// SPDX-License-Identifier: LGPL-2.1 |
---|
| 2 | +#include <linux/log2.h> |
---|
3 | 3 | |
---|
4 | | -static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, |
---|
5 | | - struct syscall_arg *arg) |
---|
| 4 | +#include "trace/beauty/generated/mmap_prot_array.c" |
---|
| 5 | +static DEFINE_STRARRAY(mmap_prot, "PROT_"); |
---|
| 6 | + |
---|
| 7 | +static size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bool show_prefix) |
---|
6 | 8 | { |
---|
7 | | - int printed = 0, prot = arg->val; |
---|
| 9 | + return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot); |
---|
| 10 | +} |
---|
8 | 11 | |
---|
9 | | - if (prot == PROT_NONE) |
---|
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); \ |
---|
14 | | - prot &= ~PROT_##n; \ |
---|
15 | | - } |
---|
| 12 | +static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) |
---|
| 13 | +{ |
---|
| 14 | + unsigned long prot = arg->val; |
---|
16 | 15 | |
---|
17 | | - P_MMAP_PROT(EXEC); |
---|
18 | | - P_MMAP_PROT(READ); |
---|
19 | | - P_MMAP_PROT(WRITE); |
---|
20 | | - P_MMAP_PROT(SEM); |
---|
21 | | - P_MMAP_PROT(GROWSDOWN); |
---|
22 | | - P_MMAP_PROT(GROWSUP); |
---|
23 | | -#undef P_MMAP_PROT |
---|
| 16 | + if (prot == 0) |
---|
| 17 | + return scnprintf(bf, size, "%sNONE", arg->show_string_prefix ? strarray__mmap_prot.prefix : ""); |
---|
24 | 18 | |
---|
25 | | - if (prot) |
---|
26 | | - printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", prot); |
---|
27 | | - |
---|
28 | | - return printed; |
---|
| 19 | + return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix); |
---|
29 | 20 | } |
---|
30 | 21 | |
---|
31 | 22 | #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot |
---|
32 | 23 | |
---|
| 24 | +#include "trace/beauty/generated/mmap_flags_array.c" |
---|
| 25 | +static DEFINE_STRARRAY(mmap_flags, "MAP_"); |
---|
| 26 | + |
---|
| 27 | +static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) |
---|
| 28 | +{ |
---|
| 29 | + return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags); |
---|
| 30 | +} |
---|
| 31 | + |
---|
33 | 32 | static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, |
---|
34 | 33 | struct syscall_arg *arg) |
---|
35 | 34 | { |
---|
36 | | - int printed = 0, flags = arg->val; |
---|
| 35 | + unsigned long flags = arg->val; |
---|
37 | 36 | |
---|
38 | 37 | if (flags & MAP_ANONYMOUS) |
---|
39 | 38 | arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */ |
---|
40 | 39 | |
---|
41 | | -#define P_MMAP_FLAG(n) \ |
---|
42 | | - if (flags & MAP_##n) { \ |
---|
43 | | - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ |
---|
44 | | - flags &= ~MAP_##n; \ |
---|
45 | | - } |
---|
46 | | - |
---|
47 | | - P_MMAP_FLAG(SHARED); |
---|
48 | | - P_MMAP_FLAG(PRIVATE); |
---|
49 | | -#ifdef MAP_32BIT |
---|
50 | | - P_MMAP_FLAG(32BIT); |
---|
51 | | -#endif |
---|
52 | | - P_MMAP_FLAG(ANONYMOUS); |
---|
53 | | - P_MMAP_FLAG(DENYWRITE); |
---|
54 | | - P_MMAP_FLAG(EXECUTABLE); |
---|
55 | | - P_MMAP_FLAG(FILE); |
---|
56 | | - P_MMAP_FLAG(FIXED); |
---|
57 | | -#ifdef MAP_FIXED_NOREPLACE |
---|
58 | | - P_MMAP_FLAG(FIXED_NOREPLACE); |
---|
59 | | -#endif |
---|
60 | | - P_MMAP_FLAG(GROWSDOWN); |
---|
61 | | - P_MMAP_FLAG(HUGETLB); |
---|
62 | | - P_MMAP_FLAG(LOCKED); |
---|
63 | | - P_MMAP_FLAG(NONBLOCK); |
---|
64 | | - P_MMAP_FLAG(NORESERVE); |
---|
65 | | - P_MMAP_FLAG(POPULATE); |
---|
66 | | - P_MMAP_FLAG(STACK); |
---|
67 | | - P_MMAP_FLAG(UNINITIALIZED); |
---|
68 | | -#ifdef MAP_SYNC |
---|
69 | | - P_MMAP_FLAG(SYNC); |
---|
70 | | -#endif |
---|
71 | | -#undef P_MMAP_FLAG |
---|
72 | | - |
---|
73 | | - if (flags) |
---|
74 | | - printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); |
---|
75 | | - |
---|
76 | | - return printed; |
---|
| 40 | + return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); |
---|
77 | 41 | } |
---|
78 | 42 | |
---|
79 | 43 | #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags |
---|
80 | 44 | |
---|
81 | | -static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, |
---|
82 | | - struct syscall_arg *arg) |
---|
| 45 | +#include "trace/beauty/generated/mremap_flags_array.c" |
---|
| 46 | +static DEFINE_STRARRAY(mremap_flags, "MREMAP_"); |
---|
| 47 | + |
---|
| 48 | +static size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) |
---|
83 | 49 | { |
---|
84 | | - int printed = 0, flags = arg->val; |
---|
| 50 | + return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags); |
---|
| 51 | +} |
---|
85 | 52 | |
---|
86 | | -#define P_MREMAP_FLAG(n) \ |
---|
87 | | - if (flags & MREMAP_##n) { \ |
---|
88 | | - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ |
---|
89 | | - flags &= ~MREMAP_##n; \ |
---|
90 | | - } |
---|
| 53 | +static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) |
---|
| 54 | +{ |
---|
| 55 | + unsigned long flags = arg->val; |
---|
91 | 56 | |
---|
92 | | - P_MREMAP_FLAG(MAYMOVE); |
---|
93 | | - P_MREMAP_FLAG(FIXED); |
---|
94 | | -#undef P_MREMAP_FLAG |
---|
| 57 | + if (!(flags & MREMAP_FIXED)) |
---|
| 58 | + arg->mask |= (1 << 5); /* Mask 5th ('new_address') args, ignored */ |
---|
95 | 59 | |
---|
96 | | - if (flags) |
---|
97 | | - printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); |
---|
98 | | - |
---|
99 | | - return printed; |
---|
| 60 | + return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); |
---|
100 | 61 | } |
---|
101 | 62 | |
---|
102 | 63 | #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags |
---|
.. | .. |
---|
104 | 65 | static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) |
---|
105 | 66 | { |
---|
106 | 67 | #include "trace/beauty/generated/madvise_behavior_array.c" |
---|
107 | | - static DEFINE_STRARRAY(madvise_advices); |
---|
| 68 | + static DEFINE_STRARRAY(madvise_advices, "MADV_"); |
---|
108 | 69 | |
---|
109 | 70 | if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL) |
---|
110 | 71 | return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]); |
---|