perf trace beauty: Add script to autogenerate socket families table
authorArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Aug 2020 11:30:06 +0000 (08:30 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 12 Aug 2020 11:38:36 +0000 (08:38 -0300)
commit58277f502f429baee11725ca2d8cb3c43c7a6429
tree629a2564ef0dec8c08f7f2b43d3548bbfa77566e
parentfb893de323e2d39f7a1f6df425703a2edbdf56ea
perf trace beauty: Add script to autogenerate socket families table

To use with 'perf trace', to convert the protocol families to strings,
e.g:

  $ tools/perf/trace/beauty/socket.sh
  static const char *socket_families[] = {
   [0] = "UNSPEC",
   [1] = "LOCAL",
   [2] = "INET",
   [3] = "AX25",
   [4] = "IPX",
   [5] = "APPLETALK",
   [6] = "NETROM",
   [7] = "BRIDGE",
   [8] = "ATMPVC",
   [9] = "X25",
   [10] = "INET6",
   [11] = "ROSE",
   [12] = "DECnet",
   [13] = "NETBEUI",
   [14] = "SECURITY",
   [15] = "KEY",
   [16] = "NETLINK",
   [17] = "PACKET",
   [18] = "ASH",
   [19] = "ECONET",
   [20] = "ATMSVC",
   [21] = "RDS",
   [22] = "SNA",
   [23] = "IRDA",
   [24] = "PPPOX",
   [25] = "WANPIPE",
   [26] = "LLC",
   [27] = "IB",
   [28] = "MPLS",
   [29] = "CAN",
   [30] = "TIPC",
   [31] = "BLUETOOTH",
   [32] = "IUCV",
   [33] = "RXRPC",
   [34] = "ISDN",
   [35] = "PHONET",
   [36] = "IEEE802154",
   [37] = "CAIF",
   [38] = "ALG",
   [39] = "NFC",
   [40] = "VSOCK",
   [41] = "KCM",
   [42] = "QIPCRTR",
   [43] = "SMC",
   [44] = "XDP",
  };
  $

This uses a copy of include/linux/socket.h that is kept in a directory
to be used just for these table generation scripts and for checking if
the kernel has a new file that maybe gets something new for these
tables.

This allows us to:

- Avoid accessing files outside tools/, in the kernel sources, that may
  be changed in unexpected ways and thus break these scripts.

- Notice when those files change and thus check if the changes don't
  break those scripts, update them to automatically get the new
  definitions, a new socket family, for instance.

- Not add then to the tools/include/ where it may end up used while
  building the tools and end up requiring dragging yet more stuff from
  the kernel or plain break the build in some of the myriad environments
  where perf may be built.

This will replace the previous static array in tools/perf/ that was
dated and was already missing the AF_KCM, AF_QIPCRTR, AF_SMC and AF_XDP
families.

The next cset will wire this up to the perf build process.

At some point this must be made into a library to be used in places such
as libtraceevent, bpftrace, etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/trace/beauty/include/linux/socket.h [new file with mode: 0644]
tools/perf/trace/beauty/socket.sh [new file with mode: 0755]