sort.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef __PERF_SORT_H
  2. #define __PERF_SORT_H
  3. #include "../builtin.h"
  4. #include "util.h"
  5. #include "color.h"
  6. #include <linux/list.h>
  7. #include "cache.h"
  8. #include <linux/rbtree.h>
  9. #include "symbol.h"
  10. #include "string.h"
  11. #include "callchain.h"
  12. #include "strlist.h"
  13. #include "values.h"
  14. #include "../perf.h"
  15. #include "debug.h"
  16. #include "header.h"
  17. #include "parse-options.h"
  18. #include "parse-events.h"
  19. #include "thread.h"
  20. #include "sort.h"
  21. extern regex_t parent_regex;
  22. extern const char *sort_order;
  23. extern const char default_parent_pattern[];
  24. extern const char *parent_pattern;
  25. extern const char default_sort_order[];
  26. extern int sort__need_collapse;
  27. extern int sort__has_parent;
  28. extern int sort__branch_mode;
  29. extern char *field_sep;
  30. extern struct sort_entry sort_comm;
  31. extern struct sort_entry sort_dso;
  32. extern struct sort_entry sort_sym;
  33. extern struct sort_entry sort_parent;
  34. extern struct sort_entry sort_dso_from;
  35. extern struct sort_entry sort_dso_to;
  36. extern struct sort_entry sort_sym_from;
  37. extern struct sort_entry sort_sym_to;
  38. extern enum sort_type sort__first_dimension;
  39. /**
  40. * struct hist_entry - histogram entry
  41. *
  42. * @row_offset - offset from the first callchain expanded to appear on screen
  43. * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
  44. */
  45. struct hist_entry {
  46. struct rb_node rb_node_in;
  47. struct rb_node rb_node;
  48. u64 period;
  49. u64 period_sys;
  50. u64 period_us;
  51. u64 period_guest_sys;
  52. u64 period_guest_us;
  53. struct map_symbol ms;
  54. struct thread *thread;
  55. u64 ip;
  56. s32 cpu;
  57. u32 nr_events;
  58. /* XXX These two should move to some tree widget lib */
  59. u16 row_offset;
  60. u16 nr_rows;
  61. bool init_have_children;
  62. char level;
  63. bool used;
  64. u8 filtered;
  65. char *srcline;
  66. struct symbol *parent;
  67. union {
  68. unsigned long position;
  69. struct hist_entry *pair;
  70. struct rb_root sorted_chain;
  71. };
  72. struct branch_info *branch_info;
  73. struct callchain_root callchain[0];
  74. };
  75. enum sort_type {
  76. SORT_PID,
  77. SORT_COMM,
  78. SORT_DSO,
  79. SORT_SYM,
  80. SORT_PARENT,
  81. SORT_CPU,
  82. SORT_DSO_FROM,
  83. SORT_DSO_TO,
  84. SORT_SYM_FROM,
  85. SORT_SYM_TO,
  86. SORT_MISPREDICT,
  87. SORT_SRCLINE,
  88. };
  89. /*
  90. * configurable sorting bits
  91. */
  92. struct sort_entry {
  93. struct list_head list;
  94. const char *se_header;
  95. int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
  96. int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
  97. int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
  98. unsigned int width);
  99. u8 se_width_idx;
  100. bool elide;
  101. };
  102. extern struct sort_entry sort_thread;
  103. extern struct list_head hist_entry__sort_list;
  104. void setup_sorting(const char * const usagestr[], const struct option *opts);
  105. extern int sort_dimension__add(const char *);
  106. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  107. const char *list_name, FILE *fp);
  108. #endif /* __PERF_SORT_H */