map.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __PERF_MAP_H
  2. #define __PERF_MAP_H
  3. #include <linux/compiler.h>
  4. #include <linux/list.h>
  5. #include <linux/rbtree.h>
  6. #include <linux/types.h>
  7. enum map_type {
  8. MAP__FUNCTION = 0,
  9. MAP__VARIABLE,
  10. };
  11. #define MAP__NR_TYPES (MAP__VARIABLE + 1)
  12. struct dso;
  13. struct map {
  14. union {
  15. struct rb_node rb_node;
  16. struct list_head node;
  17. };
  18. u64 start;
  19. u64 end;
  20. enum map_type type;
  21. u64 pgoff;
  22. u64 (*map_ip)(struct map *, u64);
  23. u64 (*unmap_ip)(struct map *, u64);
  24. struct dso *dso;
  25. };
  26. static inline u64 map__map_ip(struct map *map, u64 ip)
  27. {
  28. return ip - map->start + map->pgoff;
  29. }
  30. static inline u64 map__unmap_ip(struct map *map, u64 ip)
  31. {
  32. return ip + map->start - map->pgoff;
  33. }
  34. static inline u64 identity__map_ip(struct map *map __used, u64 ip)
  35. {
  36. return ip;
  37. }
  38. struct symbol;
  39. struct mmap_event;
  40. typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym);
  41. void map__init(struct map *self, enum map_type type,
  42. u64 start, u64 end, u64 pgoff, struct dso *dso);
  43. struct map *map__new(struct mmap_event *event, enum map_type,
  44. char *cwd, int cwdlen);
  45. void map__delete(struct map *self);
  46. struct map *map__clone(struct map *self);
  47. int map__overlap(struct map *l, struct map *r);
  48. size_t map__fprintf(struct map *self, FILE *fp);
  49. struct perf_session;
  50. int map__load(struct map *self, struct perf_session *session,
  51. symbol_filter_t filter);
  52. struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
  53. u64 addr, symbol_filter_t filter);
  54. struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
  55. struct perf_session *session,
  56. symbol_filter_t filter);
  57. void map__fixup_start(struct map *self);
  58. void map__fixup_end(struct map *self);
  59. #endif /* __PERF_MAP_H */