thread.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 map_groups {
  7. struct rb_root maps[MAP__NR_TYPES];
  8. struct list_head removed_maps[MAP__NR_TYPES];
  9. };
  10. size_t __map_groups__fprintf_maps(struct map_groups *self,
  11. enum map_type type, FILE *fp);
  12. struct thread {
  13. struct rb_node rb_node;
  14. struct map_groups mg;
  15. pid_t pid;
  16. char shortname[3];
  17. bool comm_set;
  18. char *comm;
  19. int comm_len;
  20. };
  21. int find_all_tid(int pid, pid_t ** all_tid);
  22. void map_groups__init(struct map_groups *self);
  23. int thread__set_comm(struct thread *self, const char *comm);
  24. int thread__comm_len(struct thread *self);
  25. struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
  26. void thread__insert_map(struct thread *self, struct map *map);
  27. int thread__fork(struct thread *self, struct thread *parent);
  28. size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
  29. size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
  30. void maps__insert(struct rb_root *maps, struct map *map);
  31. struct map *maps__find(struct rb_root *maps, u64 addr);
  32. static inline void map_groups__insert(struct map_groups *self, struct map *map)
  33. {
  34. maps__insert(&self->maps[map->type], map);
  35. }
  36. static inline struct map *map_groups__find(struct map_groups *self,
  37. enum map_type type, u64 addr)
  38. {
  39. return maps__find(&self->maps[type], addr);
  40. }
  41. static inline struct map *thread__find_map(struct thread *self,
  42. enum map_type type, u64 addr)
  43. {
  44. return self ? map_groups__find(&self->mg, type, addr) : NULL;
  45. }
  46. void thread__find_addr_map(struct thread *self,
  47. struct perf_session *session, u8 cpumode,
  48. enum map_type type, u64 addr,
  49. struct addr_location *al);
  50. void thread__find_addr_location(struct thread *self,
  51. struct perf_session *session, u8 cpumode,
  52. enum map_type type, u64 addr,
  53. struct addr_location *al,
  54. symbol_filter_t filter);
  55. struct symbol *map_groups__find_symbol(struct map_groups *self,
  56. enum map_type type, u64 addr,
  57. symbol_filter_t filter);
  58. static inline struct symbol *map_groups__find_function(struct map_groups *self,
  59. u64 addr,
  60. symbol_filter_t filter)
  61. {
  62. return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
  63. }
  64. struct map *map_groups__find_by_name(struct map_groups *self,
  65. enum map_type type, const char *name);
  66. int __map_groups__create_kernel_maps(struct map_groups *self,
  67. struct map *vmlinux_maps[MAP__NR_TYPES],
  68. struct dso *kernel);
  69. int map_groups__create_kernel_maps(struct map_groups *self,
  70. struct map *vmlinux_maps[MAP__NR_TYPES]);
  71. struct map *map_groups__new_module(struct map_groups *self, u64 start,
  72. const char *filename);
  73. #endif /* __PERF_THREAD_H */