xref: /linux/tools/perf/util/dsos.h (revision 3630400697a3d334a391c1dba1b601d852145f2c)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_DSOS
3 #define __PERF_DSOS
4 
5 #include <stdbool.h>
6 #include <stdio.h>
7 #include <linux/list.h>
8 #include <linux/rbtree.h>
9 #include "rwsem.h"
10 
11 struct dso;
12 struct dso_id;
13 struct kmod_path;
14 struct machine;
15 
16 /*
17  * Collection of DSOs as an array for iteration speed, but sorted for O(n)
18  * lookup.
19  */
20 struct dsos {
21 	struct rw_semaphore lock;
22 	struct dso **dsos;
23 	unsigned int cnt;
24 	unsigned int allocated;
25 	bool sorted;
26 };
27 
28 void dsos__init(struct dsos *dsos);
29 void dsos__exit(struct dsos *dsos);
30 
31 int __dsos__add(struct dsos *dsos, struct dso *dso);
32 int dsos__add(struct dsos *dsos, struct dso *dso);
33 struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
34 
35 struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, const struct dso_id *id);
36 
37 bool dsos__read_build_ids(struct dsos *dsos, bool with_hits);
38 
39 size_t dsos__fprintf_buildid(struct dsos *dsos, FILE *fp,
40 			       bool (skip)(struct dso *dso, int parm), int parm);
41 size_t dsos__fprintf(struct dsos *dsos, FILE *fp);
42 
43 int dsos__hit_all(struct dsos *dsos);
44 
45 struct dso *dsos__findnew_module_dso(struct dsos *dsos, struct machine *machine,
46 				     struct kmod_path *m, const char *filename);
47 
48 struct dso *dsos__find_kernel_dso(struct dsos *dsos);
49 
50 int dsos__for_each_dso(struct dsos *dsos, int (*cb)(struct dso *dso, void *data), void *data);
51 
52 #endif /* __PERF_DSOS */
53