Skip to content

Commit 49358df

Browse files
committed
pahole: Add --lang_exclude to allow skipping compilation units written in some languages
For instance, to exclude rust compilation units when encoding BTF from DWARF: $ pahole --btf_encode --lang_exclude rust Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 8ee3637 commit 49358df

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

man-pages/pahole.1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ Supported languages:
381381

382382
The linux kernel, for instance, is written in 'c89' circa 2022, use that in filters.
383383

384+
.B \-\-lang_exclude=languages
385+
Don't process compilation units built from source code written in the specified languages.
386+
387+
To filter out compilation units written in Rust, for instance, use:
388+
389+
pahole -j --btf_encode --lang_exclude rust
390+
384391
.TP
385392
.B \-y, \-\-prefix_filter=PREFIX
386393
Include PREFIXed classes.

pahole.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static struct {
133133
char *str;
134134
int *entries;
135135
int nr_entries;
136+
bool exclude;
136137
} languages;
137138

138139
static int lang_id_cmp(const void *pa, const void *pb)
@@ -683,7 +684,9 @@ static struct cu *cu__filter(struct cu *cu)
683684
{
684685
if (languages.nr_entries) {
685686
bool in = languages__in(cu->language);
686-
if (!in)
687+
688+
if ((!in && !languages.exclude) ||
689+
(in && languages.exclude))
687690
return NULL;
688691
}
689692

@@ -1216,6 +1219,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
12161219
#define ARGP_skip_encoding_btf_type_tag 333
12171220
#define ARGP_compile 334
12181221
#define ARGP_languages 335
1222+
#define ARGP_languages_exclude 336
12191223

12201224
static const struct argp_option pahole__options[] = {
12211225
{
@@ -1612,6 +1616,12 @@ static const struct argp_option pahole__options[] = {
16121616
.arg = "LANGUAGES",
16131617
.doc = "Only consider compilation units written in these languages"
16141618
},
1619+
{
1620+
.name = "lang_exclude",
1621+
.key = ARGP_languages_exclude,
1622+
.arg = "LANGUAGES",
1623+
.doc = "Don't consider compilation units written in these languages"
1624+
},
16151625
{
16161626
.name = NULL,
16171627
}
@@ -1772,6 +1782,9 @@ static error_t pahole__options_parser(int key, char *arg,
17721782
conf_load.skip_missing = true; break;
17731783
case ARGP_skip_encoding_btf_type_tag:
17741784
conf_load.skip_encoding_btf_type_tag = true; break;
1785+
case ARGP_languages_exclude:
1786+
languages.exclude = true;
1787+
/* fallthru */
17751788
case ARGP_languages:
17761789
languages.str = arg; break;
17771790
default:

0 commit comments

Comments
 (0)