perf tools: Add new COMM infrastructure
[deliverable/linux.git] / tools / perf / util / thread.h
CommitLineData
8b40f521
JK
1#ifndef __PERF_THREAD_H
2#define __PERF_THREAD_H
3
6baa0a5a 4#include <linux/rbtree.h>
1902efe7 5#include <linux/list.h>
6baa0a5a 6#include <unistd.h>
9d2f8e22 7#include <sys/types.h>
6baa0a5a
FW
8#include "symbol.h"
9
9958e1f0 10struct thread {
720a3aeb
ACM
11 union {
12 struct rb_node rb_node;
13 struct list_head node;
14 };
9958e1f0 15 struct map_groups mg;
99d725fc 16 pid_t pid_; /* Not all tools update this */
38051234 17 pid_t tid;
70c57efb 18 pid_t ppid;
0ec04e16 19 char shortname[3];
faa5c5c3 20 bool comm_set;
236a3bbd 21 bool dead; /* if set thread has exited */
1902efe7 22 struct list_head comm_list;
a4fb581b 23 int comm_len;
bcf6edcd
XG
24
25 void *priv;
6baa0a5a
FW
26};
27
743eb868 28struct machine;
4b8cf846 29
99d725fc 30struct thread *thread__new(pid_t pid, pid_t tid);
591765fd 31void thread__delete(struct thread *self);
236a3bbd
DA
32static inline void thread__exited(struct thread *thread)
33{
34 thread->dead = true;
35}
591765fd 36
162f0bef 37int thread__set_comm(struct thread *thread, const char *comm, u64 timestamp);
a4fb581b 38int thread__comm_len(struct thread *self);
b9c5143a 39const char *thread__comm_str(const struct thread *thread);
6baa0a5a 40void thread__insert_map(struct thread *self, struct map *map);
162f0bef 41int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp);
3f067dca 42size_t thread__fprintf(struct thread *thread, FILE *fp);
8b40f521 43
9958e1f0
ACM
44static inline struct map *thread__find_map(struct thread *self,
45 enum map_type type, u64 addr)
95011c60 46{
9958e1f0 47 return self ? map_groups__find(&self->mg, type, addr) : NULL;
95011c60 48}
1ed091c4 49
743eb868
ACM
50void thread__find_addr_map(struct thread *thread, struct machine *machine,
51 u8 cpumode, enum map_type type, u64 addr,
326f59bf 52 struct addr_location *al);
59ee68ec 53
743eb868
ACM
54void thread__find_addr_location(struct thread *thread, struct machine *machine,
55 u8 cpumode, enum map_type type, u64 addr,
61710bde 56 struct addr_location *al);
ba58041a
DA
57
58static inline void *thread__priv(struct thread *thread)
59{
60 return thread->priv;
61}
62
63static inline void thread__set_priv(struct thread *thread, void *p)
64{
65 thread->priv = p;
66}
8b40f521 67#endif /* __PERF_THREAD_H */
This page took 0.18143 seconds and 5 git commands to generate.