Commit | Line | Data |
---|---|---|
8b40f521 JK |
1 | #ifndef __PERF_THREAD_H |
2 | #define __PERF_THREAD_H | |
3 | ||
e1ed3a5b | 4 | #include <linux/atomic.h> |
6baa0a5a | 5 | #include <linux/rbtree.h> |
1902efe7 | 6 | #include <linux/list.h> |
6baa0a5a | 7 | #include <unistd.h> |
9d2f8e22 | 8 | #include <sys/types.h> |
6baa0a5a | 9 | #include "symbol.h" |
1f3878c1 | 10 | #include <strlist.h> |
e03eaa40 | 11 | #include <intlist.h> |
e583d70c JO |
12 | #ifdef HAVE_LIBUNWIND_SUPPORT |
13 | #include <libunwind.h> | |
14 | #endif | |
6baa0a5a | 15 | |
00447ccd AH |
16 | struct thread_stack; |
17 | ||
9958e1f0 | 18 | struct thread { |
720a3aeb ACM |
19 | union { |
20 | struct rb_node rb_node; | |
21 | struct list_head node; | |
22 | }; | |
93d5731d | 23 | struct map_groups *mg; |
99d725fc | 24 | pid_t pid_; /* Not all tools update this */ |
38051234 | 25 | pid_t tid; |
70c57efb | 26 | pid_t ppid; |
bf49c35f | 27 | int cpu; |
e1ed3a5b | 28 | atomic_t refcnt; |
0ec04e16 | 29 | char shortname[3]; |
faa5c5c3 | 30 | bool comm_set; |
86066064 | 31 | int comm_len; |
236a3bbd | 32 | bool dead; /* if set thread has exited */ |
1902efe7 | 33 | struct list_head comm_list; |
0db15b1e | 34 | u64 db_id; |
bcf6edcd XG |
35 | |
36 | void *priv; | |
00447ccd | 37 | struct thread_stack *ts; |
e583d70c JO |
38 | #ifdef HAVE_LIBUNWIND_SUPPORT |
39 | unw_addr_space_t addr_space; | |
40 | #endif | |
6baa0a5a FW |
41 | }; |
42 | ||
743eb868 | 43 | struct machine; |
4dfced35 | 44 | struct comm; |
4b8cf846 | 45 | |
99d725fc | 46 | struct thread *thread__new(pid_t pid, pid_t tid); |
cddcef60 | 47 | int thread__init_map_groups(struct thread *thread, struct machine *machine); |
316c7136 | 48 | void thread__delete(struct thread *thread); |
f3b623b8 ACM |
49 | |
50 | struct thread *thread__get(struct thread *thread); | |
51 | void thread__put(struct thread *thread); | |
52 | ||
53 | static inline void __thread__zput(struct thread **thread) | |
54 | { | |
55 | thread__put(*thread); | |
56 | *thread = NULL; | |
57 | } | |
58 | ||
59 | #define thread__zput(thread) __thread__zput(&thread) | |
60 | ||
236a3bbd DA |
61 | static inline void thread__exited(struct thread *thread) |
62 | { | |
63 | thread->dead = true; | |
64 | } | |
591765fd | 65 | |
65de51f9 AH |
66 | int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp, |
67 | bool exec); | |
68 | static inline int thread__set_comm(struct thread *thread, const char *comm, | |
69 | u64 timestamp) | |
70 | { | |
71 | return __thread__set_comm(thread, comm, timestamp, false); | |
72 | } | |
73 | ||
2f3027ac ACM |
74 | int thread__set_comm_from_proc(struct thread *thread); |
75 | ||
316c7136 | 76 | int thread__comm_len(struct thread *thread); |
4dfced35 | 77 | struct comm *thread__comm(const struct thread *thread); |
65de51f9 | 78 | struct comm *thread__exec_comm(const struct thread *thread); |
b9c5143a | 79 | const char *thread__comm_str(const struct thread *thread); |
316c7136 | 80 | void thread__insert_map(struct thread *thread, struct map *map); |
162f0bef | 81 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp); |
3f067dca | 82 | size_t thread__fprintf(struct thread *thread, FILE *fp); |
8b40f521 | 83 | |
bb871a9c | 84 | void thread__find_addr_map(struct thread *thread, |
743eb868 | 85 | u8 cpumode, enum map_type type, u64 addr, |
326f59bf | 86 | struct addr_location *al); |
59ee68ec | 87 | |
bb871a9c | 88 | void thread__find_addr_location(struct thread *thread, |
743eb868 | 89 | u8 cpumode, enum map_type type, u64 addr, |
61710bde | 90 | struct addr_location *al); |
ba58041a | 91 | |
52a3cb8c | 92 | void thread__find_cpumode_addr_location(struct thread *thread, |
52a3cb8c ACM |
93 | enum map_type type, u64 addr, |
94 | struct addr_location *al); | |
95 | ||
ba58041a DA |
96 | static inline void *thread__priv(struct thread *thread) |
97 | { | |
98 | return thread->priv; | |
99 | } | |
100 | ||
101 | static inline void thread__set_priv(struct thread *thread, void *p) | |
102 | { | |
103 | thread->priv = p; | |
104 | } | |
1f3878c1 DA |
105 | |
106 | static inline bool thread__is_filtered(struct thread *thread) | |
107 | { | |
108 | if (symbol_conf.comm_list && | |
109 | !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) { | |
110 | return true; | |
111 | } | |
112 | ||
e03eaa40 DA |
113 | if (symbol_conf.pid_list && |
114 | !intlist__has_entry(symbol_conf.pid_list, thread->pid_)) { | |
115 | return true; | |
116 | } | |
117 | ||
118 | if (symbol_conf.tid_list && | |
119 | !intlist__has_entry(symbol_conf.tid_list, thread->tid)) { | |
120 | return true; | |
121 | } | |
122 | ||
1f3878c1 DA |
123 | return false; |
124 | } | |
125 | ||
8b40f521 | 126 | #endif /* __PERF_THREAD_H */ |