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