thread.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. struct thread {
  11. struct rb_node rb_node;
  12. struct map_groups mg;
  13. pid_t pid;
  14. char shortname[3];
  15. char *comm;
  16. int comm_len;
  17. };
  18. void map_groups__init(struct map_groups *self);
  19. int thread__set_comm(struct thread *self, const char *comm);
  20. int thread__comm_len(struct thread *self);
  21. struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
  22. void thread__insert_map(struct thread *self, struct map *map);
  23. int thread__fork(struct thread *self, struct thread *parent);
  24. size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
  25. size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
  26. void maps__insert(struct rb_root *maps, struct map *map);
  27. struct map *maps__find(struct rb_root *maps, u64 addr);
  28. static inline void map_groups__insert(struct map_groups *self, struct map *map)
  29. {
  30. maps__insert(&self->maps[map->type], map);
  31. }
  32. static inline struct map *map_groups__find(struct map_groups *self,
  33. enum map_type type, u64 addr)
  34. {
  35. return maps__find(&self->maps[type], addr);
  36. }
  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_location(struct thread *self,
  43. struct perf_session *session, u8 cpumode,
  44. enum map_type type, u64 addr,
  45. struct addr_location *al,
  46. symbol_filter_t filter);
  47. struct symbol *map_groups__find_symbol(struct map_groups *self,
  48. struct perf_session *session,
  49. enum map_type type, u64 addr,
  50. symbol_filter_t filter);
  51. static inline struct symbol *
  52. map_groups__find_function(struct map_groups *self, struct perf_session *session,
  53. u64 addr, symbol_filter_t filter)
  54. {
  55. return map_groups__find_symbol(self, session, MAP__FUNCTION, addr, filter);
  56. }
  57. struct map *map_groups__find_by_name(struct map_groups *self,
  58. enum map_type type, const char *name);
  59. #endif /* __PERF_THREAD_H */