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 | |
| 8 | struct thread { |
Ingo Molnar | b5fae12 | 2009-09-11 12:12:54 +0200 | [diff] [blame] | 9 | struct rb_node rb_node; |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 10 | struct rb_root maps[MAP__NR_TYPES]; |
| 11 | struct list_head removed_maps[MAP__NR_TYPES]; |
Ingo Molnar | b5fae12 | 2009-09-11 12:12:54 +0200 | [diff] [blame] | 12 | pid_t pid; |
Arnaldo Carvalho de Melo | 1de8e24 | 2009-11-27 16:29:21 -0200 | [diff] [blame] | 13 | bool use_modules; |
Ingo Molnar | 0ec04e1 | 2009-09-16 17:40:48 +0200 | [diff] [blame] | 14 | char shortname[3]; |
Ingo Molnar | b5fae12 | 2009-09-11 12:12:54 +0200 | [diff] [blame] | 15 | char *comm; |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 16 | int comm_len; |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 17 | }; |
| 18 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 19 | void thread__init(struct thread *self, pid_t pid); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 20 | int thread__set_comm(struct thread *self, const char *comm); |
Frederic Weisbecker | a4fb581 | 2009-10-22 23:23:23 +0200 | [diff] [blame] | 21 | int thread__comm_len(struct thread *self); |
Arnaldo Carvalho de Melo | d5b889f | 2009-10-13 11:16:29 -0300 | [diff] [blame] | 22 | struct thread *threads__findnew(pid_t pid); |
| 23 | struct thread *register_idle_thread(void); |
Frederic Weisbecker | 6baa0a5 | 2009-08-14 12:21:53 +0200 | [diff] [blame] | 24 | void thread__insert_map(struct thread *self, struct map *map); |
| 25 | int thread__fork(struct thread *self, struct thread *parent); |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 26 | size_t thread__fprintf_maps(struct thread *self, FILE *fp); |
Arnaldo Carvalho de Melo | d5b889f | 2009-10-13 11:16:29 -0300 | [diff] [blame] | 27 | size_t threads__fprintf(FILE *fp); |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 28 | |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 29 | void maps__insert(struct rb_root *maps, struct map *map); |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 30 | struct map *maps__find(struct rb_root *maps, u64 addr); |
Arnaldo Carvalho de Melo | 439d473 | 2009-10-02 03:29:58 -0300 | [diff] [blame] | 31 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 32 | static inline struct map *thread__find_map(struct thread *self, |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 33 | enum map_type type, u64 addr) |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 34 | { |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 35 | return self ? maps__find(&self->maps[type], addr) : NULL; |
Arnaldo Carvalho de Melo | 1b46cdd | 2009-09-28 14:48:46 -0300 | [diff] [blame] | 36 | } |
| 37 | |
Arnaldo Carvalho de Melo | 95011c6 | 2009-11-27 16:29:20 -0200 | [diff] [blame] | 38 | static inline void __thread__insert_map(struct thread *self, struct map *map) |
| 39 | { |
| 40 | maps__insert(&self->maps[map->type], map); |
| 41 | } |
Arnaldo Carvalho de Melo | 1ed091c | 2009-11-27 16:29:23 -0200 | [diff] [blame] | 42 | |
| 43 | void thread__find_addr_location(struct thread *self, u8 cpumode, |
| 44 | enum map_type type, u64 addr, |
| 45 | struct addr_location *al, |
| 46 | symbol_filter_t filter); |
| 47 | struct symbol *thread__find_symbol(struct thread *self, |
| 48 | enum map_type type, u64 addr, |
| 49 | symbol_filter_t filter); |
| 50 | |
| 51 | static inline struct symbol * |
| 52 | thread__find_function(struct thread *self, u64 addr, symbol_filter_t filter) |
| 53 | { |
| 54 | return thread__find_symbol(self, MAP__FUNCTION, addr, filter); |
| 55 | } |
John Kacur | 8b40f52 | 2009-09-24 18:02:18 +0200 | [diff] [blame] | 56 | #endif /* __PERF_THREAD_H */ |