diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-12-27 04:11:38 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 14:40:20 -0500 |
commit | 14d1ac7429d104b09d65c72fd215e1cffd5c7eba (patch) | |
tree | fba4e1bdb4db10e083af2d3b6b336a57e13c285d | |
parent | 7ce28b5b5b320e26ac6a0e352d5005bce3530e05 (diff) |
perf sort: Move misplaced sort entry functions
Some functions are misplaced along with other entries. Move them to a
right place so that it can be found together with related functions.
No functional change intended.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1356599507-14226-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/sort.c | 119 |
1 files changed, 60 insertions, 59 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index dbaded90312c..ce5d40456c07 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
@@ -97,6 +97,16 @@ static int hist_entry__comm_snprintf(struct hist_entry *self, char *bf, | |||
97 | return repsep_snprintf(bf, size, "%*s", width, self->thread->comm); | 97 | return repsep_snprintf(bf, size, "%*s", width, self->thread->comm); |
98 | } | 98 | } |
99 | 99 | ||
100 | struct sort_entry sort_comm = { | ||
101 | .se_header = "Command", | ||
102 | .se_cmp = sort__comm_cmp, | ||
103 | .se_collapse = sort__comm_collapse, | ||
104 | .se_snprintf = hist_entry__comm_snprintf, | ||
105 | .se_width_idx = HISTC_COMM, | ||
106 | }; | ||
107 | |||
108 | /* --sort dso */ | ||
109 | |||
100 | static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r) | 110 | static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r) |
101 | { | 111 | { |
102 | struct dso *dso_l = map_l ? map_l->dso : NULL; | 112 | struct dso *dso_l = map_l ? map_l->dso : NULL; |
@@ -117,22 +127,38 @@ static int64_t _sort__dso_cmp(struct map *map_l, struct map *map_r) | |||
117 | return strcmp(dso_name_l, dso_name_r); | 127 | return strcmp(dso_name_l, dso_name_r); |
118 | } | 128 | } |
119 | 129 | ||
120 | struct sort_entry sort_comm = { | ||
121 | .se_header = "Command", | ||
122 | .se_cmp = sort__comm_cmp, | ||
123 | .se_collapse = sort__comm_collapse, | ||
124 | .se_snprintf = hist_entry__comm_snprintf, | ||
125 | .se_width_idx = HISTC_COMM, | ||
126 | }; | ||
127 | |||
128 | /* --sort dso */ | ||
129 | |||
130 | static int64_t | 130 | static int64_t |
131 | sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) | 131 | sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) |
132 | { | 132 | { |
133 | return _sort__dso_cmp(left->ms.map, right->ms.map); | 133 | return _sort__dso_cmp(left->ms.map, right->ms.map); |
134 | } | 134 | } |
135 | 135 | ||
136 | static int _hist_entry__dso_snprintf(struct map *map, char *bf, | ||
137 | size_t size, unsigned int width) | ||
138 | { | ||
139 | if (map && map->dso) { | ||
140 | const char *dso_name = !verbose ? map->dso->short_name : | ||
141 | map->dso->long_name; | ||
142 | return repsep_snprintf(bf, size, "%-*s", width, dso_name); | ||
143 | } | ||
144 | |||
145 | return repsep_snprintf(bf, size, "%-*s", width, "[unknown]"); | ||
146 | } | ||
147 | |||
148 | static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf, | ||
149 | size_t size, unsigned int width) | ||
150 | { | ||
151 | return _hist_entry__dso_snprintf(self->ms.map, bf, size, width); | ||
152 | } | ||
153 | |||
154 | struct sort_entry sort_dso = { | ||
155 | .se_header = "Shared Object", | ||
156 | .se_cmp = sort__dso_cmp, | ||
157 | .se_snprintf = hist_entry__dso_snprintf, | ||
158 | .se_width_idx = HISTC_DSO, | ||
159 | }; | ||
160 | |||
161 | /* --sort symbol */ | ||
136 | 162 | ||
137 | static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r, | 163 | static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r, |
138 | u64 ip_l, u64 ip_r) | 164 | u64 ip_l, u64 ip_r) |
@@ -149,22 +175,24 @@ static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r, | |||
149 | return (int64_t)(ip_r - ip_l); | 175 | return (int64_t)(ip_r - ip_l); |
150 | } | 176 | } |
151 | 177 | ||
152 | static int _hist_entry__dso_snprintf(struct map *map, char *bf, | 178 | static int64_t |
153 | size_t size, unsigned int width) | 179 | sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) |
154 | { | 180 | { |
155 | if (map && map->dso) { | 181 | u64 ip_l, ip_r; |
156 | const char *dso_name = !verbose ? map->dso->short_name : | ||
157 | map->dso->long_name; | ||
158 | return repsep_snprintf(bf, size, "%-*s", width, dso_name); | ||
159 | } | ||
160 | 182 | ||
161 | return repsep_snprintf(bf, size, "%-*s", width, "[unknown]"); | 183 | if (!left->ms.sym && !right->ms.sym) |
162 | } | 184 | return right->level - left->level; |
163 | 185 | ||
164 | static int hist_entry__dso_snprintf(struct hist_entry *self, char *bf, | 186 | if (!left->ms.sym || !right->ms.sym) |
165 | size_t size, unsigned int width) | 187 | return cmp_null(left->ms.sym, right->ms.sym); |
166 | { | 188 | |
167 | return _hist_entry__dso_snprintf(self->ms.map, bf, size, width); | 189 | if (left->ms.sym == right->ms.sym) |
190 | return 0; | ||
191 | |||
192 | ip_l = left->ms.sym->start; | ||
193 | ip_r = right->ms.sym->start; | ||
194 | |||
195 | return _sort__sym_cmp(left->ms.sym, right->ms.sym, ip_l, ip_r); | ||
168 | } | 196 | } |
169 | 197 | ||
170 | static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, | 198 | static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, |
@@ -195,14 +223,6 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, | |||
195 | return ret; | 223 | return ret; |
196 | } | 224 | } |
197 | 225 | ||
198 | |||
199 | struct sort_entry sort_dso = { | ||
200 | .se_header = "Shared Object", | ||
201 | .se_cmp = sort__dso_cmp, | ||
202 | .se_snprintf = hist_entry__dso_snprintf, | ||
203 | .se_width_idx = HISTC_DSO, | ||
204 | }; | ||
205 | |||
206 | static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf, | 226 | static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf, |
207 | size_t size, | 227 | size_t size, |
208 | unsigned int width __maybe_unused) | 228 | unsigned int width __maybe_unused) |
@@ -211,27 +231,6 @@ static int hist_entry__sym_snprintf(struct hist_entry *self, char *bf, | |||
211 | self->level, bf, size, width); | 231 | self->level, bf, size, width); |
212 | } | 232 | } |
213 | 233 | ||
214 | /* --sort symbol */ | ||
215 | static int64_t | ||
216 | sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) | ||
217 | { | ||
218 | u64 ip_l, ip_r; | ||
219 | |||
220 | if (!left->ms.sym && !right->ms.sym) | ||
221 | return right->level - left->level; | ||
222 | |||
223 | if (!left->ms.sym || !right->ms.sym) | ||
224 | return cmp_null(left->ms.sym, right->ms.sym); | ||
225 | |||
226 | if (left->ms.sym == right->ms.sym) | ||
227 | return 0; | ||
228 | |||
229 | ip_l = left->ms.sym->start; | ||
230 | ip_r = right->ms.sym->start; | ||
231 | |||
232 | return _sort__sym_cmp(left->ms.sym, right->ms.sym, ip_l, ip_r); | ||
233 | } | ||
234 | |||
235 | struct sort_entry sort_sym = { | 234 | struct sort_entry sort_sym = { |
236 | .se_header = "Symbol", | 235 | .se_header = "Symbol", |
237 | .se_cmp = sort__sym_cmp, | 236 | .se_cmp = sort__sym_cmp, |
@@ -343,6 +342,8 @@ struct sort_entry sort_cpu = { | |||
343 | .se_width_idx = HISTC_CPU, | 342 | .se_width_idx = HISTC_CPU, |
344 | }; | 343 | }; |
345 | 344 | ||
345 | /* sort keys for branch stacks */ | ||
346 | |||
346 | static int64_t | 347 | static int64_t |
347 | sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) | 348 | sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) |
348 | { | 349 | { |
@@ -357,13 +358,6 @@ static int hist_entry__dso_from_snprintf(struct hist_entry *self, char *bf, | |||
357 | bf, size, width); | 358 | bf, size, width); |
358 | } | 359 | } |
359 | 360 | ||
360 | struct sort_entry sort_dso_from = { | ||
361 | .se_header = "Source Shared Object", | ||
362 | .se_cmp = sort__dso_from_cmp, | ||
363 | .se_snprintf = hist_entry__dso_from_snprintf, | ||
364 | .se_width_idx = HISTC_DSO_FROM, | ||
365 | }; | ||
366 | |||
367 | static int64_t | 361 | static int64_t |
368 | sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) | 362 | sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) |
369 | { | 363 | { |
@@ -423,6 +417,13 @@ static int hist_entry__sym_to_snprintf(struct hist_entry *self, char *bf, | |||
423 | 417 | ||
424 | } | 418 | } |
425 | 419 | ||
420 | struct sort_entry sort_dso_from = { | ||
421 | .se_header = "Source Shared Object", | ||
422 | .se_cmp = sort__dso_from_cmp, | ||
423 | .se_snprintf = hist_entry__dso_from_snprintf, | ||
424 | .se_width_idx = HISTC_DSO_FROM, | ||
425 | }; | ||
426 | |||
426 | struct sort_entry sort_dso_to = { | 427 | struct sort_entry sort_dso_to = { |
427 | .se_header = "Target Shared Object", | 428 | .se_header = "Target Shared Object", |
428 | .se_cmp = sort__dso_to_cmp, | 429 | .se_cmp = sort__dso_to_cmp, |