sort.h 3.3 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 char *field_sep;
  29. extern struct sort_entry sort_comm;
  30. extern struct sort_entry sort_dso;
  31. extern struct sort_entry sort_sym;
  32. extern struct sort_entry sort_parent;
  33. extern enum sort_type sort__first_dimension;
  34. /**
  35. * struct hist_entry - histogram entry
  36. *
  37. * @row_offset - offset from the first callchain expanded to appear on screen
  38. * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
  39. */
  40. struct hist_entry {
  41. struct rb_node rb_node;
  42. u64 period;
  43. u64 period_sys;
  44. u64 period_us;
  45. u64 period_guest_sys;
  46. u64 period_guest_us;
  47. struct map_symbol ms;
  48. struct thread *thread;
  49. u64 ip;
  50. s32 cpu;
  51. u32 nr_events;
  52. /* XXX These two should move to some tree widget lib */
  53. u16 row_offset;
  54. u16 nr_rows;
  55. bool init_have_children;
  56. char level;
  57. u8 filtered;
  58. struct symbol *parent;
  59. union {
  60. unsigned long position;
  61. struct hist_entry *pair;
  62. struct rb_root sorted_chain;
  63. };
  64. struct callchain_root callchain[0];
  65. };
  66. enum sort_type {
  67. SORT_PID,
  68. SORT_COMM,
  69. SORT_DSO,
  70. SORT_SYM,
  71. SORT_PARENT,
  72. SORT_CPU,
  73. };
  74. /*
  75. * configurable sorting bits
  76. */
  77. struct sort_entry {
  78. struct list_head list;
  79. const char *se_header;
  80. int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
  81. int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
  82. int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
  83. unsigned int width);
  84. u8 se_width_idx;
  85. bool elide;
  86. };
  87. extern struct sort_entry sort_thread;
  88. extern struct list_head hist_entry__sort_list;
  89. void setup_sorting(const char * const usagestr[], const struct option *opts);
  90. extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
  91. extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
  92. extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
  93. extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
  94. extern int64_t cmp_null(void *, void *);
  95. extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
  96. extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
  97. extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
  98. extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
  99. extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
  100. extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
  101. int64_t sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right);
  102. extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
  103. extern int sort_dimension__add(const char *);
  104. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  105. const char *list_name, FILE *fp);
  106. #endif /* __PERF_SORT_H */