blob: 3c0c2724f82c718dc02153acaf08b9a46bbac5ce [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 Weisbecker1902efe2013-09-11 16:56:44 +02005#include <linux/list.h>
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +02006#include <unistd.h>
Arnaldo Carvalho de Melo9d2f8e22012-10-06 15:43:20 -03007#include <sys/types.h>
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +02008#include "symbol.h"
David Ahern1f3878c2013-11-18 13:32:47 -07009#include <strlist.h>
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020010
Arnaldo Carvalho de Melo9958e1f2009-12-11 14:50:36 -020011struct thread {
Arnaldo Carvalho de Melo720a3ae2010-06-17 08:37:44 -030012 union {
13 struct rb_node rb_node;
14 struct list_head node;
15 };
Arnaldo Carvalho de Melo93d57312014-03-21 17:57:01 -030016 struct map_groups *mg;
Adrian Hunter99d725f2013-08-26 16:00:19 +030017 pid_t pid_; /* Not all tools update this */
Adrian Hunter38051232013-07-04 16:20:31 +030018 pid_t tid;
David Ahern70c57ef2013-05-25 22:47:10 -060019 pid_t ppid;
Ingo Molnar0ec04e12009-09-16 17:40:48 +020020 char shortname[3];
Arnaldo Carvalho de Melofaa5c5c2010-02-19 23:02:07 -020021 bool comm_set;
David Ahern236a3bb2013-08-14 08:49:27 -060022 bool dead; /* if set thread has exited */
Frederic Weisbecker1902efe2013-09-11 16:56:44 +020023 struct list_head comm_list;
Frederic Weisbeckera4fb5812009-10-22 23:23:23 +020024 int comm_len;
Xiao Guangrongbcf6edc2012-09-17 16:31:15 +080025
26 void *priv;
Frederic Weisbecker6baa0a52009-08-14 12:21:53 +020027};
28
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020029struct machine;
Namhyung Kim4dfced32013-09-13 16:28:57 +090030struct comm;
Arnaldo Carvalho de Melo4b8cf842010-03-25 19:58:58 -030031
Adrian Hunter99d725f2013-08-26 16:00:19 +030032struct thread *thread__new(pid_t pid, pid_t tid);
Jiri Olsacddcef62014-04-09 20:54:29 +020033int thread__init_map_groups(struct thread *thread, struct machine *machine);
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030034void thread__delete(struct thread *thread);
David Ahern236a3bb2013-08-14 08:49:27 -060035static inline void thread__exited(struct thread *thread)
36{
37 thread->dead = true;
38}
Arnaldo Carvalho de Melo591765f2010-07-30 18:28:42 -030039
Frederic Weisbecker162f0be2013-09-11 16:18:24 +020040int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp);
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030041int thread__comm_len(struct thread *thread);
Namhyung Kim4dfced32013-09-13 16:28:57 +090042struct comm *thread__comm(const struct thread *thread);
Frederic Weisbeckerb9c51432013-09-11 14:46:56 +020043const char *thread__comm_str(const struct thread *thread);
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -030044void thread__insert_map(struct thread *thread, struct map *map);
Frederic Weisbecker162f0be2013-09-11 16:18:24 +020045int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
Arnaldo Carvalho de Melo3f067dc2012-12-07 17:39:39 -030046size_t thread__fprintf(struct thread *thread, FILE *fp);
John Kacur8b40f522009-09-24 18:02:18 +020047
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020048void thread__find_addr_map(struct thread *thread, struct machine *machine,
49 u8 cpumode, enum map_type type, u64 addr,
Adrian Hunter326f59b2013-08-08 14:32:27 +030050 struct addr_location *al);
Arnaldo Carvalho de Melo59ee68e2010-01-14 23:45:29 -020051
Arnaldo Carvalho de Melo743eb862011-11-28 07:56:39 -020052void thread__find_addr_location(struct thread *thread, struct machine *machine,
53 u8 cpumode, enum map_type type, u64 addr,
Adrian Hunter61710bd2013-08-08 14:32:26 +030054 struct addr_location *al);
David Ahernba580412013-06-07 16:22:12 -060055
Arnaldo Carvalho de Melo52a3cb82014-03-11 16:16:49 -030056void thread__find_cpumode_addr_location(struct thread *thread,
57 struct machine *machine,
58 enum map_type type, u64 addr,
59 struct addr_location *al);
60
David Ahernba580412013-06-07 16:22:12 -060061static inline void *thread__priv(struct thread *thread)
62{
63 return thread->priv;
64}
65
66static inline void thread__set_priv(struct thread *thread, void *p)
67{
68 thread->priv = p;
69}
David Ahern1f3878c2013-11-18 13:32:47 -070070
71static inline bool thread__is_filtered(struct thread *thread)
72{
73 if (symbol_conf.comm_list &&
74 !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) {
75 return true;
76 }
77
78 return false;
79}
80
John Kacur8b40f522009-09-24 18:02:18 +020081#endif /* __PERF_THREAD_H */