[PATCH V5 2/3] perf tool: new function to compare build_ids

From: Kan Liang
Date: Mon Nov 24 2014 - 11:18:25 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

New function to compare the build_ids between different DSOs

Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Kan Liang <kan.liang@xxxxxxxxx>
---
tools/perf/util/dso.c | 33 +++++++++++++++++++++++++++++++++
tools/perf/util/dso.h | 3 +++
2 files changed, 36 insertions(+)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 45be944..e53ce26 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -1087,3 +1087,36 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine)

return dso__type_fd(fd);
}
+
+bool dsos__build_ids_equal(struct dsos *dsos_a, struct dsos *dsos_b)
+{
+ bool ret;
+ struct dso *dso_a, *dso_b;
+
+ list_for_each_entry(dso_a, &dsos_a->head, node) {
+ dso_b = dsos__find(dsos_b, dso_a->long_name, false);
+ if (dso_b == NULL)
+ return false;
+
+ if (memcmp(dso_a->build_id, dso_b->build_id, sizeof(dso_a->build_id)))
+ return false;
+
+ /* Mark that we compared this one */
+ dso_b->visited = 1;
+ }
+
+ /*
+ * Now check if there are dsos in dsos_b that are not in
+ * dsos_a
+ */
+
+ ret = true;
+ list_for_each_entry(dso_b, &dsos_b->head, node) {
+ if (!dso_b->visited)
+ ret = false;
+ else
+ dso_b->visited = 0;
+ }
+
+ return ret;
+}
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 3782c82..371f826 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -117,6 +117,7 @@ struct dso {
u8 has_build_id:1;
u8 has_srcline:1;
u8 hit:1;
+ u8 visited:1;
u8 annotate_warned:1;
u8 short_name_allocated:1;
u8 long_name_allocated:1;
@@ -278,4 +279,6 @@ void dso__free_a2l(struct dso *dso);

enum dso_type dso__type(struct dso *dso, struct machine *machine);

+bool dsos__build_ids_equal(struct dsos *dsos_a, struct dsos *dsos_b);
+
#endif /* __PERF_DSO */
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/