xref: /linux/tools/perf/util/dsos.h (revision 173b0b5b0e865348684c02bd9cb1d22b5d46e458)
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  * DSOs are put into both a list for fast iteration and rbtree for fast
18  * long name lookup.
19  */
20 struct dsos {
21 	struct list_head    head;
22 	struct rb_root	    root;	/* rbtree root sorted by long name */
23 	struct rw_semaphore lock;
24 };
25 
26 void dsos__init(struct dsos *dsos);
27 void dsos__exit(struct dsos *dsos);
28 
29 void __dsos__add(struct dsos *dsos, struct dso *dso);
30 void dsos__add(struct dsos *dsos, struct dso *dso);
31 struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
32 struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);
33 
34 struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, struct dso_id *id);
35 
36 bool dsos__read_build_ids(struct dsos *dsos, bool with_hits);
37 
38 struct dso *__dsos__findnew_link_by_longname_id(struct rb_root *root, struct dso *dso,
39 						const char *name, struct dso_id *id);
40 
41 size_t dsos__fprintf_buildid(struct dsos *dsos, FILE *fp,
42 			       bool (skip)(struct dso *dso, int parm), int parm);
43 size_t dsos__fprintf(struct dsos *dsos, FILE *fp);
44 
45 int dsos__hit_all(struct dsos *dsos);
46 
47 struct dso *dsos__findnew_module_dso(struct dsos *dsos, struct machine *machine,
48 				     struct kmod_path *m, const char *filename);
49 
50 struct dso *dsos__find_kernel_dso(struct dsos *dsos);
51 
52 int dsos__for_each_dso(struct dsos *dsos, int (*cb)(struct dso *dso, void *data), void *data);
53 
54 #endif /* __PERF_DSOS */
55