thread.h 1.6 KB

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