thread.h 2.7 KB

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