Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / tools / perf / trace / beauty / clone.c
blobd64d049ab9915162e220f91c3f59997d8abddc15
1 /*
2 * trace/beauty/cone.c
4 * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
6 * Released under the GPL v2. (and only v2, not any later version)
7 */
9 #include "trace/beauty/beauty.h"
10 #include <linux/kernel.h>
11 #include <sys/types.h>
12 #include <uapi/linux/sched.h>
14 static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size)
16 int printed = 0;
18 #define P_FLAG(n) \
19 if (flags & CLONE_##n) { \
20 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
21 flags &= ~CLONE_##n; \
24 P_FLAG(VM);
25 P_FLAG(FS);
26 P_FLAG(FILES);
27 P_FLAG(SIGHAND);
28 P_FLAG(PTRACE);
29 P_FLAG(VFORK);
30 P_FLAG(PARENT);
31 P_FLAG(THREAD);
32 P_FLAG(NEWNS);
33 P_FLAG(SYSVSEM);
34 P_FLAG(SETTLS);
35 P_FLAG(PARENT_SETTID);
36 P_FLAG(CHILD_CLEARTID);
37 P_FLAG(DETACHED);
38 P_FLAG(UNTRACED);
39 P_FLAG(CHILD_SETTID);
40 P_FLAG(NEWCGROUP);
41 P_FLAG(NEWUTS);
42 P_FLAG(NEWIPC);
43 P_FLAG(NEWUSER);
44 P_FLAG(NEWPID);
45 P_FLAG(NEWNET);
46 P_FLAG(IO);
47 #undef P_FLAG
49 if (flags)
50 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
52 return printed;
55 size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg)
57 unsigned long flags = arg->val;
58 enum syscall_clone_args {
59 SCC_FLAGS = (1 << 0),
60 SCC_CHILD_STACK = (1 << 1),
61 SCC_PARENT_TIDPTR = (1 << 2),
62 SCC_CHILD_TIDPTR = (1 << 3),
63 SCC_TLS = (1 << 4),
65 if (!(flags & CLONE_PARENT_SETTID))
66 arg->mask |= SCC_PARENT_TIDPTR;
68 if (!(flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)))
69 arg->mask |= SCC_CHILD_TIDPTR;
71 if (!(flags & CLONE_SETTLS))
72 arg->mask |= SCC_TLS;
74 return clone__scnprintf_flags(flags, bf, size);