On Wed, May 19, 2021 at 10:44:44AM +0800, Shuyi Cheng wrote: SNIP > where > one wants to know what if the installed version has some feature, i.e.: 118 > instead of "v1.18". > > +.TP > +.B \-\-kabi_prefix=STRING > +When the prefix of the string is STRING, treat the string as STRING. > + > .SH NOTES > > To enable the generation of debugging information in the Linux kernel build > diff --git a/pahole.c b/pahole.c > index dc40ccf..6a700d9 100644 > --- a/pahole.c > +++ b/pahole.c > @@ -24,6 +24,7 @@ > #include "btf_encoder.h" > #include "libbtf.h" > #include "lib/bpf/src/libbpf.h" > +#include "pahole_strings.h" > > static bool btf_encode; > static bool ctf_encode; > @@ -855,6 +856,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version; > #define ARGP_btf_gen_floats 322 > #define ARGP_btf_gen_all 323 > #define ARGP_with_flexible_array 324 > +#define ARGP_kabi_prefix 325 > > static const struct argp_option pahole__options[] = { > { > @@ -1140,6 +1142,12 @@ static const struct argp_option pahole__options[] = { > .doc = "Path to the base BTF file", > }, > { > + .name = "kabi_prefix", > + .key = ARGP_kabi_prefix, > + .arg = "STRING", > + .doc = "When the prefix of the string is STRING, treat the string as > STRING.", please keep the '=' indentation > + }, > + { > .name = "btf_encode", > .key = 'J', > .doc = "Encode as BTF", > @@ -1297,6 +1305,8 @@ static error_t pahole__options_parser(int key, char > *arg, > btf_encode_force = true; break; > case ARGP_btf_base: > base_btf_file = arg; break; > + case ARGP_kabi_prefix: > + kabi_prefix = arg; break; > case ARGP_numeric_version: > print_numeric_version = true; break; > case ARGP_btf_gen_floats: > diff --git a/pahole_strings.h b/pahole_strings.h > index 522fbf2..a836ba8 100644 > --- a/pahole_strings.h > +++ b/pahole_strings.h > @@ -14,6 +14,8 @@ struct strings { > struct btf *btf; > }; > > +extern const char *kabi_prefix; > + > struct strings *strings__new(void); > > void strings__delete(struct strings *strings); > diff --git a/strings.c b/strings.c > index d37f49d..d1a54ec 100644 > --- a/strings.c > +++ b/strings.c > @@ -17,6 +17,8 @@ > #include "dutil.h" > #include "lib/bpf/src/libbpf.h" > > +const char *kabi_prefix; > + > struct strings *strings__new(void) > { > struct strings *strs = malloc(sizeof(*strs)); > @@ -48,7 +50,12 @@ strings_t strings__add(struct strings *strs, const char > *str) > if (str == NULL) > return 0; > > - index = btf__add_str(strs->btf, str); > + if (kabi_prefix && > + strncmp(str, kabi_prefix, strlen(kabi_prefix)) == 0) > + index = btf__add_str(strs->btf, kabi_prefix); > + else > + index = btf__add_str(strs->btf, str); > + ^^^ extra whitespace, other than that looks ok Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> jirka > if (index < 0) > return 0; > > -- > 1.8.3.1 >