From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
dwarves@vger.kernel.org, bpf <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andriin@fb.com>, Yonghong Song <yhs@fb.com>,
Hao Luo <haoluo@google.com>
Subject: Re: [RFC/PATCH 2/3] btf_encoder: Put function generation code to generate_func
Date: Thu, 12 Nov 2020 11:39:42 -0800 [thread overview]
Message-ID: <CAEf4BzavQiEAQyeUU3kxHQ5tmwRJev6N_jbqNe=xhJpWyTAQ8Q@mail.gmail.com> (raw)
In-Reply-To: <20201112150506.705430-3-jolsa@kernel.org>
On Thu, Nov 12, 2020 at 7:05 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> We will use generate_func from another place in following change.
>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> btf_encoder.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/btf_encoder.c b/btf_encoder.c
> index d531651b1e9e..efc4f48dbc5a 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -351,6 +351,23 @@ static struct btf_elf *btfe;
> static uint32_t array_index_id;
> static bool has_index_type;
>
> +static int generate_func(struct btf_elf *btfe, struct cu *cu,
> + struct function *fn, uint32_t type_id_off)
> +{
> + int btf_fnproto_id, btf_fn_id, err = 0;
btf_ prefix for these variables don't contribute anything, I'd just
drop them here
> + const char *name;
> +
> + btf_fnproto_id = btf_elf__add_func_proto(btfe, cu, &fn->proto, type_id_off);
> + name = dwarves__active_loader->strings__ptr(cu, fn->name);
> + btf_fn_id = btf_elf__add_ref_type(btfe, BTF_KIND_FUNC, btf_fnproto_id, name, false);
> + if (btf_fnproto_id < 0 || btf_fn_id < 0) {
> + err = -1;
> + printf("error: failed to encode function '%s'\n", function__name(fn, cu));
return -1;
> + }
> +
> + return err;
return 0; drop err variable.
> +}
> +
> int btf_encoder__encode()
> {
> int err;
> @@ -608,9 +625,6 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> }
>
> cu__for_each_function(cu, core_id, fn) {
> - int btf_fnproto_id, btf_fn_id;
> - const char *name;
> -
> /*
> * The functions_cnt != 0 means we parsed all necessary
> * kernel symbols and we are using ftrace location filter
> @@ -634,14 +648,8 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force,
> continue;
> }
>
> - btf_fnproto_id = btf_elf__add_func_proto(btfe, cu, &fn->proto, type_id_off);
> - name = dwarves__active_loader->strings__ptr(cu, fn->name);
> - btf_fn_id = btf_elf__add_ref_type(btfe, BTF_KIND_FUNC, btf_fnproto_id, name, false);
> - if (btf_fnproto_id < 0 || btf_fn_id < 0) {
> - err = -1;
> - printf("error: failed to encode function '%s'\n", function__name(fn, cu));
> + if (generate_func(btfe, cu, fn, type_id_off))
> goto out;
> - }
> }
>
> if (skip_encoding_vars)
> --
> 2.26.2
>
next prev parent reply other threads:[~2020-11-12 19:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-12 15:05 [RFC 0/3] btf_encoder: Fix functions BTF data generation Jiri Olsa
2020-11-12 15:05 ` [RFC/PATCH 1/3] btf_encoder: Generate also .init functions Jiri Olsa
2020-11-12 19:37 ` Andrii Nakryiko
2020-11-12 15:05 ` [RFC/PATCH 2/3] btf_encoder: Put function generation code to generate_func Jiri Olsa
2020-11-12 19:39 ` Andrii Nakryiko [this message]
2020-11-12 15:05 ` [RFC/PATCH 3/3] btf_encoder: Func generation fix Jiri Olsa
2020-11-12 19:54 ` Andrii Nakryiko
2020-11-12 21:14 ` Jiri Olsa
2020-11-13 0:08 ` Andrii Nakryiko
2020-11-13 0:18 ` Alexei Starovoitov
2020-11-13 0:30 ` Andrii Nakryiko
2020-11-13 1:00 ` Yonghong Song
2020-11-13 1:12 ` Andrii Nakryiko
2020-11-13 10:59 ` Jiri Olsa
2020-11-13 11:52 ` Arnaldo Carvalho de Melo
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='CAEf4BzavQiEAQyeUU3kxHQ5tmwRJev6N_jbqNe=xhJpWyTAQ8Q@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=acme@kernel.org \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=haoluo@google.com \
--cc=jolsa@kernel.org \
--cc=yhs@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).