pahole: Add --skip_missing option

Add a --skip_missing option that allows pahole to keep going in case one
of the type passed to -C (e.g. via a file) does not exist.

This is useful for intropsection software such as debugging kernel
modules that can handle various kernel configurations and versions for
which some recently added types are missing. The consumer of the header
becomes responsible of gating the uses of the type with #ifdef
CONFIG_XXX, rather than pahole bailing out on the first unknown type.

Committer testing:

Before:

  $ pahole tcp_splice_state,xxfrm_policy_queue,list_head tcp.o
  struct tcp_splice_state {
  	struct pipe_inode_info *   pipe;                 /*     0     8 */
  	size_t                     len;                  /*     8     8 */
  	unsigned int               flags;                /*    16     4 */

  	/* size: 24, cachelines: 1, members: 3 */
  	/* padding: 4 */
  	/* last cacheline: 24 bytes */
  };
  pahole: type 'xxfrm_policy_queue' not found
  $

After:

  $ pahole --help |& grep skip
        --skip=COUNT           Skip COUNT input records
        --skip_encoding_btf_tag   Do not encode TAGs in BTF.
        --skip_encoding_btf_vars   Do not encode VARs in BTF.
        --skip_missing         skip missing types passed to -C rather than stop
  $ pahole --skip_missing tcp_splice_state,xxfrm_policy_queue,list_head tcp.o
  struct tcp_splice_state {
  	struct pipe_inode_info *   pipe;                 /*     0     8 */
  	size_t                     len;                  /*     8     8 */
  	unsigned int               flags;                /*    16     4 */

  	/* size: 24, cachelines: 1, members: 3 */
  	/* padding: 4 */
  	/* last cacheline: 24 bytes */
  };
  struct list_head {
  	struct list_head *         next;                 /*     0     8 */
  	struct list_head *         prev;                 /*     8     8 */

  	/* size: 16, cachelines: 1, members: 2 */
  	/* last cacheline: 16 bytes */
  };
  pahole: type 'xxfrm_policy_queue' not found
  $

Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2 files changed