thread.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __PERF_THREAD_H
  2. #define __PERF_THREAD_H
  3. #include <linux/rbtree.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6. #include "symbol.h"
  7. struct thread {
  8. union {
  9. struct rb_node rb_node;
  10. struct list_head node;
  11. };
  12. struct map_groups mg;
  13. pid_t tid;
  14. pid_t ppid;
  15. char shortname[3];
  16. bool comm_set;
  17. char *comm;
  18. int comm_len;
  19. void *priv;
  20. };
  21. struct machine;
  22. struct thread *thread__new(pid_t tid);
  23. void thread__delete(struct thread *self);
  24. int thread__set_comm(struct thread *self, const char *comm);
  25. int thread__comm_len(struct thread *self);
  26. void thread__insert_map(struct thread *self, struct map *map);
  27. int thread__fork(struct thread *self, struct thread *parent);
  28. size_t thread__fprintf(struct thread *thread, FILE *fp);
  29. static inline struct map *thread__find_map(struct thread *self,
  30. enum map_type type, u64 addr)
  31. {
  32. return self ? map_groups__find(&self->mg, type, addr) : NULL;
  33. }
  34. void thread__find_addr_map(struct thread *thread, struct machine *machine,
  35. u8 cpumode, enum map_type type, u64 addr,
  36. struct addr_location *al);
  37. void thread__find_addr_location(struct thread *thread, struct machine *machine,
  38. u8 cpumode, enum map_type type, u64 addr,
  39. struct addr_location *al,
  40. symbol_filter_t filter);
  41. static inline void *thread__priv(struct thread *thread)
  42. {
  43. return thread->priv;
  44. }
  45. static inline void thread__set_priv(struct thread *thread, void *p)
  46. {
  47. thread->priv = p;
  48. }
  49. #endif /* __PERF_THREAD_H */