thread.h 2.0 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. bool use_modules;
  10. };
  11. struct thread {
  12. struct rb_node rb_node;
  13. struct map_groups mg;
  14. pid_t pid;
  15. char shortname[3];
  16. char *comm;
  17. int comm_len;
  18. };
  19. void map_groups__init(struct map_groups *self);
  20. int thread__set_comm(struct thread *self, const char *comm);
  21. int thread__comm_len(struct thread *self);
  22. struct thread *threads__findnew(pid_t pid);
  23. struct thread *register_idle_thread(void);
  24. void thread__insert_map(struct thread *self, struct map *map);
  25. int thread__fork(struct thread *self, struct thread *parent);
  26. size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
  27. size_t threads__fprintf(FILE *fp);
  28. void maps__insert(struct rb_root *maps, struct map *map);
  29. struct map *maps__find(struct rb_root *maps, u64 addr);
  30. static inline void map_groups__insert(struct map_groups *self, struct map *map)
  31. {
  32. maps__insert(&self->maps[map->type], map);
  33. }
  34. static inline struct map *map_groups__find(struct map_groups *self,
  35. enum map_type type, u64 addr)
  36. {
  37. return maps__find(&self->maps[type], addr);
  38. }
  39. static inline struct map *thread__find_map(struct thread *self,
  40. enum map_type type, u64 addr)
  41. {
  42. return self ? map_groups__find(&self->mg, type, addr) : NULL;
  43. }
  44. void thread__find_addr_location(struct thread *self, u8 cpumode,
  45. enum map_type type, u64 addr,
  46. struct addr_location *al,
  47. symbol_filter_t filter);
  48. struct symbol *map_groups__find_symbol(struct map_groups *self,
  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, u64 addr,
  53. symbol_filter_t filter)
  54. {
  55. return map_groups__find_symbol(self, 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 */