Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/vapier...
[linux-2.6-block.git] / tools / perf / util / thread.h
CommitLineData
8b40f521
JK
1#ifndef __PERF_THREAD_H
2#define __PERF_THREAD_H
3
6baa0a5a 4#include <linux/rbtree.h>
6baa0a5a
FW
5#include <unistd.h>
6#include "symbol.h"
7
9958e1f0 8struct map_groups {
95011c60
ACM
9 struct rb_root maps[MAP__NR_TYPES];
10 struct list_head removed_maps[MAP__NR_TYPES];
9958e1f0
ACM
11};
12
65f2ed2b
ACM
13size_t __map_groups__fprintf_maps(struct map_groups *self,
14 enum map_type type, FILE *fp);
15
9958e1f0
ACM
16struct thread {
17 struct rb_node rb_node;
18 struct map_groups mg;
19 pid_t pid;
0ec04e16 20 char shortname[3];
faa5c5c3 21 bool comm_set;
b5fae128 22 char *comm;
a4fb581b 23 int comm_len;
6baa0a5a
FW
24};
25
9958e1f0 26void map_groups__init(struct map_groups *self);
6baa0a5a 27int thread__set_comm(struct thread *self, const char *comm);
a4fb581b 28int thread__comm_len(struct thread *self);
b3165f41 29struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
6baa0a5a
FW
30void thread__insert_map(struct thread *self, struct map *map);
31int thread__fork(struct thread *self, struct thread *parent);
9958e1f0 32size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
b3165f41 33size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
8b40f521 34
1b46cddf 35void maps__insert(struct rb_root *maps, struct map *map);
1ed091c4 36struct map *maps__find(struct rb_root *maps, u64 addr);
439d473b 37
9958e1f0
ACM
38static inline void map_groups__insert(struct map_groups *self, struct map *map)
39{
40 maps__insert(&self->maps[map->type], map);
41}
42
43static inline struct map *map_groups__find(struct map_groups *self,
1ed091c4 44 enum map_type type, u64 addr)
1b46cddf 45{
9958e1f0 46 return maps__find(&self->maps[type], addr);
1b46cddf
ACM
47}
48
9958e1f0
ACM
49static inline struct map *thread__find_map(struct thread *self,
50 enum map_type type, u64 addr)
95011c60 51{
9958e1f0 52 return self ? map_groups__find(&self->mg, type, addr) : NULL;
95011c60 53}
1ed091c4 54
59ee68ec
ACM
55void thread__find_addr_map(struct thread *self,
56 struct perf_session *session, u8 cpumode,
57 enum map_type type, u64 addr,
58 struct addr_location *al);
59
4aa65636
ACM
60void thread__find_addr_location(struct thread *self,
61 struct perf_session *session, u8 cpumode,
1ed091c4
ACM
62 enum map_type type, u64 addr,
63 struct addr_location *al,
64 symbol_filter_t filter);
9958e1f0
ACM
65struct symbol *map_groups__find_symbol(struct map_groups *self,
66 enum map_type type, u64 addr,
67 symbol_filter_t filter);
1ed091c4 68
9de89fe7
ACM
69static inline struct symbol *map_groups__find_function(struct map_groups *self,
70 u64 addr,
71 symbol_filter_t filter)
1ed091c4 72{
9de89fe7 73 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
1ed091c4 74}
79406cd7
ACM
75
76struct map *map_groups__find_by_name(struct map_groups *self,
77 enum map_type type, const char *name);
b7cece76
ACM
78
79int __map_groups__create_kernel_maps(struct map_groups *self,
80 struct map *vmlinux_maps[MAP__NR_TYPES],
81 struct dso *kernel);
9de89fe7
ACM
82int map_groups__create_kernel_maps(struct map_groups *self,
83 struct map *vmlinux_maps[MAP__NR_TYPES]);
84
85struct map *map_groups__new_module(struct map_groups *self, u64 start,
86 const char *filename);
8b40f521 87#endif /* __PERF_THREAD_H */