All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Martin Reboredo <yakoyoku@gmail.com>
Cc: arnaldo.melo@gmail.com, dwarves@vger.kernel.org, ast@kernel.org,
	andrii@kernel.org, daniel@iogearbox.net
Subject: Re: [PATCH] pahole: Implement cu_exclude_lang flag
Date: Tue, 3 May 2022 11:58:42 -0300	[thread overview]
Message-ID: <YnFDItzfx2JD7Gw7@kernel.org> (raw)
In-Reply-To: <20220421144715.8154-1-yakoyoku@gmail.com>

Em Thu, Apr 21, 2022 at 11:47:15AM -0300, Martin Reboredo escreveu:
> Exclude compilation units that have the language id equal to the one
> from the --cu_exclude_lang=LANG flag.
> 
> Required by Rust Linux builds due to failing BTF checks product of
> things like rustc's struct reordering.

Sorry, when I saw this patch I already had committed a similar one, can
you please take a look?

Its in the "next" branch at:

https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=next

- Arnaldo
 
> Signed-off-by: Martin Reboredo <yakoyoku@gmail.com>
> Tested-by: Martin Reboredo <yakoyoku@gmail.com>
> ---
>  dwarves.h | 18 ++++++++++++++++++
>  pahole.c  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/dwarves.h b/dwarves.h
> index 456b037..9d57a4f 100644
> --- a/dwarves.h
> +++ b/dwarves.h
> @@ -204,6 +204,24 @@ enum dwarf_languages {
>      LANG_ObjC_plus_plus	= 0x11,	/* Objective-C++ */
>      LANG_UPC		= 0x12,	/* Unified Parallel C */
>      LANG_D		= 0x13,	/* D */
> +    LANG_Python	= 0x14,	/* Python */
> +    LANG_OpenCL	= 0x15,	/* OpenCL */
> +    LANG_Go	= 0x16,	/* Go */
> +    LANG_Modula3	= 0x17,	/* Modula-3 */
> +    LANG_Haskell	= 0x18,	/* Haskell */
> +    LANG_C_plus_plus_03	= 0x19, /* ISO C++:2003 */
> +    LANG_C_plus_plus_11	= 0x1a, /* ISO C++:2011 */
> +    LANG_OCaml	= 0x1b,	/* OCaml */
> +    LANG_Rust	= 0x1c,	/* Rust */
> +    LANG_C11	= 0x1d,	/* ISO C:2011 */
> +    LANG_Swift	= 0x1e,	/* Swift */
> +    LANG_Julia	= 0x1f,	/* Julia */
> +    LANG_Dylan	= 0x20,	/* Dylan */
> +    LANG_C_plus_plus_14	= 0x21, /* ISO C++:2014 */
> +    LANG_Fortran03	= 0x22,	/* ISO/IEC 1539-1:2004 */
> +    LANG_Fortran08	= 0x23,	/* ISO/IEC 1539-1:2010 */
> +    LANG_RenderScript	= 0x24, /* RenderScript Kernal Language */
> +    LANG_BLISS	= 0x25,	/* BLISS */
>  };
>  
>  /** struct debug_fmt_ops - specific to the underlying debug file format
> diff --git a/pahole.c b/pahole.c
> index a909b22..1c961fb 100644
> --- a/pahole.c
> +++ b/pahole.c
> @@ -57,6 +57,8 @@ static size_t class__include_prefix_len;
>  static char *cu__exclude_prefix;
>  static size_t cu__exclude_prefix_len;
>  
> +static uint32_t cu__exclude_lang;
> +
>  static char *decl_exclude_prefix;
>  static size_t decl_exclude_prefix_len;
>  
> @@ -615,6 +617,10 @@ static struct cu *cu__filter(struct cu *cu)
>  		     cu__exclude_prefix_len) == 0))
>  		return NULL;
>  
> +  if (cu__exclude_lang != 0 &&
> +	    cu__exclude_lang == cu->language)
> +		return NULL;
> +
>  	return cu;
>  }
>  
> @@ -988,6 +994,39 @@ static void cu__account_nr_methods(struct cu *cu)
>  	}
>  }
>  
> +static const struct {
> +  const char *name;
> +  uint32_t id;
> +} language_table[] = {
> +	{ "C", LANG_C },
> +	{ "C89", LANG_C89 },
> +	{ "C99", LANG_C99 },
> +	{ "C11", LANG_C11 },
> +	{ "C++", LANG_C_plus_plus },
> +	{ "C++03", LANG_C_plus_plus_03 },
> +	{ "C++11", LANG_C_plus_plus_11 },
> +	{ "C++14", LANG_C_plus_plus_14 },
> +	{ "Fortran77", LANG_Fortran77 },
> +	{ "Fortran90", LANG_Fortran90 },
> +	{ "Fortran95", LANG_Fortran95 },
> +	{ "Fortran03", LANG_Fortran03 },
> +	{ "Fortran08", LANG_Fortran08 },
> +	{ "Go", LANG_Go },
> +	{ "Haskell", LANG_Haskell },
> +	{ "Rust", LANG_Rust },
> +	{ NULL, 0 },
> +};
> +
> +static uint32_t language_id(const char *lang) {
> +	for (int l = 0; language_table[l].name; l++) {
> +		if (strcmp(lang, language_table[l].name) == 0) {
> +			return language_table[l].id;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static char tab[128];
>  
>  static void print_structs_with_pointer_to(struct cu *cu, uint32_t type)
> @@ -1137,6 +1176,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
>  #define ARGP_skip_missing          332
>  #define ARGP_skip_encoding_btf_type_tag 333
>  #define ARGP_compile		   334
> +#define ARGP_exclude_lang	   335
>  
>  static const struct argp_option pahole__options[] = {
>  	{
> @@ -1512,6 +1552,12 @@ static const struct argp_option pahole__options[] = {
>  		.key  = ARGP_devel_stats,
>  		.doc  = "Print internal data structures stats",
>  	},
> +	{
> +		.name = "cu_exclude_lang",
> +		.key  = ARGP_exclude_lang,
> +		.arg  = "LANG",
> +		.doc  = "exclude LANGuage compilation units",
> +	},
>  	{
>  		.name = "skip_encoding_btf_decl_tag",
>  		.key  = ARGP_skip_encoding_btf_decl_tag,
> @@ -1681,6 +1727,8 @@ static error_t pahole__options_parser(int key, char *arg,
>  		conf_load.hashtable_bits = atoi(arg);	break;
>  	case ARGP_devel_stats:
>  		conf_load.ptr_table_stats = true;	break;
> +	case ARGP_exclude_lang:
> +		cu__exclude_lang = language_id(arg);	break;
>  	case ARGP_skip_encoding_btf_decl_tag:
>  		conf_load.skip_encoding_btf_decl_tag = true;	break;
>  	case ARGP_skip_missing:
> -- 
> 2.36.0

-- 

- Arnaldo

  reply	other threads:[~2022-05-03 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 14:47 [PATCH] pahole: Implement cu_exclude_lang flag Martin Reboredo
2022-05-03 14:58 ` Arnaldo Carvalho de Melo [this message]
2022-05-04 19:42   ` Martin Reboredo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YnFDItzfx2JD7Gw7@kernel.org \
    --to=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dwarves@vger.kernel.org \
    --cc=yakoyoku@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.