annotate.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __PERF_ANNOTATE_H
  2. #define __PERF_ANNOTATE_H
  3. #include <stdbool.h>
  4. #include "types.h"
  5. #include "symbol.h"
  6. #include <linux/list.h>
  7. #include <linux/rbtree.h>
  8. struct objdump_line {
  9. struct list_head node;
  10. s64 offset;
  11. char *line;
  12. };
  13. void objdump_line__free(struct objdump_line *self);
  14. struct objdump_line *objdump__get_next_ip_line(struct list_head *head,
  15. struct objdump_line *pos);
  16. struct sym_hist {
  17. u64 sum;
  18. u64 addr[0];
  19. };
  20. struct source_line {
  21. struct rb_node node;
  22. double percent;
  23. char *path;
  24. };
  25. /** struct annotation - symbols with hits have this attached as in sannotation
  26. *
  27. * @histogram: Array of addr hit histograms per event being monitored
  28. * @src_line: If 'print_lines' is specified, per source code line percentages
  29. *
  30. * src_line is allocated, percentages calculated and all sorted by percentage
  31. * when the annotation is about to be presented, so the percentages are for
  32. * one of the entries in the histogram array, i.e. for the event/counter being
  33. * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
  34. * returns.
  35. */
  36. struct annotation {
  37. struct source_line *src_line;
  38. struct sym_hist *histograms;
  39. int sizeof_sym_hist;
  40. };
  41. struct sannotation {
  42. struct annotation annotation;
  43. struct symbol symbol;
  44. };
  45. static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
  46. {
  47. return ((void *)notes->histograms) + (notes->sizeof_sym_hist * idx);
  48. }
  49. static inline struct annotation *symbol__annotation(struct symbol *sym)
  50. {
  51. struct sannotation *a = container_of(sym, struct sannotation, symbol);
  52. return &a->annotation;
  53. }
  54. int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
  55. int evidx, u64 addr);
  56. int symbol__alloc_hist(struct symbol *sym, int nevents);
  57. int symbol__annotate(struct symbol *sym, struct map *map,
  58. struct list_head *head, size_t privsize);
  59. int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
  60. bool print_lines, bool full_paths, int min_pcnt,
  61. int max_lines);
  62. #ifdef NO_NEWT_SUPPORT
  63. static inline int symbol__tui_annotate(symbol *sym __used,
  64. struct map *map __used, int evidx __used)
  65. {
  66. return 0;
  67. }
  68. #else
  69. int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx);
  70. #endif
  71. #endif /* __PERF_ANNOTATE_H */