summaryrefslogtreecommitdiff
path: root/tools/perf/util/dsos.h
blob: a7c7f723c5fff0115e54522c05eebf79c9547000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __PERF_DSOS
#define __PERF_DSOS

#include <stdbool.h>
#include <stdio.h>
#include <linux/list.h>
#include <linux/rbtree.h>
#include "rwsem.h"

struct dso;
struct dso_id;
struct kmod_path;
struct machine;

/*
 * DSOs are put into both a list for fast iteration and rbtree for fast
 * long name lookup.
 */
struct dsos {
	struct list_head    head;
	struct rb_root	    root;	/* rbtree root sorted by long name */
	struct rw_semaphore lock;
};

#define dsos__for_each_with_build_id(pos, head)	\
	list_for_each_entry(pos, head, node)	\
		if (!pos->has_build_id)		\
			continue;		\
		else

void dsos__init(struct dsos *dsos);
void dsos__exit(struct dsos *dsos);

void __dsos__add(struct dsos *dsos, struct dso *dso);
void dsos__add(struct dsos *dsos, struct dso *dso);
struct dso *__dsos__addnew(struct dsos *dsos, const char *name);
struct dso *dsos__find(struct dsos *dsos, const char *name, bool cmp_short);

struct dso *dsos__findnew_id(struct dsos *dsos, const char *name, struct dso_id *id);
 
bool __dsos__read_build_ids(struct dsos *dsos, bool with_hits);

struct dso *__dsos__findnew_link_by_longname_id(struct rb_root *root, struct dso *dso,
						const char *name, struct dso_id *id);

size_t __dsos__fprintf_buildid(struct dsos *dsos, FILE *fp,
			       bool (skip)(struct dso *dso, int parm), int parm);
size_t __dsos__fprintf(struct dsos *dsos, FILE *fp);

int __dsos__hit_all(struct dsos *dsos);

struct dso *dsos__findnew_module_dso(struct dsos *dsos, struct machine *machine,
				     struct kmod_path *m, const char *filename);

struct dso *dsos__find_kernel_dso(struct dsos *dsos);

#endif /* __PERF_DSOS */