perf symbols: Rename kthreads to kmaps, using another abstraction for it
[safe/jmp/linux-2.6] / tools / perf / util / thread.h
1 #ifndef __PERF_THREAD_H
2 #define __PERF_THREAD_H
3
4 #include <linux/rbtree.h>
5 #include <unistd.h>
6 #include "symbol.h"
7
8 struct map_groups {
9         struct rb_root          maps[MAP__NR_TYPES];
10         struct list_head        removed_maps[MAP__NR_TYPES];
11         bool                    use_modules;
12 };
13
14 struct thread {
15         struct rb_node          rb_node;
16         struct map_groups       mg;
17         pid_t                   pid;
18         char                    shortname[3];
19         char                    *comm;
20         int                     comm_len;
21 };
22
23 void map_groups__init(struct map_groups *self);
24 int thread__set_comm(struct thread *self, const char *comm);
25 int thread__comm_len(struct thread *self);
26 struct thread *threads__findnew(pid_t pid);
27 struct thread *register_idle_thread(void);
28 void thread__insert_map(struct thread *self, struct map *map);
29 int thread__fork(struct thread *self, struct thread *parent);
30 size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
31 size_t threads__fprintf(FILE *fp);
32
33 void maps__insert(struct rb_root *maps, struct map *map);
34 struct map *maps__find(struct rb_root *maps, u64 addr);
35
36 static inline void map_groups__insert(struct map_groups *self, struct map *map)
37 {
38          maps__insert(&self->maps[map->type], map);
39 }
40
41 static inline struct map *map_groups__find(struct map_groups *self,
42                                            enum map_type type, u64 addr)
43 {
44         return maps__find(&self->maps[type], addr);
45 }
46
47 static inline struct map *thread__find_map(struct thread *self,
48                                            enum map_type type, u64 addr)
49 {
50         return self ? map_groups__find(&self->mg, type, addr) : NULL;
51 }
52
53 void thread__find_addr_location(struct thread *self, u8 cpumode,
54                                 enum map_type type, u64 addr,
55                                 struct addr_location *al,
56                                 symbol_filter_t filter);
57 struct symbol *map_groups__find_symbol(struct map_groups *self,
58                                        enum map_type type, u64 addr,
59                                        symbol_filter_t filter);
60
61 static inline struct symbol *
62 map_groups__find_function(struct map_groups *self, u64 addr,
63                           symbol_filter_t filter)
64 {
65         return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
66 }
67 #endif  /* __PERF_THREAD_H */