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>
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 40c9acd..60ced70 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -5,8 +5,9 @@
char *parent_pattern = default_parent_pattern;
char default_sort_order[] = "comm,dso,symbol";
char *sort_order = default_sort_order;
-int sort__need_collapse = 0;
-int sort__has_parent = 0;
+int sort__need_collapse = 0;
+int sort__has_parent = 0;
+int sort_by_sym_first;
unsigned int dsos__col_width;
unsigned int comms__col_width;
@@ -265,6 +266,10 @@
sort__has_parent = 1;
}
+ if (list_empty(&hist_entry__sort_list) &&
+ !strcmp(sd->name, "symbol"))
+ sort_by_sym_first = true;
+
list_add_tail(&sd->entry->list, &hist_entry__sort_list);
sd->taken = 1;
@@ -273,4 +278,3 @@
return -ESRCH;
}
-