Re: [PATCH 21/26] perf tools: Add machine__for_each_dso function

From: Arnaldo Carvalho de Melo
Date: Mon Sep 14 2020 - 12:20:38 EST


Em Sun, Sep 13, 2020 at 11:03:08PM +0200, Jiri Olsa escreveu:
> Adding machine__for_each_dso to iterate over all dso
> objects defined for the within the machine. It will
> be used in following changes.

prep work, applying.

- Arnaldo

> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
> tools/perf/util/machine.c | 12 ++++++++++++
> tools/perf/util/machine.h | 4 ++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 863d949ef967..f8e8d0d80847 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -3181,3 +3181,15 @@ char *machine__resolve_kernel_addr(void *vmachine, unsigned long long *addrp, ch
> *addrp = map->unmap_ip(map, sym->start);
> return sym->name;
> }
> +
> +int machine__for_each_dso(struct machine *machine, machine__dso_t fn, void *priv)
> +{
> + struct dso *pos;
> + int err = 0;
> +
> + list_for_each_entry(pos, &machine->dsos.head, node) {
> + if (fn(pos, machine, priv))
> + err = -1;
> + }
> + return err;
> +}
> diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h
> index a3c1d0bf89e5..504c707f22bb 100644
> --- a/tools/perf/util/machine.h
> +++ b/tools/perf/util/machine.h
> @@ -252,6 +252,10 @@ void machines__destroy_kernel_maps(struct machines *machines);
>
> size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
>
> +typedef int (*machine__dso_t)(struct dso *dso, struct machine *machine, void *priv);
> +
> +int machine__for_each_dso(struct machine *machine, machine__dso_t fn,
> + void *priv);
> int machine__for_each_thread(struct machine *machine,
> int (*fn)(struct thread *thread, void *p),
> void *priv);
> --
> 2.26.2
>

--

- Arnaldo