John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 1 | #ifndef __PERF_THREAD_H |
| 2 | #define __PERF_THREAD_H |
| 3 | |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 4 | #include <linux/rbtree.h> |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 5 | #include <unistd.h> |
| 6 | #include "symbol.h" |
| 7 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 8 | struct map_groups { |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 9 | struct rb_root maps[MAP__NR_TYPES]; |
| 10 | struct list_head removed_maps[MAP__NR_TYPES]; |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 11 | }; |
| 12 | |
| 13 | struct thread { |
| 14 | struct rb_node rb_node; |
| 15 | struct map_groups mg; |
| 16 | pid_t pid; |
Ingo Molnar | 0ec04e1 | 2009-09-16 17:40:48 +0200 | [diff] [blame] | 17 | char shortname[3]; |
Ingo Molnar | b5fae12 | 2009-09-11 12:12:54 +0200 | [diff] [blame] | 18 | char *comm; |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 19 | int comm_len; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 20 | }; |
| 21 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 22 | void map_groups__init(struct map_groups *self); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 23 | int thread__set_comm(struct thread *self, const char *comm); |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 24 | int thread__comm_len(struct thread *self); |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 25 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 26 | void thread__insert_map(struct thread *self, struct map *map); |
| 27 | int thread__fork(struct thread *self, struct thread *parent); |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 28 | size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp); |
Arnaldo Carvalho de Melo | b3165f4 | 2009-12-13 19:50:28 -0200 | [diff] [blame] | 29 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 30 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 31 | void maps__insert(struct rb_root *maps, struct map *map); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 32 | struct map *maps__find(struct rb_root *maps, u64 addr); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 33 | |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 34 | static inline void map_groups__insert(struct map_groups *self, struct map *map) |
| 35 | { |
| 36 | maps__insert(&self->maps[map->type], map); |
| 37 | } |
| 38 | |
| 39 | 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 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 45 | static inline struct map *thread__find_map(struct thread *self, |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 46 | enum map_type type, u64 addr) |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 47 | { |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 48 | return self ? map_groups__find(&self->mg, type, addr) : NULL; |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 49 | } |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 50 | |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 51 | void thread__find_addr_location(struct thread *self, |
| 52 | struct perf_session *session, u8 cpumode, |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 53 | enum map_type type, u64 addr, |
| 54 | struct addr_location *al, |
| 55 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 56 | struct symbol *map_groups__find_symbol(struct map_groups *self, |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 57 | struct perf_session *session, |
Arnaldo Carvalho de Melo | 9958e1f | 2009-12-11 14:50:36 -0200 | [diff] [blame] | 58 | enum map_type type, u64 addr, |
| 59 | symbol_filter_t filter); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 60 | |
| 61 | static inline struct symbol * |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 62 | map_groups__find_function(struct map_groups *self, struct perf_session *session, |
| 63 | u64 addr, symbol_filter_t filter) |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 64 | { |
Arnaldo Carvalho de Melo | 4aa6563 | 2009-12-13 19:50:29 -0200 | [diff] [blame] | 65 | return map_groups__find_symbol(self, session, MAP__FUNCTION, addr, filter); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 66 | } |
Arnaldo Carvalho de Melo | 79406cd | 2009-12-11 18:50:22 -0200 | [diff] [blame] | 67 | |
| 68 | struct map *map_groups__find_by_name(struct map_groups *self, |
| 69 | enum map_type type, const char *name); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 70 | #endif /* __PERF_THREAD_H */ |