• Arnaldo Carvalho de Melo's avatar
    perf trace beauty: Add script to autogenerate socket families table · 58277f50
    Arnaldo Carvalho de Melo authored
    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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    58277f50
socket.sh 924 Bytes