sort.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. union {
  48. unsigned long position;
  49. struct hist_entry *pair;
  50. struct rb_root sorted_chain;
  51. };
  52. };
  53. enum sort_type {
  54. SORT_PID,
  55. SORT_COMM,
  56. SORT_DSO,
  57. SORT_SYM,
  58. SORT_PARENT
  59. };
  60. /*
  61. * configurable sorting bits
  62. */
  63. struct sort_entry {
  64. struct list_head list;
  65. const char *header;
  66. int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
  67. int64_t (*collapse)(struct hist_entry *, struct hist_entry *);
  68. size_t (*print)(FILE *fp, struct hist_entry *, unsigned int width);
  69. unsigned int *width;
  70. bool elide;
  71. };
  72. extern struct sort_entry sort_thread;
  73. extern struct list_head hist_entry__sort_list;
  74. void setup_sorting(const char * const usagestr[], const struct option *opts);
  75. extern int repsep_fprintf(FILE *fp, const char *fmt, ...);
  76. extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
  77. extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
  78. extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
  79. extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
  80. extern int64_t cmp_null(void *, void *);
  81. extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
  82. extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
  83. extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
  84. extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
  85. extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
  86. extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
  87. extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
  88. extern int sort_dimension__add(const char *);
  89. void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
  90. const char *list_name, FILE *fp);
  91. #endif /* __PERF_SORT_H */