blob: 0a28f39de545f5810893fe44b87af0f895000037 [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];
Arnaldo Carvalho de Melofaa5c5c2010-02-19 23:02:07 -020018 bool comm_set;
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 Melob3165f42009-12-13 19:50:28 -020026struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020027void thread__insert_map(struct thread *self, struct map *map);
28int thread__fork(struct thread *self, struct thread *parent);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020029size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020030size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020031
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030032void maps__insert(struct rb_root *maps, struct map *map);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020033struct map *maps__find(struct rb_root *maps, u64 addr);
Arnaldo Carvalho de Melo439d4732009-10-02 03:29:58 -030034
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020035static inline void map_groups__insert(struct map_groups *self, struct map *map)
36{
37 maps__insert(&self->maps[map->type], map);
38}
39
40static inline struct map *map_groups__find(struct map_groups *self,
41 enum map_type type, u64 addr)
42{
43 return maps__find(&self->maps[type], addr);
44}
45
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020046static inline struct map *thread__find_map(struct thread *self,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020047 enum map_type type, u64 addr)
Arnaldo Carvalho de Melo1b46cdd2009-09-28 14:48:46 -030048{
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020049 return self ? map_groups__find(&self->mg, type, addr) : NULL;
Arnaldo Carvalho de Melo95011c62009-11-27 16:29:20 -020050}
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020051
Arnaldo Carvalho de Melo59ee68e2010-01-14 23:45:29 -020052void thread__find_addr_map(struct thread *self,
53 struct perf_session *session, u8 cpumode,
54 enum map_type type, u64 addr,
55 struct addr_location *al);
56
Arnaldo Carvalho de Melo4aa65632009-12-13 19:50:29 -020057void thread__find_addr_location(struct thread *self,
58 struct perf_session *session, u8 cpumode,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020059 enum map_type type, u64 addr,
60 struct addr_location *al,
61 symbol_filter_t filter);
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020062struct symbol *map_groups__find_symbol(struct map_groups *self,
63 enum map_type type, u64 addr,
64 symbol_filter_t filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020065
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020066static inline struct symbol *map_groups__find_function(struct map_groups *self,
67 u64 addr,
68 symbol_filter_t filter)
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020069{
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020070 return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020071}
Arnaldo Carvalho de Melo79406cd2009-12-11 18:50:22 -020072
73struct map *map_groups__find_by_name(struct map_groups *self,
74 enum map_type type, const char *name);
Arnaldo Carvalho de Melob7cece72010-01-13 13:22:17 -020075
76int __map_groups__create_kernel_maps(struct map_groups *self,
77 struct map *vmlinux_maps[MAP__NR_TYPES],
78 struct dso *kernel);
Arnaldo Carvalho de Melo9de89fe2010-02-03 16:52:00 -020079int map_groups__create_kernel_maps(struct map_groups *self,
80 struct map *vmlinux_maps[MAP__NR_TYPES]);
81
82struct map *map_groups__new_module(struct map_groups *self, u64 start,
83 const char *filename);
John Kacur8b40f522009-09-24 18:02:18 +020084#endif /* __PERF_THREAD_H */