blob: d7574101054a8ae9b6ded40fd0a813c3cacf9965 [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 thread {
Arnaldo Carvalho de Melo720a3ae2010-06-17 08:37:44 -03009 union {
10 struct rb_node rb_node;
11 struct list_head node;
12 };
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020013 struct map_groups mg;
14 pid_t pid;
Ingo Molnar0ec04e12009-09-16 17:40:48 +020015 char shortname[3];
Arnaldo Carvalho de Melofaa5c5c2010-02-19 23:02:07 -020016 bool comm_set;
Ingo Molnarb5fae122009-09-11 12:12:54 +020017 char *comm;
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020018 int comm_len;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020019};
20
Arnaldo Carvalho de Melo5c98d4662011-01-03 17:53:33 -020021struct thread_map {
22 int nr;
23 int map[];
24};
25
Arnaldo Carvalho de Melo4b8cf842010-03-25 19:58:58 -030026struct perf_session;
27
Arnaldo Carvalho de Melo591765f2010-07-30 18:28:42 -030028void thread__delete(struct thread *self);
29
Arnaldo Carvalho de Melo5c98d4662011-01-03 17:53:33 -020030struct thread_map *thread_map__new_by_pid(pid_t pid);
31struct thread_map *thread_map__new_by_tid(pid_t tid);
32struct thread_map *thread_map__new(pid_t pid, pid_t tid);
33
34static inline void thread_map__delete(struct thread_map *threads)
35{
36 free(threads);
37}
38
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020039int thread__set_comm(struct thread *self, const char *comm);
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020040int thread__comm_len(struct thread *self);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020041struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020042void thread__insert_map(struct thread *self, struct map *map);
43int thread__fork(struct thread *self, struct thread *parent);
Arnaldo Carvalho de Melob3165f42009-12-13 19:50:28 -020044size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020045
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,
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080054 enum map_type type, pid_t pid, u64 addr,
Arnaldo Carvalho de Melo59ee68e2010-01-14 23:45:29 -020055 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,
Zhang, Yanmina1645ce2010-04-19 13:32:50 +080059 enum map_type type, pid_t pid, u64 addr,
Arnaldo Carvalho de Melo1ed091c2009-11-27 16:29:23 -020060 struct addr_location *al,
61 symbol_filter_t filter);
John Kacur8b40f522009-09-24 18:02:18 +020062#endif /* __PERF_THREAD_H */