annotate.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 nr_histograms;
  40. int sizeof_sym_hist;
  41. };
  42. struct sannotation {
  43. struct annotation annotation;
  44. struct symbol symbol;
  45. };
  46. static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
  47. {
  48. return ((void *)notes->histograms) + (notes->sizeof_sym_hist * idx);
  49. }
  50. static inline struct annotation *symbol__annotation(struct symbol *sym)
  51. {
  52. struct sannotation *a = container_of(sym, struct sannotation, symbol);
  53. return &a->annotation;
  54. }
  55. int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
  56. int evidx, u64 addr);
  57. int symbol__alloc_hist(struct symbol *sym, int nevents);
  58. void symbol__annotate_zero_histograms(struct symbol *sym);
  59. int symbol__annotate(struct symbol *sym, struct map *map,
  60. struct list_head *head, size_t privsize);
  61. int symbol__annotate_printf(struct symbol *sym, struct map *map,
  62. struct list_head *head, int evidx, bool full_paths,
  63. int min_pcnt, int max_lines);
  64. void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
  65. void symbol__annotate_decay_histogram(struct symbol *sym,
  66. struct list_head *head, int evidx);
  67. void objdump_line_list__purge(struct list_head *head);
  68. int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,
  69. bool print_lines, bool full_paths, int min_pcnt,
  70. int max_lines);
  71. #ifdef NO_NEWT_SUPPORT
  72. static inline int symbol__tui_annotate(symbol *sym __used,
  73. struct map *map __used, int evidx __used)
  74. {
  75. return 0;
  76. }
  77. #else
  78. int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx);
  79. #endif
  80. #endif /* __PERF_ANNOTATE_H */