sort.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. struct thread *thread;
  41. struct map *map;
  42. struct symbol *sym;
  43. u64 ip;
  44. char level;
  45. struct symbol *parent;
  46. struct callchain_node callchain;
  47. struct rb_root sorted_chain;
  48. };
  49. enum sort_type {
  50. SORT_PID,
  51. SORT_COMM,
  52. SORT_DSO,
  53. SORT_SYM,
  54. SORT_PARENT
  55. };
  56. /*
  57. * configurable sorting bits
  58. */
  59. struct sort_entry {
  60. struct list_head list;
  61. const char *header;
  62. int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
  63. int64_t (*collapse)(struct hist_entry *, struct hist_entry *);
  64. size_t (*print)(FILE *fp, struct hist_entry *, unsigned int width);
  65. unsigned int *width;
  66. bool elide;
  67. };
  68. extern struct sort_entry sort_thread;
  69. extern struct list_head hist_entry__sort_list;
  70. extern int repsep_fprintf(FILE *fp, const char *fmt, ...);
  71. extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
  72. extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
  73. extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
  74. extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
  75. extern int64_t cmp_null(void *, void *);
  76. extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
  77. extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
  78. extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
  79. extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
  80. extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
  81. extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
  82. extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
  83. extern int sort_dimension__add(const char *);
  84. #endif /* __PERF_SORT_H */