linux/tools/perf/trace/beauty
Arnaldo Carvalho de Melo 80ee5668b8 perf beauty: Add a generator for MAP_ mmap's flag constants
It'll use tools/{arch}/*,include copies of mman.h to generate a table to
be used by tools, initially by the 'mmap' beautifiers in 'perf trace',
but that could also be used to translate from a string constant to the
integer value to be used in a eBPF or tracefs tracepoint filter.

Tested for all archs using:

$ for arch in `ls tools/arch/` ; \
	do echo $arch ; tools/perf/trace/beauty/mmap_flags.sh $arch ; \
   done | less

Example for alpha, an oddball, doesn't include any header, defines all
its stuff:

  $ tools/perf/trace/beauty/mmap_flags.sh alpha
  static const char *mmap_flags[] = {
	[ilog2(0x10) + 1] = "ANONYMOUS",
	[ilog2(0x02000) + 1] = "DENYWRITE",
	[ilog2(0x04000) + 1] = "EXECUTABLE",
	[ilog2(0x100) + 1] = "FIXED",
	[ilog2(0x01000) + 1] = "GROWSDOWN",
	[ilog2(0x100000) + 1] = "HUGETLB",
	[ilog2(0x08000) + 1] = "LOCKED",
	[ilog2(0x40000) + 1] = "NONBLOCK",
	[ilog2(0x10000) + 1] = "NORESERVE",
	[ilog2(0x20000) + 1] = "POPULATE",
	[ilog2(0x02) + 1] = "PRIVATE",
	[ilog2(0x01) + 1] = "SHARED",
	[ilog2(0x80000) + 1] = "STACK",
  };
  $

Common case, my workstation, defines one entry (MAP_32BIT), then
includes mman.h, which gets it to include mman-common.h too:

  $ tools/perf/trace/beauty/mmap_flags.sh
  static const char *mmap_flags[] = {
	[ilog2(0x40) + 1] = "32BIT",
	[ilog2(0x01) + 1] = "SHARED",
	[ilog2(0x02) + 1] = "PRIVATE",
	[ilog2(0x10) + 1] = "FIXED",
	[ilog2(0x20) + 1] = "ANONYMOUS",
	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
	[ilog2(0x0100) + 1] = "GROWSDOWN",
	[ilog2(0x0800) + 1] = "DENYWRITE",
	[ilog2(0x1000) + 1] = "EXECUTABLE",
	[ilog2(0x2000) + 1] = "LOCKED",
	[ilog2(0x4000) + 1] = "NORESERVE",
	[ilog2(0x8000) + 1] = "POPULATE",
	[ilog2(0x10000) + 1] = "NONBLOCK",
	[ilog2(0x20000) + 1] = "STACK",
	[ilog2(0x40000) + 1] = "HUGETLB",
	[ilog2(0x80000) + 1] = "SYNC",
  };
  $ uname -m
  x86_64
  $

Sparc, that defines a bunch then includes just mman-common.h:

  $ tools/perf/trace/beauty/mmap_flags.sh sparc
  static const char *mmap_flags[] = {
	[ilog2(0x0800) + 1] = "DENYWRITE",
	[ilog2(0x1000) + 1] = "EXECUTABLE",
	[ilog2(0x0200) + 1] = "GROWSDOWN",
	[ilog2(0x40000) + 1] = "HUGETLB",
	[ilog2(0x100) + 1] = "LOCKED",
	[ilog2(0x10000) + 1] = "NONBLOCK",
	[ilog2(0x40) + 1] = "NORESERVE",
	[ilog2(0x8000) + 1] = "POPULATE",
	[ilog2(0x20000) + 1] = "STACK",
	[ilog2(0x01) + 1] = "SHARED",
	[ilog2(0x02) + 1] = "PRIVATE",
	[ilog2(0x10) + 1] = "FIXED",
	[ilog2(0x20) + 1] = "ANONYMOUS",
	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
  };
  [acme@jouet perf]$

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-xydeh491z8fkgglcmqnl5thj@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-10-31 09:57:52 -03:00
..
arch_errno_names.c perf util: Introduce architecture specific errno/name mapping 2018-01-23 09:51:37 -03:00
arch_errno_names.sh perf util: Introduce architecture specific errno/name mapping 2018-01-23 09:51:37 -03:00
beauty.h perf trace beauty: Beautify mount/umount's 'flags' argument 2018-10-30 11:46:23 -03:00
Build perf trace beauty: Beautify mount/umount's 'flags' argument 2018-10-30 11:46:23 -03:00
clone.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
drm_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
eventfd.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
fcntl.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
flock.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
futex_op.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
futex_val3.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
ioctl.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
kcmp_type.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
kcmp.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
kvm_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
madvise_behavior.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
mmap_flags.sh perf beauty: Add a generator for MAP_ mmap's flag constants 2018-10-31 09:57:52 -03:00
mmap.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
mode_t.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
mount_flags.c perf trace beauty: Beautify mount/umount's 'flags' argument 2018-10-30 11:46:23 -03:00
mount_flags.sh perf beauty: Add a generator for MS_ mount/umount's flag constants 2018-10-30 11:46:23 -03:00
msg_flags.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
open_flags.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
perf_event_open.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
perf_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
pid.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
pkey_alloc_access_rights.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
pkey_alloc.c perf beauty: Introduce strarray__scnprintf_flags() 2018-10-30 11:46:23 -03:00
prctl_option.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
prctl.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
sched_policy.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
seccomp.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
signum.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
sndrv_ctl_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
sndrv_pcm_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
sockaddr.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
socket_ipproto.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
socket_type.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
socket.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
statx.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
vhost_virtio_ioctl.sh perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00
waitid_options.c perf beauty: Switch from GPL v2.0 to LGPL v2.1 2018-10-30 11:46:23 -03:00