Re: [PATCH 4/8] libbpf: Add libbpf__kallsyms_parse function

From: Jiri Olsa
Date: Tue Feb 08 2022 - 04:08:48 EST


On Mon, Feb 07, 2022 at 10:59:24AM -0800, Andrii Nakryiko wrote:
> On Wed, Feb 2, 2022 at 5:54 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Move the kallsyms parsing in internal libbpf__kallsyms_parse
> > function, so it can be used from other places.
> >
> > It will be used in following changes.
> >
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> > tools/lib/bpf/libbpf.c | 62 ++++++++++++++++++++-------------
> > tools/lib/bpf/libbpf_internal.h | 5 +++
> > 2 files changed, 43 insertions(+), 24 deletions(-)
> >
> > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> > index 1b0936b016d9..7d595cfd03bc 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -7165,12 +7165,10 @@ static int bpf_object__sanitize_maps(struct bpf_object *obj)
> > return 0;
> > }
> >
> > -static int bpf_object__read_kallsyms_file(struct bpf_object *obj)
> > +int libbpf__kallsyms_parse(void *arg, kallsyms_cb_t cb)
>
> please call it libbpf_kallsyms_parse(), internal APIs don't use
> "object oriented" double underscore separator
>
> also this "arg" is normally called "ctx" in similar APIs in libbpf and
> is passed the last, can you please adjust all that for consistency?

ok, thanks

jirka

>
> > {
> > char sym_type, sym_name[500];
> > unsigned long long sym_addr;
> > - const struct btf_type *t;
> > - struct extern_desc *ext;
> > int ret, err = 0;
> > FILE *f;
> >
>
> [...]
>