diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-11-19 20:30:56 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-11-19 20:30:56 +0100 |
commit | 7b59a82493b49b715224bfe3b35fae52e48e5fa1 (patch) | |
tree | 19ea4fc7681d4806d13b3f0c5b63620abbd91698 /tools/perf/util/dsos.c | |
parent | perf map: Pass a dso_id to map__new() (diff) | |
download | linux-7b59a82493b49b715224bfe3b35fae52e48e5fa1.tar.xz linux-7b59a82493b49b715224bfe3b35fae52e48e5fa1.zip |
perf map: Move comparision of map's dso_id to a separate function
We'll use it when doing DSO lookups using dso_ids.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-u2nr1oq03o0i29w2ay9jx03s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/dsos.c')
-rw-r--r-- | tools/perf/util/dsos.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/util/dsos.c b/tools/perf/util/dsos.c index 3ea80d203587..ecf8d7346685 100644 --- a/tools/perf/util/dsos.c +++ b/tools/perf/util/dsos.c @@ -2,6 +2,7 @@ #include "debug.h" #include "dsos.h" #include "dso.h" +#include "map.h" #include "vdso.h" #include "namespaces.h" #include <libgen.h> @@ -9,6 +10,30 @@ #include <string.h> #include <symbol.h> // filename__read_build_id +int dso_id__cmp(struct dso_id *a, struct dso_id *b) +{ + /* + * The second is always dso->id, so zeroes if not set, assume passing + * NULL for a means a zeroed id + */ + if (a == NULL) + return 0; + + if (a->maj > b->maj) return -1; + if (a->maj < b->maj) return 1; + + if (a->min > b->min) return -1; + if (a->min < b->min) return 1; + + if (a->ino > b->ino) return -1; + if (a->ino < b->ino) return 1; + + if (a->ino_generation > b->ino_generation) return -1; + if (a->ino_generation < b->ino_generation) return 1; + + return 0; +} + bool __dsos__read_build_ids(struct list_head *head, bool with_hits) { bool have_build_id = false; |