sort.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_in;
  42. struct rb_node rb_node;
  43. u64 period;
  44. u64 period_sys;
  45. u64 period_us;
  46. u64 period_guest_sys;
  47. u64 period_guest_us;
  48. struct map_symbol ms;
  49. struct thread *thread;
  50. u64 ip;
  51. s32 cpu;
  52. u32 nr_events;
  53. /* XXX These two should move to some tree widget lib */
  54. u16 row_offset;
  55. u16 nr_rows;
  56. bool init_have_children;
  57. char level;
  58. bool used;
  59. u8 filtered;
  60. struct symbol *parent;
  61. union {
  62. unsigned long position;
  63. struct hist_entry *pair;
  64. struct rb_root sorted_chain;
  65. };
  66. struct callchain_root callchain[0];
  67. };
  68. enum sort_type {
  69. SORT_PID,
  70. SORT_COMM,
  71. SORT_DSO,
  72. SORT_SYM,
  73. SORT_PARENT,
  74. SORT_CPU,
  75. };
  76. /*
  77. * configurable sorting bits
  78. */
  79. struct sort_entry {
  80. struct list_head list;
  81. const char *se_header;
  82. int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
  83. int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
  84. int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
  85. unsigned int width);
  86. u8 se_width_idx;
  87. bool elide;
  88. };
  89. extern struct sort_entry sort_thread;
  90. extern struct list_head hist_entry__sort_list;
  91. void setup_sorting(const char * const usagestr[], const struct option *opts);
  92. extern int sort_dimension__add(const char *);
  93. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  94. const char *list_name, FILE *fp);
  95. #endif /* __PERF_SORT_H */