blob: dcf70303e58ee3a98675ad156d46658e67d1d1ec [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
Arnaldo Carvalho de Melo65f2ed22010-03-09 15:58:17 -030013size_t __map_groups__fprintf_maps(struct map_groups *self,
14 enum map_type type, FILE *fp);
15
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020016struct thread {
17 struct rb_node rb_node;
18 struct map_groups mg;
19 pid_t pid;
Ingo Molnar0ec04e12009-09-16 17:40:48 +020020 char shortname[3];
Arnaldo Carvalho de Melofaa5c5c2010-02-19 23:02:07 -020021 bool comm_set;
Ingo Molnarb5fae122009-09-11 12:12:54 +020022 char *comm;
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020023 int comm_len;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020024};
25
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020026void map_groups__init(struct map_groups *self);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020027int thread__set_comm(struct thread *self, const char *comm);
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020028int thread__comm_len(struct thread *self);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020029struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020030void thread__insert_map(struct thread *self, struct map *map);
31int thread__fork(struct thread *self, struct thread *parent);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020032size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020033size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020034
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030035void maps__insert(struct rb_root *maps, struct map *map);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020036struct map *maps__find(struct rb_root *maps, u64 addr);
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030037
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020038static inline void map_groups__insert(struct map_groups *self, struct map *map)
39{
40 maps__insert(&self->maps[map->type], map);
41}
42
43static inline struct map *map_groups__find(struct map_groups *self,
44 enum map_type type, u64 addr)
45{
46 return maps__find(&self->maps[type], addr);
47}
48
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020049static inline struct map *thread__find_map(struct thread *self,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020050 enum map_type type, u64 addr)
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030051{
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020052 return self ? map_groups__find(&self->mg, type, addr) : NULL;
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020053}
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020054
Arnaldo Carvalho de Melo59ee68e2010-01-14 23:45:29 -020055void thread__find_addr_map(struct thread *self,
56 struct perf_session *session, u8 cpumode,
57 enum map_type type, u64 addr,
58 struct addr_location *al);
59
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020060void thread__find_addr_location(struct thread *self,
61 struct perf_session *session, u8 cpumode,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020062 enum map_type type, u64 addr,
63 struct addr_location *al,
64 symbol_filter_t filter);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020065struct symbol *map_groups__find_symbol(struct map_groups *self,
66 enum map_type type, u64 addr,
67 symbol_filter_t filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020068
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020069static inline struct symbol *map_groups__find_function(struct map_groups *self,
70 u64 addr,
71 symbol_filter_t filter)
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020072{
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020073 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020074}
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020075
76struct map *map_groups__find_by_name(struct map_groups *self,
77 enum map_type type, const char *name);
Arnaldo Carvalho de Melob7cece72010-01-13 13:22:17 -020078
79int __map_groups__create_kernel_maps(struct map_groups *self,
80 struct map *vmlinux_maps[MAP__NR_TYPES],
81 struct dso *kernel);
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020082int map_groups__create_kernel_maps(struct map_groups *self,
83 struct map *vmlinux_maps[MAP__NR_TYPES]);
84
85struct map *map_groups__new_module(struct map_groups *self, u64 start,
86 const char *filename);
John Kacur8b40f522009-09-24 18:02:18 +020087#endif /* __PERF_THREAD_H */