perf sort: Clean up sort__first_dimension setting
[deliverable/linux.git] / tools / perf / util / sort.h
CommitLineData
dd68ada2
JK
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#include <linux/list.h>
9#include "cache.h"
10#include <linux/rbtree.h>
11#include "symbol.h"
12#include "string.h"
13#include "callchain.h"
14#include "strlist.h"
15#include "values.h"
16
17#include "../perf.h"
18#include "debug.h"
19#include "header.h"
20
21#include "parse-options.h"
22#include "parse-events.h"
23
24#include "thread.h"
25#include "sort.h"
26
27extern regex_t parent_regex;
edb7c60e
ACM
28extern const char *sort_order;
29extern const char default_parent_pattern[];
30extern const char *parent_pattern;
31extern const char default_sort_order[];
dd68ada2
JK
32extern int sort__need_collapse;
33extern int sort__has_parent;
1af55640 34extern int sort__has_sym;
993ac88d 35extern int sort__branch_mode;
dd68ada2
JK
36extern struct sort_entry sort_comm;
37extern struct sort_entry sort_dso;
38extern struct sort_entry sort_sym;
39extern struct sort_entry sort_parent;
a68c2c58
SE
40extern struct sort_entry sort_dso_from;
41extern struct sort_entry sort_dso_to;
42extern struct sort_entry sort_sym_from;
43extern struct sort_entry sort_sym_to;
a4fb581b 44extern enum sort_type sort__first_dimension;
dd68ada2 45
b24c28f7
NK
46struct he_stat {
47 u64 period;
48 u64 period_sys;
49 u64 period_us;
50 u64 period_guest_sys;
51 u64 period_guest_us;
52 u32 nr_events;
53};
54
96c47f19
JO
55struct hist_entry_diff {
56 bool computed;
57
96c47f19
JO
58 /* PERF_HPP__DELTA */
59 double period_ratio_delta;
60
61 /* PERF_HPP__RATIO */
62 double period_ratio;
81d5f958
JO
63
64 /* HISTC_WEIGHTED_DIFF */
65 s64 wdiff;
96c47f19
JO
66};
67
0f0cbf7a
ACM
68/**
69 * struct hist_entry - histogram entry
70 *
71 * @row_offset - offset from the first callchain expanded to appear on screen
72 * @nr_rows - rows expanded in callchain, recalculated on folding/unfolding
73 */
dd68ada2 74struct hist_entry {
1980c2eb 75 struct rb_node rb_node_in;
dd68ada2 76 struct rb_node rb_node;
b821c732
ACM
77 union {
78 struct list_head node;
79 struct list_head head;
80 } pairs;
b24c28f7 81 struct he_stat stat;
59fd5306 82 struct map_symbol ms;
a5e29aca 83 struct thread *thread;
dd68ada2 84 u64 ip;
f60f3593 85 s32 cpu;
0f0cbf7a 86
96c47f19
JO
87 struct hist_entry_diff diff;
88
0f0cbf7a
ACM
89 /* XXX These two should move to some tree widget lib */
90 u16 row_offset;
91 u16 nr_rows;
92
93 bool init_have_children;
dd68ada2 94 char level;
df71d95f 95 bool used;
a5e29aca 96 u8 filtered;
409a8be6 97 char *srcline;
83753190 98 struct symbol *parent;
dd464345 99 unsigned long position;
b821c732 100 struct rb_root sorted_chain;
b5387528 101 struct branch_info *branch_info;
ae359f19 102 struct hists *hists;
d2009c51 103 struct callchain_root callchain[0];
dd68ada2
JK
104};
105
b821c732
ACM
106static inline bool hist_entry__has_pairs(struct hist_entry *he)
107{
108 return !list_empty(&he->pairs.node);
109}
110
111static inline struct hist_entry *hist_entry__next_pair(struct hist_entry *he)
112{
113 if (hist_entry__has_pairs(he))
114 return list_entry(he->pairs.node.next, struct hist_entry, pairs.node);
115 return NULL;
116}
117
2850d948 118static inline void hist_entry__add_pair(struct hist_entry *he,
b821c732
ACM
119 struct hist_entry *pair)
120{
121 list_add_tail(&he->pairs.head, &pair->pairs.node);
122}
123
a4fb581b
FW
124enum sort_type {
125 SORT_PID,
126 SORT_COMM,
127 SORT_DSO,
128 SORT_SYM,
f60f3593
AS
129 SORT_PARENT,
130 SORT_CPU,
b5387528
RAV
131 SORT_DSO_FROM,
132 SORT_DSO_TO,
133 SORT_SYM_FROM,
134 SORT_SYM_TO,
135 SORT_MISPREDICT,
409a8be6 136 SORT_SRCLINE,
a4fb581b
FW
137};
138
dd68ada2
JK
139/*
140 * configurable sorting bits
141 */
142
143struct sort_entry {
144 struct list_head list;
145
fcd14984 146 const char *se_header;
dd68ada2 147
fcd14984
FW
148 int64_t (*se_cmp)(struct hist_entry *, struct hist_entry *);
149 int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *);
150 int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size,
151 unsigned int width);
8a6c5b26 152 u8 se_width_idx;
dd68ada2
JK
153 bool elide;
154};
155
156extern struct sort_entry sort_thread;
157extern struct list_head hist_entry__sort_list;
158
c8829c7a 159void setup_sorting(const char * const usagestr[], const struct option *opts);
dd68ada2 160extern int sort_dimension__add(const char *);
c351c281
ACM
161void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
162 const char *list_name, FILE *fp);
dd68ada2
JK
163
164#endif /* __PERF_SORT_H */
This page took 0.138504 seconds and 5 git commands to generate.