diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-22 17:23:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-23 01:55:16 -0400 |
commit | af0a6fa46388e1e0c2d1a672aad84f8f6ef0b20b (patch) | |
tree | 961592b767ecda1e2ac85b997f64bc1665f0b249 /tools/perf/builtin-report.c | |
parent | 4e3b799d7dbb2a12ca8dca8d3594d32095772973 (diff) |
perf tools: Fix missing top level callchain
While recursively printing the branches of each callchains, we
forget to display the root. It is never printed.
Say we have:
symbol
f1
f2
|
-------- f3
| f4
|
---------f5
f6
Actually we never see that, instead it displays:
symbol
|
--------- f3
| f4
|
--------- f5
f6
However f1 is always the same than "symbol" and if we are
sorting by symbols first then "symbol", f1 and f2 will be well
aligned like in the above example, so displaying f1 looks
redundant here.
But if we are sorting by something else first (dso, comm,
etc...), displaying f1 doesn't look redundant but rather
necessary because the symbol is not well aligned anymore with
its callchain:
comm dso symbol
f1
f2
|
--------- [...]
And we want the callchain to be obvious.
So we fix the bug by printing the root branch, but we also
filter its first entry if we are sorting by symbols first.
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1256246604-17156-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r-- | tools/perf/builtin-report.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bee207ce589a..3d8c52220f1f 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -122,8 +122,8 @@ static void init_rem_hits(void) | |||
122 | } | 122 | } |
123 | 123 | ||
124 | static size_t | 124 | static size_t |
125 | callchain__fprintf_graph(FILE *fp, struct callchain_node *self, | 125 | __callchain__fprintf_graph(FILE *fp, struct callchain_node *self, |
126 | u64 total_samples, int depth, int depth_mask) | 126 | u64 total_samples, int depth, int depth_mask) |
127 | { | 127 | { |
128 | struct rb_node *node, *next; | 128 | struct rb_node *node, *next; |
129 | struct callchain_node *child; | 129 | struct callchain_node *child; |
@@ -174,9 +174,9 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self, | |||
174 | new_total, | 174 | new_total, |
175 | cumul); | 175 | cumul); |
176 | } | 176 | } |
177 | ret += callchain__fprintf_graph(fp, child, new_total, | 177 | ret += __callchain__fprintf_graph(fp, child, new_total, |
178 | depth + 1, | 178 | depth + 1, |
179 | new_depth_mask | (1 << depth)); | 179 | new_depth_mask | (1 << depth)); |
180 | node = next; | 180 | node = next; |
181 | } | 181 | } |
182 | 182 | ||
@@ -197,6 +197,33 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self, | |||
197 | } | 197 | } |
198 | 198 | ||
199 | static size_t | 199 | static size_t |
200 | callchain__fprintf_graph(FILE *fp, struct callchain_node *self, | ||
201 | u64 total_samples) | ||
202 | { | ||
203 | struct callchain_list *chain; | ||
204 | int i = 0; | ||
205 | int ret = 0; | ||
206 | |||
207 | list_for_each_entry(chain, &self->val, list) { | ||
208 | if (chain->ip >= PERF_CONTEXT_MAX) | ||
209 | continue; | ||
210 | |||
211 | if (!i++ && sort_by_sym_first) | ||
212 | continue; | ||
213 | |||
214 | if (chain->sym) | ||
215 | ret += fprintf(fp, " %s\n", chain->sym->name); | ||
216 | else | ||
217 | ret += fprintf(fp, " %p\n", | ||
218 | (void *)(long)chain->ip); | ||
219 | } | ||
220 | |||
221 | ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1); | ||
222 | |||
223 | return ret; | ||
224 | } | ||
225 | |||
226 | static size_t | ||
200 | callchain__fprintf_flat(FILE *fp, struct callchain_node *self, | 227 | callchain__fprintf_flat(FILE *fp, struct callchain_node *self, |
201 | u64 total_samples) | 228 | u64 total_samples) |
202 | { | 229 | { |
@@ -244,8 +271,7 @@ hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self, | |||
244 | break; | 271 | break; |
245 | case CHAIN_GRAPH_ABS: /* Falldown */ | 272 | case CHAIN_GRAPH_ABS: /* Falldown */ |
246 | case CHAIN_GRAPH_REL: | 273 | case CHAIN_GRAPH_REL: |
247 | ret += callchain__fprintf_graph(fp, chain, | 274 | ret += callchain__fprintf_graph(fp, chain, total_samples); |
248 | total_samples, 1, 1); | ||
249 | case CHAIN_NONE: | 275 | case CHAIN_NONE: |
250 | default: | 276 | default: |
251 | break; | 277 | break; |