blob: 1751802a09ba41aef3fb1e985d94110aff516a12 [file] [log] [blame]
John Kacur8b40f522009-09-24 18:02:18 +02001#ifndef __PERF_THREAD_H
2#define __PERF_THREAD_H
3
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +02004#include <linux/rbtree.h>
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +02005#include <unistd.h>
6#include "symbol.h"
7
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -02008struct map_groups {
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -02009 struct rb_root maps[MAP__NR_TYPES];
10 struct list_head removed_maps[MAP__NR_TYPES];
Arnaldo Carvalho de Melo1de8e242009-11-27 16:29:21 -020011 bool use_modules;
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020012};
13
14struct thread {
15 struct rb_node rb_node;
16 struct map_groups mg;
17 pid_t pid;
Ingo Molnar0ec04e12009-09-16 17:40:48 +020018 char shortname[3];
Ingo Molnarb5fae122009-09-11 12:12:54 +020019 char *comm;
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020020 int comm_len;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020021};
22
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020023void map_groups__init(struct map_groups *self);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020024int thread__set_comm(struct thread *self, const char *comm);
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020025int thread__comm_len(struct thread *self);
Arnaldo Carvalho de Melod5b889f2009-10-13 11:16:29 -030026struct thread *threads__findnew(pid_t pid);
27struct thread *register_idle_thread(void);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020028void thread__insert_map(struct thread *self, struct map *map);
29int thread__fork(struct thread *self, struct thread *parent);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020030size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
Arnaldo Carvalho de Melod5b889f2009-10-13 11:16:29 -030031size_t threads__fprintf(FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020032
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030033void maps__insert(struct rb_root *maps, struct map *map);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020034struct map *maps__find(struct rb_root *maps, u64 addr);
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030035
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020036static inline void map_groups__insert(struct map_groups *self, struct map *map)
37{
38 maps__insert(&self->maps[map->type], map);
39}
40
41static 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
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020047static inline struct map *thread__find_map(struct thread *self,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020048 enum map_type type, u64 addr)
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030049{
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020050 return self ? map_groups__find(&self->mg, type, addr) : NULL;
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020051}
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020052
53void 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);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020057struct symbol *map_groups__find_symbol(struct map_groups *self,
58 enum map_type type, u64 addr,
59 symbol_filter_t filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020060
61static inline struct symbol *
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020062map_groups__find_function(struct map_groups *self, u64 addr,
63 symbol_filter_t filter)
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020064{
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020065 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020066}
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020067
68struct map *map_groups__find_by_name(struct map_groups *self,
69 enum map_type type, const char *name);
John Kacur8b40f522009-09-24 18:02:18 +020070#endif /* __PERF_THREAD_H */