sort.h 3.2 KB

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