sort.h 3.0 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 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 period;
  40. u64 period_sys;
  41. u64 period_us;
  42. u64 period_guest_sys;
  43. u64 period_guest_us;
  44. struct map_symbol ms;
  45. struct thread *thread;
  46. u64 ip;
  47. u32 nr_events;
  48. char level;
  49. u8 filtered;
  50. struct symbol *parent;
  51. union {
  52. unsigned long position;
  53. struct hist_entry *pair;
  54. struct rb_root sorted_chain;
  55. };
  56. struct callchain_node callchain[0];
  57. };
  58. enum sort_type {
  59. SORT_PID,
  60. SORT_COMM,
  61. SORT_DSO,
  62. SORT_SYM,
  63. SORT_PARENT
  64. };
  65. /*
  66. * configurable sorting bits
  67. */
  68. struct sort_entry {
  69. struct list_head list;
  70. const char *se_header;
  71. int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
  72. int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
  73. int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
  74. unsigned int width);
  75. unsigned int *se_width;
  76. bool elide;
  77. };
  78. extern struct sort_entry sort_thread;
  79. extern struct list_head hist_entry__sort_list;
  80. void setup_sorting(const char * const usagestr[], const struct option *opts);
  81. extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
  82. extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
  83. extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
  84. extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
  85. extern int64_t cmp_null(void *, void *);
  86. extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
  87. extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
  88. extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
  89. extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
  90. extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
  91. extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
  92. extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
  93. extern int sort_dimension__add(const char *);
  94. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  95. const char *list_name, FILE *fp);
  96. #endif /* __PERF_SORT_H */