Re: [PATCH v3 perf,bpf 10/11] perf, bpf: enable annotation of bpf program

Jiri Olsa
2019-02-17T23:05:31Z

On Fri, Feb 15, 2019 at 01:53:53PM -0800, Song Liu wrote:

SNIP

> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 70de8f6b3aee..078017d31ca9 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -22,6 +22,7 @@
> #include "annotate.h"
> #include "evsel.h"
> #include "evlist.h"
> +#include "bpf-event.h"
> #include "block-range.h"
> #include "string2.h"
> #include "arch/common.h"
> @@ -29,6 +30,9 @@
> #include <pthread.h>
> #include <linux/bitops.h>
> #include <linux/kernel.h>
> +#include <bfd.h>
> +#include <dis-asm.h>
> +#include <bpf/libbpf.h>
>
> /* FIXME: For the HE_COLORSET */
> #include "ui/browser.h"
> @@ -1672,6 +1676,147 @@ static int dso__disassemble_filename(struct dso *dso, char *filename, size_t fil
> return 0;
> }
>
> +static void get_exec_path(char *tpath, size_t size)
> +{
> + const char *path = "/proc/self/exe";
> + ssize_t len;
> +
> + len = readlink(path, tpath, size - 1);
> + assert(len > 0);
> + tpath[len] = 0;
> +}

this is also used in write_cmdline, could you please
move it under util.c and use it in write_cmdline as well?

thanks,
jirka

> +
> +static int symbol__disassemble_bpf(struct symbol *sym,
> + struct annotate_args *args)
> +{
> + struct annotation *notes = symbol__annotation(sym);
> + struct annotation_options *opts = args->options;
> + struct bpf_prog_info_linear *info_linear;
> + struct bpf_prog_linfo *prog_linfo = NULL;
> + struct bpf_prog_info_node *info_node;
> + int len = sym->end - sym->start;
> + disassembler_ftype disassemble;
> + struct map *map = args->ms.map;
> + struct disassemble_info info;
> + struct dso *dso = map->dso;
> + int pc = 0, count, sub_id;
> + struct btf *btf = NULL;
> + char tpath[PATH_MAX];
> + size_t buf_size;
> + int nr_skip = 0;
> + __u64 arrays;
> + char *buf;
> + bfd *bfdf;
> + FILE *s;

nice triangle ;-)

SNIP