1 #include <uapi/linux/mman.h> 2 3 static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, 4 struct syscall_arg *arg) 5 { 6 int printed = 0, prot = arg->val; 7 8 if (prot == PROT_NONE) 9 return scnprintf(bf, size, "NONE"); 10 #define P_MMAP_PROT(n) \ 11 if (prot & PROT_##n) { \ 12 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 13 prot &= ~PROT_##n; \ 14 } 15 16 P_MMAP_PROT(EXEC); 17 P_MMAP_PROT(READ); 18 P_MMAP_PROT(WRITE); 19 P_MMAP_PROT(SEM); 20 P_MMAP_PROT(GROWSDOWN); 21 P_MMAP_PROT(GROWSUP); 22 #undef P_MMAP_PROT 23 24 if (prot) 25 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", prot); 26 27 return printed; 28 } 29 30 #define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot 31 32 static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, 33 struct syscall_arg *arg) 34 { 35 int printed = 0, flags = arg->val; 36 37 if (flags & MAP_ANONYMOUS) 38 arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */ 39 40 #define P_MMAP_FLAG(n) \ 41 if (flags & MAP_##n) { \ 42 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 43 flags &= ~MAP_##n; \ 44 } 45 46 P_MMAP_FLAG(SHARED); 47 P_MMAP_FLAG(PRIVATE); 48 #ifdef MAP_32BIT 49 P_MMAP_FLAG(32BIT); 50 #endif 51 P_MMAP_FLAG(ANONYMOUS); 52 P_MMAP_FLAG(DENYWRITE); 53 P_MMAP_FLAG(EXECUTABLE); 54 P_MMAP_FLAG(FILE); 55 P_MMAP_FLAG(FIXED); 56 P_MMAP_FLAG(GROWSDOWN); 57 P_MMAP_FLAG(HUGETLB); 58 P_MMAP_FLAG(LOCKED); 59 P_MMAP_FLAG(NONBLOCK); 60 P_MMAP_FLAG(NORESERVE); 61 P_MMAP_FLAG(POPULATE); 62 P_MMAP_FLAG(STACK); 63 P_MMAP_FLAG(UNINITIALIZED); 64 #undef P_MMAP_FLAG 65 66 if (flags) 67 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 68 69 return printed; 70 } 71 72 #define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags 73 74 static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, 75 struct syscall_arg *arg) 76 { 77 int printed = 0, flags = arg->val; 78 79 #define P_MREMAP_FLAG(n) \ 80 if (flags & MREMAP_##n) { \ 81 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 82 flags &= ~MREMAP_##n; \ 83 } 84 85 P_MREMAP_FLAG(MAYMOVE); 86 P_MREMAP_FLAG(FIXED); 87 #undef P_MREMAP_FLAG 88 89 if (flags) 90 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 91 92 return printed; 93 } 94 95 #define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags 96 97 static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, 98 struct syscall_arg *arg) 99 { 100 int behavior = arg->val; 101 102 switch (behavior) { 103 #define P_MADV_BHV(n) case MADV_##n: return scnprintf(bf, size, #n) 104 P_MADV_BHV(NORMAL); 105 P_MADV_BHV(RANDOM); 106 P_MADV_BHV(SEQUENTIAL); 107 P_MADV_BHV(WILLNEED); 108 P_MADV_BHV(DONTNEED); 109 P_MADV_BHV(FREE); 110 P_MADV_BHV(REMOVE); 111 P_MADV_BHV(DONTFORK); 112 P_MADV_BHV(DOFORK); 113 P_MADV_BHV(HWPOISON); 114 P_MADV_BHV(SOFT_OFFLINE); 115 P_MADV_BHV(MERGEABLE); 116 P_MADV_BHV(UNMERGEABLE); 117 P_MADV_BHV(HUGEPAGE); 118 P_MADV_BHV(NOHUGEPAGE); 119 P_MADV_BHV(DONTDUMP); 120 P_MADV_BHV(DODUMP); 121 #undef P_MADV_BHV 122 default: break; 123 } 124 125 return scnprintf(bf, size, "%#x", behavior); 126 } 127 128 #define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior 129