diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-11-09 00:45:46 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-19 11:19:26 -0500 |
commit | 2c6caff2b26fde8f3f87183f8c97f2cebfdbcb98 (patch) | |
tree | 4a4fca80707f6f94fb8ee5575c51674e121bdea6 /tools/perf/ui | |
parent | 3cd99dfd1c87067fb28a19fee76500aed56d7c8f (diff) |
perf ui/gtk: Support folded callchains
The folded callchain mode is to print all chains in a single line.
Currently perf report --gtk doesn't support folded callchains. Like
flat callchains, only leaf nodes are added to the final rbtree so it
should show entries in parent nodes.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1447047946-1691-11-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 0b24cd6d38a4..467717276ab6 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -152,6 +152,66 @@ static void perf_gtk__add_callchain_flat(struct rb_root *root, GtkTreeStore *sto | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | static void perf_gtk__add_callchain_folded(struct rb_root *root, GtkTreeStore *store, | ||
156 | GtkTreeIter *parent, int col, u64 total) | ||
157 | { | ||
158 | struct rb_node *nd; | ||
159 | |||
160 | for (nd = rb_first(root); nd; nd = rb_next(nd)) { | ||
161 | struct callchain_node *node; | ||
162 | struct callchain_list *chain; | ||
163 | GtkTreeIter iter; | ||
164 | char buf[64]; | ||
165 | char *str, *str_alloc = NULL; | ||
166 | bool first = true; | ||
167 | |||
168 | node = rb_entry(nd, struct callchain_node, rb_node); | ||
169 | |||
170 | callchain_node__make_parent_list(node); | ||
171 | |||
172 | list_for_each_entry(chain, &node->parent_val, list) { | ||
173 | char name[1024]; | ||
174 | |||
175 | callchain_list__sym_name(chain, name, sizeof(name), false); | ||
176 | |||
177 | if (asprintf(&str, "%s%s%s", | ||
178 | first ? "" : str_alloc, | ||
179 | first ? "" : symbol_conf.field_sep ?: "; ", | ||
180 | name) < 0) | ||
181 | return; | ||
182 | |||
183 | first = false; | ||
184 | free(str_alloc); | ||
185 | str_alloc = str; | ||
186 | } | ||
187 | |||
188 | list_for_each_entry(chain, &node->val, list) { | ||
189 | char name[1024]; | ||
190 | |||
191 | callchain_list__sym_name(chain, name, sizeof(name), false); | ||
192 | |||
193 | if (asprintf(&str, "%s%s%s", | ||
194 | first ? "" : str_alloc, | ||
195 | first ? "" : symbol_conf.field_sep ?: "; ", | ||
196 | name) < 0) | ||
197 | return; | ||
198 | |||
199 | first = false; | ||
200 | free(str_alloc); | ||
201 | str_alloc = str; | ||
202 | } | ||
203 | |||
204 | gtk_tree_store_append(store, &iter, parent); | ||
205 | |||
206 | callchain_node__scnprintf_value(node, buf, sizeof(buf), total); | ||
207 | gtk_tree_store_set(store, &iter, 0, buf, -1); | ||
208 | |||
209 | gtk_tree_store_set(store, &iter, col, str, -1); | ||
210 | |||
211 | free(str_alloc); | ||
212 | } | ||
213 | } | ||
214 | |||
155 | static void perf_gtk__add_callchain_graph(struct rb_root *root, GtkTreeStore *store, | 215 | static void perf_gtk__add_callchain_graph(struct rb_root *root, GtkTreeStore *store, |
156 | GtkTreeIter *parent, int col, u64 total) | 216 | GtkTreeIter *parent, int col, u64 total) |
157 | { | 217 | { |
@@ -207,6 +267,8 @@ static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store, | |||
207 | { | 267 | { |
208 | if (callchain_param.mode == CHAIN_FLAT) | 268 | if (callchain_param.mode == CHAIN_FLAT) |
209 | perf_gtk__add_callchain_flat(root, store, parent, col, total); | 269 | perf_gtk__add_callchain_flat(root, store, parent, col, total); |
270 | else if (callchain_param.mode == CHAIN_FOLDED) | ||
271 | perf_gtk__add_callchain_folded(root, store, parent, col, total); | ||
210 | else | 272 | else |
211 | perf_gtk__add_callchain_graph(root, store, parent, col, total); | 273 | perf_gtk__add_callchain_graph(root, store, parent, col, total); |
212 | } | 274 | } |