sort.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 char *sort_order;
  23. extern char default_parent_pattern[];
  24. extern char *parent_pattern;
  25. extern 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 unsigned int dsos__col_width;
  34. extern unsigned int comms__col_width;
  35. extern unsigned int threads__col_width;
  36. extern enum sort_type sort__first_dimension;
  37. struct hist_entry {
  38. struct rb_node rb_node;
  39. u64 count;
  40. u64 count_sys;
  41. u64 count_us;
  42. u64 count_guest_sys;
  43. u64 count_guest_us;
  44. /*
  45. * XXX WARNING!
  46. * thread _has_ to come after ms, see
  47. * hist_browser__selected_thread in util/newt.c
  48. */
  49. struct map_symbol ms;
  50. struct thread *thread;
  51. u64 ip;
  52. char level;
  53. u8 filtered;
  54. struct symbol *parent;
  55. union {
  56. unsigned long position;
  57. struct hist_entry *pair;
  58. struct rb_root sorted_chain;
  59. };
  60. struct callchain_node callchain[0];
  61. };
  62. enum sort_type {
  63. SORT_PID,
  64. SORT_COMM,
  65. SORT_DSO,
  66. SORT_SYM,
  67. SORT_PARENT
  68. };
  69. /*
  70. * configurable sorting bits
  71. */
  72. struct sort_entry {
  73. struct list_head list;
  74. const char *se_header;
  75. int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
  76. int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
  77. int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
  78. unsigned int width);
  79. unsigned int *se_width;
  80. bool elide;
  81. };
  82. extern struct sort_entry sort_thread;
  83. extern struct list_head hist_entry__sort_list;
  84. void setup_sorting(const char * const usagestr[], const struct option *opts);
  85. extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
  86. extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
  87. extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
  88. extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
  89. extern int64_t cmp_null(void *, void *);
  90. extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
  91. extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
  92. extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
  93. extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
  94. extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
  95. extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
  96. extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
  97. extern int sort_dimension__add(const char *);
  98. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  99. const char *list_name, FILE *fp);
  100. #endif /* __PERF_SORT_H */