2009-09-24 18:02:18 +02:00
|
|
|
#ifndef __PERF_THREAD_H
|
|
|
|
|
#define __PERF_THREAD_H
|
|
|
|
|
|
2015-04-07 11:59:50 -03:00
|
|
|
#include <linux/atomic.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
#include <linux/rbtree.h>
|
2013-09-11 16:56:44 +02:00
|
|
|
#include <linux/list.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
#include <unistd.h>
|
2012-10-06 15:43:20 -03:00
|
|
|
#include <sys/types.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
#include "symbol.h"
|
2013-11-18 13:32:47 -07:00
|
|
|
#include <strlist.h>
|
2015-03-24 09:52:41 -06:00
|
|
|
#include <intlist.h>
|
2009-08-14 12:21:53 +02:00
|
|
|
|
2014-10-30 16:09:42 +02:00
|
|
|
struct thread_stack;
|
2016-06-03 03:33:12 +00:00
|
|
|
struct unwind_libunwind_ops;
|
2014-10-30 16:09:42 +02:00
|
|
|
|
2009-12-11 14:50:36 -02:00
|
|
|
struct thread {
|
2010-06-17 08:37:44 -03:00
|
|
|
union {
|
|
|
|
|
struct rb_node rb_node;
|
|
|
|
|
struct list_head node;
|
|
|
|
|
};
|
2014-03-21 17:57:01 -03:00
|
|
|
struct map_groups *mg;
|
2013-08-26 16:00:19 +03:00
|
|
|
pid_t pid_; /* Not all tools update this */
|
2013-07-04 16:20:31 +03:00
|
|
|
pid_t tid;
|
2013-05-25 22:47:10 -06:00
|
|
|
pid_t ppid;
|
2014-07-22 16:17:24 +03:00
|
|
|
int cpu;
|
2015-04-07 11:59:50 -03:00
|
|
|
atomic_t refcnt;
|
2009-09-16 17:40:48 +02:00
|
|
|
char shortname[3];
|
2010-02-19 23:02:07 -02:00
|
|
|
bool comm_set;
|
2015-05-15 17:29:56 -03:00
|
|
|
int comm_len;
|
2013-08-14 08:49:27 -06:00
|
|
|
bool dead; /* if set thread has exited */
|
2013-09-11 16:56:44 +02:00
|
|
|
struct list_head comm_list;
|
2014-10-23 13:45:13 +03:00
|
|
|
u64 db_id;
|
2012-09-17 16:31:15 +08:00
|
|
|
|
|
|
|
|
void *priv;
|
2014-10-30 16:09:42 +02:00
|
|
|
struct thread_stack *ts;
|
2016-04-07 09:11:12 +02:00
|
|
|
#ifdef HAVE_LIBUNWIND_SUPPORT
|
2016-06-03 03:33:12 +00:00
|
|
|
void *addr_space;
|
|
|
|
|
struct unwind_libunwind_ops *unwind_libunwind_ops;
|
2016-04-07 09:11:12 +02:00
|
|
|
#endif
|
2009-08-14 12:21:53 +02:00
|
|
|
};
|
|
|
|
|
|
2011-11-28 07:56:39 -02:00
|
|
|
struct machine;
|
2013-09-13 16:28:57 +09:00
|
|
|
struct comm;
|
2010-03-25 19:58:58 -03:00
|
|
|
|
2013-08-26 16:00:19 +03:00
|
|
|
struct thread *thread__new(pid_t pid, pid_t tid);
|
2014-04-09 20:54:29 +02:00
|
|
|
int thread__init_map_groups(struct thread *thread, struct machine *machine);
|
2013-11-05 15:32:36 -03:00
|
|
|
void thread__delete(struct thread *thread);
|
2015-03-02 22:21:35 -03:00
|
|
|
|
|
|
|
|
struct thread *thread__get(struct thread *thread);
|
|
|
|
|
void thread__put(struct thread *thread);
|
|
|
|
|
|
|
|
|
|
static inline void __thread__zput(struct thread **thread)
|
|
|
|
|
{
|
|
|
|
|
thread__put(*thread);
|
|
|
|
|
*thread = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define thread__zput(thread) __thread__zput(&thread)
|
|
|
|
|
|
2013-08-14 08:49:27 -06:00
|
|
|
static inline void thread__exited(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
thread->dead = true;
|
|
|
|
|
}
|
2010-07-30 18:28:42 -03:00
|
|
|
|
2014-07-31 09:00:44 +03:00
|
|
|
int __thread__set_comm(struct thread *thread, const char *comm, u64 timestamp,
|
|
|
|
|
bool exec);
|
|
|
|
|
static inline int thread__set_comm(struct thread *thread, const char *comm,
|
|
|
|
|
u64 timestamp)
|
|
|
|
|
{
|
|
|
|
|
return __thread__set_comm(thread, comm, timestamp, false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-26 12:32:50 -03:00
|
|
|
int thread__set_comm_from_proc(struct thread *thread);
|
|
|
|
|
|
2013-11-05 15:32:36 -03:00
|
|
|
int thread__comm_len(struct thread *thread);
|
2013-09-13 16:28:57 +09:00
|
|
|
struct comm *thread__comm(const struct thread *thread);
|
2014-07-31 09:00:44 +03:00
|
|
|
struct comm *thread__exec_comm(const struct thread *thread);
|
2013-09-11 14:46:56 +02:00
|
|
|
const char *thread__comm_str(const struct thread *thread);
|
2016-06-03 03:33:13 +00:00
|
|
|
int thread__insert_map(struct thread *thread, struct map *map);
|
2013-09-11 16:18:24 +02:00
|
|
|
int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
|
2012-12-07 17:39:39 -03:00
|
|
|
size_t thread__fprintf(struct thread *thread, FILE *fp);
|
2009-09-24 18:02:18 +02:00
|
|
|
|
2016-05-23 17:52:24 -07:00
|
|
|
struct thread *thread__main_thread(struct machine *machine, struct thread *thread);
|
|
|
|
|
|
2014-10-23 12:50:25 -03:00
|
|
|
void thread__find_addr_map(struct thread *thread,
|
2011-11-28 07:56:39 -02:00
|
|
|
u8 cpumode, enum map_type type, u64 addr,
|
2013-08-08 14:32:27 +03:00
|
|
|
struct addr_location *al);
|
2010-01-14 23:45:29 -02:00
|
|
|
|
2014-10-23 12:50:25 -03:00
|
|
|
void thread__find_addr_location(struct thread *thread,
|
2011-11-28 07:56:39 -02:00
|
|
|
u8 cpumode, enum map_type type, u64 addr,
|
2013-08-08 14:32:26 +03:00
|
|
|
struct addr_location *al);
|
2013-06-07 16:22:12 -06:00
|
|
|
|
2014-03-11 16:16:49 -03:00
|
|
|
void thread__find_cpumode_addr_location(struct thread *thread,
|
|
|
|
|
enum map_type type, u64 addr,
|
|
|
|
|
struct addr_location *al);
|
|
|
|
|
|
2013-06-07 16:22:12 -06:00
|
|
|
static inline void *thread__priv(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
return thread->priv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void thread__set_priv(struct thread *thread, void *p)
|
|
|
|
|
{
|
|
|
|
|
thread->priv = p;
|
|
|
|
|
}
|
2013-11-18 13:32:47 -07:00
|
|
|
|
|
|
|
|
static inline bool thread__is_filtered(struct thread *thread)
|
|
|
|
|
{
|
|
|
|
|
if (symbol_conf.comm_list &&
|
|
|
|
|
!strlist__has_entry(symbol_conf.comm_list, thread__comm_str(thread))) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 09:52:41 -06:00
|
|
|
if (symbol_conf.pid_list &&
|
|
|
|
|
!intlist__has_entry(symbol_conf.pid_list, thread->pid_)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (symbol_conf.tid_list &&
|
|
|
|
|
!intlist__has_entry(symbol_conf.tid_list, thread->tid)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-18 13:32:47 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-24 18:02:18 +02:00
|
|
|
#endif /* __PERF_THREAD_H */
|