Merge tag 'block-5.9-2020-08-14' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / perf / trace / beauty / clone.c
blobf4db894e0af6d14bb0ead601ae7424d097be019a
1 // SPDX-License-Identifier: LGPL-2.1
2 /*
3 * trace/beauty/cone.c
5 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
6 */
8 #include "trace/beauty/beauty.h"
9 #include <linux/kernel.h>
10 #include <sys/types.h>
11 #include <uapi/linux/sched.h>
13 static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
15 const char *prefix = "CLONE_";
16 int printed = 0;
18 #define P_FLAG(n) \
19 if (flags & CLONE_##n) { \
20 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
21 flags &= ~CLONE_##n; \
24 P_FLAG(VM);
25 P_FLAG(FS);
26 P_FLAG(FILES);
27 P_FLAG(SIGHAND);
28 P_FLAG(PIDFD);
29 P_FLAG(PTRACE);
30 P_FLAG(VFORK);
31 P_FLAG(PARENT);
32 P_FLAG(THREAD);
33 P_FLAG(NEWNS);
34 P_FLAG(SYSVSEM);
35 P_FLAG(SETTLS);
36 P_FLAG(PARENT_SETTID);
37 P_FLAG(CHILD_CLEARTID);
38 P_FLAG(DETACHED);
39 P_FLAG(UNTRACED);
40 P_FLAG(CHILD_SETTID);
41 P_FLAG(NEWCGROUP);
42 P_FLAG(NEWUTS);
43 P_FLAG(NEWIPC);
44 P_FLAG(NEWUSER);
45 P_FLAG(NEWPID);
46 P_FLAG(NEWNET);
47 P_FLAG(IO);
48 P_FLAG(CLEAR_SIGHAND);
49 P_FLAG(INTO_CGROUP);
50 #undef P_FLAG
52 if (flags)
53 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
55 return printed;
58 size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg)
60 unsigned long flags = arg->val;
61 enum syscall_clone_args {
62 SCC_FLAGS = (1 << 0),
63 SCC_CHILD_STACK = (1 << 1),
64 SCC_PARENT_TIDPTR = (1 << 2),
65 SCC_CHILD_TIDPTR = (1 << 3),
66 SCC_TLS = (1 << 4),
68 if (!(flags & CLONE_PARENT_SETTID))
69 arg->mask |= SCC_PARENT_TIDPTR;
71 if (!(flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)))
72 arg->mask |= SCC_CHILD_TIDPTR;
74 if (!(flags & CLONE_SETTLS))
75 arg->mask |= SCC_TLS;
77 return clone__scnprintf_flags(flags, bf, size, arg->show_string_prefix);