blob: c206f72c88811fb959d26d984b2e7a3506621d9a [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 Melo9958e1f2009-12-11 14:50:36 -020011};
12
13struct thread {
14 struct rb_node rb_node;
15 struct map_groups mg;
16 pid_t pid;
Ingo Molnar0ec04e12009-09-16 17:40:48 +020017 char shortname[3];
Ingo Molnarb5fae122009-09-11 12:12:54 +020018 char *comm;
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020019 int comm_len;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020020};
21
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020022void map_groups__init(struct map_groups *self);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020023int thread__set_comm(struct thread *self, const char *comm);
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020024int thread__comm_len(struct thread *self);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020025struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020026void thread__insert_map(struct thread *self, struct map *map);
27int thread__fork(struct thread *self, struct thread *parent);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020028size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020029size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020030
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030031void maps__insert(struct rb_root *maps, struct map *map);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020032struct map *maps__find(struct rb_root *maps, u64 addr);
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030033
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020034static inline void map_groups__insert(struct map_groups *self, struct map *map)
35{
36 maps__insert(&self->maps[map->type], map);
37}
38
39static 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 Melo95011c62009-11-27 16:29:20 -020045static inline struct map *thread__find_map(struct thread *self,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020046 enum map_type type, u64 addr)
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030047{
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020048 return self ? map_groups__find(&self->mg, type, addr) : NULL;
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020049}
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020050
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020051void thread__find_addr_location(struct thread *self,
52 struct perf_session *session, u8 cpumode,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020053 enum map_type type, u64 addr,
54 struct addr_location *al,
55 symbol_filter_t filter);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020056struct symbol *map_groups__find_symbol(struct map_groups *self,
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020057 struct perf_session *session,
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020058 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 Melo4aa65632009-12-13 19:50:29 -020062map_groups__find_function(struct map_groups *self, struct perf_session *session,
63 u64 addr, symbol_filter_t filter)
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020064{
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020065 return map_groups__find_symbol(self, session, 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 */