1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_THREAD_H
3 #define __PERF_THREAD_H
5 #include <linux/refcount.h>
6 #include <linux/rbtree.h>
7 #include <linux/list.h>
10 #include <sys/types.h>
12 #include "symbol_conf.h"
19 struct namespaces_event;
21 struct unwind_libunwind_ops;
25 struct rb_node rb_node;
26 struct list_head node;
28 struct map_groups *mg;
29 pid_t pid_; /* Not all tools update this */
36 bool dead; /* if set thread has exited */
37 struct list_head namespaces_list;
38 struct rw_semaphore namespaces_lock;
39 struct list_head comm_list;
40 struct rw_semaphore comm_lock;
44 struct thread_stack *ts;
45 struct nsinfo *nsinfo;
46 struct srccode_state srccode_state;
47 #ifdef HAVE_LIBUNWIND_SUPPORT
49 struct unwind_libunwind_ops *unwind_libunwind_ops;
52 int filter_entry_depth;
59 struct thread *thread__new(pid_t pid, pid_t tid);
60 int thread__init_map_groups(struct thread *thread, struct machine *machine);
61 void thread__delete(struct thread *thread);
63 struct thread *thread__get(struct thread *thread);
64 void thread__put(struct thread *thread);
66 static inline void __thread__zput(struct thread **thread)
72 #define thread__zput(thread) __thread__zput(&thread)
74 static inline void thread__exited(struct thread *thread)
79 struct namespaces *thread__namespaces(struct thread *thread);
80 int thread__set_namespaces(struct thread *thread, u64 timestamp,
81 struct namespaces_event *event);
83 int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp,
85 static inline int thread__set_comm(struct thread *thread, const char *comm,
88 return __thread__set_comm(thread, comm, timestamp, false);
91 int thread__set_comm_from_proc(struct thread *thread);
93 int thread__comm_len(struct thread *thread);
94 struct comm *thread__comm(const struct thread *thread);
95 struct comm *thread__exec_comm(const struct thread *thread);
96 const char *thread__comm_str(struct thread *thread);
97 int thread__insert_map(struct thread *thread, struct map *map);
98 int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone);
99 size_t thread__fprintf(struct thread *thread, FILE *fp);
101 struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
103 struct map *thread__find_map(struct thread *thread, u8 cpumode, u64 addr,
104 struct addr_location *al);
105 struct map *thread__find_map_fb(struct thread *thread, u8 cpumode, u64 addr,
106 struct addr_location *al);
108 struct symbol *thread__find_symbol(struct thread *thread, u8 cpumode,
109 u64 addr, struct addr_location *al);
110 struct symbol *thread__find_symbol_fb(struct thread *thread, u8 cpumode,
111 u64 addr, struct addr_location *al);
113 void thread__find_cpumode_addr_location(struct thread *thread, u64 addr,
114 struct addr_location *al);
116 int thread__memcpy(struct thread *thread, struct machine *machine,
117 void *buf, u64 ip, int len, bool *is64bit);
119 static inline void *thread__priv(struct thread *thread)
124 static inline void thread__set_priv(struct thread *thread, void *p)
129 static inline bool thread__is_filtered(struct thread *thread)
131 if (symbol_conf.comm_list &&
132 !strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) {
136 if (symbol_conf.pid_list &&
137 !intlist__has_entry(symbol_conf.pid_list, thread->pid_)) {
141 if (symbol_conf.tid_list &&
142 !intlist__has_entry(symbol_conf.tid_list, thread->tid)) {
149 #endif /* __PERF_THREAD_H */