From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A61F2C43460 for ; Thu, 20 May 2021 15:25:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84AD161073 for ; Thu, 20 May 2021 15:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231907AbhETP1J (ORCPT ); Thu, 20 May 2021 11:27:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56673 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232323AbhETP06 (ORCPT ); Thu, 20 May 2021 11:26:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621524336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oVkBUZW9yv71USEd9qQVYrxN1VvKA0gHt398KBPcOvA=; b=XmYwhpNmAi2p/5QNuwi0vmrmUUe9Q/L/bMJ2aTrNJ0CHr4YgW4dlzW5E1g6sNzb77UlZzP 4g+hmLHt9vOguvD2roNpZdUPG3bBtBHtJmaFMtrrbX8S/DpH02BnfGaadu1bvHyiQAXdx7 xjv8jZK9+EiV87YuLf5GQ7U3Kf8nr+w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-srxN6A4_OxuVZvxB4oONiA-1; Thu, 20 May 2021 11:25:32 -0400 X-MC-Unique: srxN6A4_OxuVZvxB4oONiA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C55908031ED; Thu, 20 May 2021 15:25:27 +0000 (UTC) Received: from krava (unknown [10.40.194.160]) by smtp.corp.redhat.com (Postfix) with SMTP id F285E29166; Thu, 20 May 2021 15:25:25 +0000 (UTC) Date: Thu, 20 May 2021 17:25:24 +0200 From: Jiri Olsa To: Shuyi Cheng Cc: Andrii Nakryiko , Arnaldo Carvalho de Melo , dwarves@vger.kernel.org, wenan.mao@linux.alibaba.com, Jiri Olsa Subject: Re: [PATCH v2] pahole: Add --kabi_prefix flag Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: dwarves@vger.kernel.org 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 jirka > if (index < 0) > return 0; > > -- > 1.8.3.1 >