• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __PERF_SORT_H
2 #define __PERF_SORT_H
3 #include "../builtin.h"
4 
5 #include "util.h"
6 
7 #include "color.h"
8 /* ANDROID_CHANGE_BEGIN */
9 #if 0
10 #include <linux/list.h>
11 #include "cache.h"
12 #include <linux/rbtree.h>
13 #else
14 #include "include/linux/list.h"
15 #include "cache.h"
16 #include "include/linux/rbtree.h"
17 #endif
18 /* ANDROID_CHANGE_END */
19 #include "symbol.h"
20 #include "string.h"
21 #include "callchain.h"
22 #include "strlist.h"
23 #include "values.h"
24 
25 #include "../perf.h"
26 #include "debug.h"
27 #include "header.h"
28 
29 #include "parse-options.h"
30 #include "parse-events.h"
31 
32 #include "thread.h"
33 #include "sort.h"
34 
35 extern regex_t parent_regex;
36 extern const char *sort_order;
37 extern const char default_parent_pattern[];
38 extern const char *parent_pattern;
39 extern const char default_sort_order[];
40 extern int sort__need_collapse;
41 extern int sort__has_parent;
42 extern char *field_sep;
43 extern struct sort_entry sort_comm;
44 extern struct sort_entry sort_dso;
45 extern struct sort_entry sort_sym;
46 extern struct sort_entry sort_parent;
47 extern enum sort_type sort__first_dimension;
48 
49 /**
50  * struct hist_entry - histogram entry
51  *
52  * @row_offset - offset from the first callchain expanded to appear on screen
53  * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
54  */
55 struct hist_entry {
56 	struct rb_node		rb_node;
57 	u64			period;
58 	u64			period_sys;
59 	u64			period_us;
60 	u64			period_guest_sys;
61 	u64			period_guest_us;
62 	struct map_symbol	ms;
63 	struct thread		*thread;
64 	u64			ip;
65 	s32			cpu;
66 	u32			nr_events;
67 
68 	/* XXX These two should move to some tree widget lib */
69 	u16			row_offset;
70 	u16			nr_rows;
71 
72 	bool			init_have_children;
73 	char			level;
74 	u8			filtered;
75 	struct symbol		*parent;
76 	union {
77 		unsigned long	  position;
78 		struct hist_entry *pair;
79 		struct rb_root	  sorted_chain;
80 	};
81 	struct callchain_root	callchain[0];
82 };
83 
84 enum sort_type {
85 	SORT_PID,
86 	SORT_COMM,
87 	SORT_DSO,
88 	SORT_SYM,
89 	SORT_PARENT,
90 	SORT_CPU,
91 };
92 
93 /*
94  * configurable sorting bits
95  */
96 
97 struct sort_entry {
98 	struct list_head list;
99 
100 	const char *se_header;
101 
102 	int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
103 	int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
104 	int	(*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
105 			       unsigned int width);
106 	u8	se_width_idx;
107 	bool	elide;
108 };
109 
110 extern struct sort_entry sort_thread;
111 extern struct list_head hist_entry__sort_list;
112 
113 void setup_sorting(const char * const usagestr[], const struct option *opts);
114 
115 extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
116 extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
117 extern size_t sort__dso_print(FILE *, struct hist_entry *, unsigned int);
118 extern size_t sort__sym_print(FILE *, struct hist_entry *, unsigned int __used);
119 extern int64_t cmp_null(void *, void *);
120 extern int64_t sort__thread_cmp(struct hist_entry *, struct hist_entry *);
121 extern int64_t sort__comm_cmp(struct hist_entry *, struct hist_entry *);
122 extern int64_t sort__comm_collapse(struct hist_entry *, struct hist_entry *);
123 extern int64_t sort__dso_cmp(struct hist_entry *, struct hist_entry *);
124 extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
125 extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
126 int64_t sort__cpu_cmp(struct hist_entry *left, struct hist_entry *right);
127 extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
128 extern int sort_dimension__add(const char *);
129 void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
130 			     const char *list_name, FILE *fp);
131 
132 #endif	/* __PERF_SORT_H */
133