thread.h 2.6 KB
Newer Older
1 2 3
#ifndef __PERF_THREAD_H
#define __PERF_THREAD_H

4 5 6 7
#include <linux/rbtree.h>
#include <unistd.h>
#include "symbol.h"

8
struct map_groups {
9 10
	struct rb_root		maps[MAP__NR_TYPES];
	struct list_head	removed_maps[MAP__NR_TYPES];
11 12 13 14 15 16
};

struct thread {
	struct rb_node		rb_node;
	struct map_groups	mg;
	pid_t			pid;
17
	char			shortname[3];
18
	char			*comm;
19
	int			comm_len;
20 21
};

22
void map_groups__init(struct map_groups *self);
23
int thread__set_comm(struct thread *self, const char *comm);
24
int thread__comm_len(struct thread *self);
25
struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
26 27
void thread__insert_map(struct thread *self, struct map *map);
int thread__fork(struct thread *self, struct thread *parent);
28
size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
29
size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
30

31
void maps__insert(struct rb_root *maps, struct map *map);
32
struct map *maps__find(struct rb_root *maps, u64 addr);
33

34 35 36 37 38 39
static inline void map_groups__insert(struct map_groups *self, struct map *map)
{
	 maps__insert(&self->maps[map->type], map);
}

static inline struct map *map_groups__find(struct map_groups *self,
40
					   enum map_type type, u64 addr)
41
{
42
	return maps__find(&self->maps[type], addr);
43 44
}

45 46
static inline struct map *thread__find_map(struct thread *self,
					   enum map_type type, u64 addr)
47
{
48
	return self ? map_groups__find(&self->mg, type, addr) : NULL;
49
}
50

51 52 53 54 55
void thread__find_addr_map(struct thread *self,
			   struct perf_session *session, u8 cpumode,
			   enum map_type type, u64 addr,
			   struct addr_location *al);

56 57
void thread__find_addr_location(struct thread *self,
				struct perf_session *session, u8 cpumode,
58 59 60
				enum map_type type, u64 addr,
				struct addr_location *al,
				symbol_filter_t filter);
61 62 63
struct symbol *map_groups__find_symbol(struct map_groups *self,
				       enum map_type type, u64 addr,
				       symbol_filter_t filter);
64

65 66 67
static inline struct symbol *map_groups__find_function(struct map_groups *self,
						       u64 addr,
						       symbol_filter_t filter)
68
{
69
	return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
70
}
71 72 73

struct map *map_groups__find_by_name(struct map_groups *self,
				     enum map_type type, const char *name);
74 75 76 77

int __map_groups__create_kernel_maps(struct map_groups *self,
				     struct map *vmlinux_maps[MAP__NR_TYPES],
				     struct dso *kernel);
78 79 80 81 82
int map_groups__create_kernel_maps(struct map_groups *self,
				   struct map *vmlinux_maps[MAP__NR_TYPES]);

struct map *map_groups__new_module(struct map_groups *self, u64 start,
				   const char *filename);
83
#endif	/* __PERF_THREAD_H */