Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 1 | #include "../evlist.h" |
| 2 | #include "../cache.h" |
| 3 | #include "../evsel.h" |
| 4 | #include "../sort.h" |
| 5 | #include "../hist.h" |
| 6 | #include "../helpline.h" |
| 7 | #include "gtk.h" |
| 8 | |
| 9 | #define MAX_COLUMNS 32 |
| 10 | |
Namhyung Kim | a0088ad | 2014-03-03 10:14:04 +0900 | [diff] [blame] | 11 | static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...) |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 12 | { |
| 13 | int ret = 0; |
Namhyung Kim | d675107 | 2014-07-31 14:47:36 +0900 | [diff] [blame] | 14 | int len; |
Namhyung Kim | 4a62109 | 2014-03-03 10:14:03 +0900 | [diff] [blame] | 15 | va_list args; |
| 16 | double percent; |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 17 | const char *markup; |
Namhyung Kim | a0088ad | 2014-03-03 10:14:04 +0900 | [diff] [blame] | 18 | char *buf = hpp->buf; |
| 19 | size_t size = hpp->size; |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 20 | |
Namhyung Kim | 4a62109 | 2014-03-03 10:14:03 +0900 | [diff] [blame] | 21 | va_start(args, fmt); |
Namhyung Kim | d675107 | 2014-07-31 14:47:36 +0900 | [diff] [blame] | 22 | len = va_arg(args, int); |
Namhyung Kim | 4a62109 | 2014-03-03 10:14:03 +0900 | [diff] [blame] | 23 | percent = va_arg(args, double); |
| 24 | va_end(args); |
| 25 | |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 26 | markup = perf_gtk__get_percent_color(percent); |
| 27 | if (markup) |
| 28 | ret += scnprintf(buf, size, markup); |
| 29 | |
Namhyung Kim | d675107 | 2014-07-31 14:47:36 +0900 | [diff] [blame] | 30 | ret += scnprintf(buf + ret, size - ret, fmt, len, percent); |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 31 | |
| 32 | if (markup) |
| 33 | ret += scnprintf(buf + ret, size - ret, "</span>"); |
| 34 | |
| 35 | return ret; |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 36 | } |
| 37 | |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 38 | #define __HPP_COLOR_PERCENT_FN(_type, _field) \ |
| 39 | static u64 he_get_##_field(struct hist_entry *he) \ |
| 40 | { \ |
| 41 | return he->stat._field; \ |
| 42 | } \ |
| 43 | \ |
Namhyung Kim | 5b59166 | 2014-07-31 14:47:38 +0900 | [diff] [blame] | 44 | static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame] | 45 | struct perf_hpp *hpp, \ |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 46 | struct hist_entry *he) \ |
| 47 | { \ |
Namhyung Kim | 5b59166 | 2014-07-31 14:47:38 +0900 | [diff] [blame] | 48 | return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ |
| 49 | __percent_color_snprintf, true); \ |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 50 | } |
| 51 | |
Namhyung Kim | b09955b | 2013-10-30 16:15:23 +0900 | [diff] [blame] | 52 | #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ |
| 53 | static u64 he_get_acc_##_field(struct hist_entry *he) \ |
| 54 | { \ |
| 55 | return he->stat_acc->_field; \ |
| 56 | } \ |
| 57 | \ |
| 58 | static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
| 59 | struct perf_hpp *hpp, \ |
| 60 | struct hist_entry *he) \ |
| 61 | { \ |
Namhyung Kim | 5b59166 | 2014-07-31 14:47:38 +0900 | [diff] [blame] | 62 | return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", \ |
| 63 | __percent_color_snprintf, true); \ |
Namhyung Kim | b09955b | 2013-10-30 16:15:23 +0900 | [diff] [blame] | 64 | } |
| 65 | |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 66 | __HPP_COLOR_PERCENT_FN(overhead, period) |
| 67 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys) |
| 68 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us) |
| 69 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys) |
| 70 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us) |
Namhyung Kim | b09955b | 2013-10-30 16:15:23 +0900 | [diff] [blame] | 71 | __HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period) |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 72 | |
| 73 | #undef __HPP_COLOR_PERCENT_FN |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 74 | |
| 75 | |
| 76 | void perf_gtk__init_hpp(void) |
| 77 | { |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 78 | perf_hpp__format[PERF_HPP__OVERHEAD].color = |
| 79 | perf_gtk__hpp_color_overhead; |
| 80 | perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color = |
| 81 | perf_gtk__hpp_color_overhead_sys; |
| 82 | perf_hpp__format[PERF_HPP__OVERHEAD_US].color = |
| 83 | perf_gtk__hpp_color_overhead_us; |
| 84 | perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_SYS].color = |
| 85 | perf_gtk__hpp_color_overhead_guest_sys; |
| 86 | perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_US].color = |
| 87 | perf_gtk__hpp_color_overhead_guest_us; |
Namhyung Kim | b09955b | 2013-10-30 16:15:23 +0900 | [diff] [blame] | 88 | perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color = |
| 89 | perf_gtk__hpp_color_overhead_acc; |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 90 | } |
| 91 | |
Namhyung Kim | 3cd99df | 2015-11-09 14:45:45 +0900 | [diff] [blame] | 92 | static void perf_gtk__add_callchain_flat(struct rb_root *root, GtkTreeStore *store, |
| 93 | GtkTreeIter *parent, int col, u64 total) |
| 94 | { |
| 95 | struct rb_node *nd; |
| 96 | bool has_single_node = (rb_first(root) == rb_last(root)); |
| 97 | |
| 98 | for (nd = rb_first(root); nd; nd = rb_next(nd)) { |
| 99 | struct callchain_node *node; |
| 100 | struct callchain_list *chain; |
| 101 | GtkTreeIter iter, new_parent; |
| 102 | bool need_new_parent; |
| 103 | |
| 104 | node = rb_entry(nd, struct callchain_node, rb_node); |
| 105 | |
| 106 | new_parent = *parent; |
| 107 | need_new_parent = !has_single_node; |
| 108 | |
| 109 | callchain_node__make_parent_list(node); |
| 110 | |
| 111 | list_for_each_entry(chain, &node->parent_val, list) { |
| 112 | char buf[128]; |
| 113 | |
| 114 | gtk_tree_store_append(store, &iter, &new_parent); |
| 115 | |
| 116 | callchain_node__scnprintf_value(node, buf, sizeof(buf), total); |
| 117 | gtk_tree_store_set(store, &iter, 0, buf, -1); |
| 118 | |
| 119 | callchain_list__sym_name(chain, buf, sizeof(buf), false); |
| 120 | gtk_tree_store_set(store, &iter, col, buf, -1); |
| 121 | |
| 122 | if (need_new_parent) { |
| 123 | /* |
| 124 | * Only show the top-most symbol in a callchain |
| 125 | * if it's not the only callchain. |
| 126 | */ |
| 127 | new_parent = iter; |
| 128 | need_new_parent = false; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | list_for_each_entry(chain, &node->val, list) { |
| 133 | char buf[128]; |
| 134 | |
| 135 | gtk_tree_store_append(store, &iter, &new_parent); |
| 136 | |
| 137 | callchain_node__scnprintf_value(node, buf, sizeof(buf), total); |
| 138 | gtk_tree_store_set(store, &iter, 0, buf, -1); |
| 139 | |
| 140 | callchain_list__sym_name(chain, buf, sizeof(buf), false); |
| 141 | gtk_tree_store_set(store, &iter, col, buf, -1); |
| 142 | |
| 143 | if (need_new_parent) { |
| 144 | /* |
| 145 | * Only show the top-most symbol in a callchain |
| 146 | * if it's not the only callchain. |
| 147 | */ |
| 148 | new_parent = iter; |
| 149 | need_new_parent = false; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
Namhyung Kim | 2c6caff | 2015-11-09 14:45:46 +0900 | [diff] [blame] | 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 | |
Namhyung Kim | 3cd99df | 2015-11-09 14:45:45 +0900 | [diff] [blame] | 215 | static void perf_gtk__add_callchain_graph(struct rb_root *root, GtkTreeStore *store, |
| 216 | GtkTreeIter *parent, int col, u64 total) |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 217 | { |
| 218 | struct rb_node *nd; |
| 219 | bool has_single_node = (rb_first(root) == rb_last(root)); |
| 220 | |
| 221 | for (nd = rb_first(root); nd; nd = rb_next(nd)) { |
| 222 | struct callchain_node *node; |
| 223 | struct callchain_list *chain; |
| 224 | GtkTreeIter iter, new_parent; |
| 225 | bool need_new_parent; |
Namhyung Kim | 5ab250c | 2015-11-09 14:45:39 +0900 | [diff] [blame] | 226 | u64 child_total; |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 227 | |
| 228 | node = rb_entry(nd, struct callchain_node, rb_node); |
| 229 | |
| 230 | new_parent = *parent; |
| 231 | need_new_parent = !has_single_node && (node->val_nr > 1); |
| 232 | |
| 233 | list_for_each_entry(chain, &node->val, list) { |
| 234 | char buf[128]; |
| 235 | |
| 236 | gtk_tree_store_append(store, &iter, &new_parent); |
| 237 | |
Namhyung Kim | 5ab250c | 2015-11-09 14:45:39 +0900 | [diff] [blame] | 238 | callchain_node__scnprintf_value(node, buf, sizeof(buf), total); |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 239 | gtk_tree_store_set(store, &iter, 0, buf, -1); |
| 240 | |
Andi Kleen | 2989cca | 2014-11-12 18:05:23 -0800 | [diff] [blame] | 241 | callchain_list__sym_name(chain, buf, sizeof(buf), false); |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 242 | gtk_tree_store_set(store, &iter, col, buf, -1); |
| 243 | |
| 244 | if (need_new_parent) { |
| 245 | /* |
| 246 | * Only show the top-most symbol in a callchain |
| 247 | * if it's not the only callchain. |
| 248 | */ |
| 249 | new_parent = iter; |
| 250 | need_new_parent = false; |
| 251 | } |
| 252 | } |
| 253 | |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 254 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
| 255 | child_total = node->children_hit; |
| 256 | else |
| 257 | child_total = total; |
| 258 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 259 | /* Now 'iter' contains info of the last callchain_list */ |
Namhyung Kim | 3cd99df | 2015-11-09 14:45:45 +0900 | [diff] [blame] | 260 | perf_gtk__add_callchain_graph(&node->rb_root, store, &iter, col, |
| 261 | child_total); |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 262 | } |
| 263 | } |
| 264 | |
Namhyung Kim | 3cd99df | 2015-11-09 14:45:45 +0900 | [diff] [blame] | 265 | static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store, |
| 266 | GtkTreeIter *parent, int col, u64 total) |
| 267 | { |
| 268 | if (callchain_param.mode == CHAIN_FLAT) |
| 269 | perf_gtk__add_callchain_flat(root, store, parent, col, total); |
Namhyung Kim | 2c6caff | 2015-11-09 14:45:46 +0900 | [diff] [blame] | 270 | else if (callchain_param.mode == CHAIN_FOLDED) |
| 271 | perf_gtk__add_callchain_folded(root, store, parent, col, total); |
Namhyung Kim | 3cd99df | 2015-11-09 14:45:45 +0900 | [diff] [blame] | 272 | else |
| 273 | perf_gtk__add_callchain_graph(root, store, parent, col, total); |
| 274 | } |
| 275 | |
Namhyung Kim | 450f390 | 2013-06-04 18:22:16 +0900 | [diff] [blame] | 276 | static void on_row_activated(GtkTreeView *view, GtkTreePath *path, |
| 277 | GtkTreeViewColumn *col __maybe_unused, |
| 278 | gpointer user_data __maybe_unused) |
| 279 | { |
| 280 | bool expanded = gtk_tree_view_row_expanded(view, path); |
| 281 | |
| 282 | if (expanded) |
| 283 | gtk_tree_view_collapse_row(view, path); |
| 284 | else |
| 285 | gtk_tree_view_expand_row(view, path, FALSE); |
| 286 | } |
| 287 | |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 288 | static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, |
| 289 | float min_pcnt) |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 290 | { |
| 291 | struct perf_hpp_fmt *fmt; |
| 292 | GType col_types[MAX_COLUMNS]; |
| 293 | GtkCellRenderer *renderer; |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 294 | GtkTreeStore *store; |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 295 | struct rb_node *nd; |
| 296 | GtkWidget *view; |
| 297 | int col_idx; |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 298 | int sym_col = -1; |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 299 | int nr_cols; |
| 300 | char s[512]; |
| 301 | |
| 302 | struct perf_hpp hpp = { |
| 303 | .buf = s, |
| 304 | .size = sizeof(s), |
| 305 | }; |
| 306 | |
| 307 | nr_cols = 0; |
| 308 | |
Jiri Olsa | cf09404 | 2016-01-18 10:24:17 +0100 | [diff] [blame^] | 309 | perf_hpp_list__for_each_format(&perf_hpp_list, fmt) |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 310 | col_types[nr_cols++] = G_TYPE_STRING; |
| 311 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 312 | store = gtk_tree_store_newv(nr_cols, col_types); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 313 | |
| 314 | view = gtk_tree_view_new(); |
| 315 | |
| 316 | renderer = gtk_cell_renderer_text_new(); |
| 317 | |
| 318 | col_idx = 0; |
| 319 | |
Jiri Olsa | cf09404 | 2016-01-18 10:24:17 +0100 | [diff] [blame^] | 320 | perf_hpp_list__for_each_format(&perf_hpp_list, fmt) { |
Namhyung Kim | 361459f | 2015-12-23 02:07:08 +0900 | [diff] [blame] | 321 | if (perf_hpp__should_skip(fmt, hists)) |
Namhyung Kim | e67d49a | 2014-03-18 13:00:59 +0900 | [diff] [blame] | 322 | continue; |
| 323 | |
Namhyung Kim | e4cf6f8 | 2014-05-23 18:49:33 +0900 | [diff] [blame] | 324 | /* |
| 325 | * XXX no way to determine where symcol column is.. |
| 326 | * Just use last column for now. |
| 327 | */ |
| 328 | if (perf_hpp__is_sort_entry(fmt)) |
| 329 | sym_col = col_idx; |
| 330 | |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 331 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), |
Namhyung Kim | 1ecd445 | 2014-07-31 14:47:40 +0900 | [diff] [blame] | 332 | -1, fmt->name, |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 333 | renderer, "markup", |
| 334 | col_idx++, NULL); |
| 335 | } |
| 336 | |
Namhyung Kim | 1a30942 | 2013-06-04 18:22:15 +0900 | [diff] [blame] | 337 | for (col_idx = 0; col_idx < nr_cols; col_idx++) { |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 338 | GtkTreeViewColumn *column; |
| 339 | |
Namhyung Kim | 1a30942 | 2013-06-04 18:22:15 +0900 | [diff] [blame] | 340 | column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx); |
| 341 | gtk_tree_view_column_set_resizable(column, TRUE); |
| 342 | |
| 343 | if (col_idx == sym_col) { |
| 344 | gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), |
| 345 | column); |
| 346 | } |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 347 | } |
| 348 | |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 349 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); |
| 350 | |
| 351 | g_object_unref(GTK_TREE_MODEL(store)); |
| 352 | |
| 353 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
| 354 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| 355 | GtkTreeIter iter; |
Namhyung Kim | f214833 | 2014-01-14 11:52:48 +0900 | [diff] [blame] | 356 | u64 total = hists__total_period(h->hists); |
Namhyung Kim | 1413566 | 2013-10-31 10:17:39 +0900 | [diff] [blame] | 357 | float percent; |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 358 | |
| 359 | if (h->filtered) |
| 360 | continue; |
| 361 | |
Namhyung Kim | 1413566 | 2013-10-31 10:17:39 +0900 | [diff] [blame] | 362 | percent = hist_entry__get_percent_limit(h); |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 363 | if (percent < min_pcnt) |
| 364 | continue; |
| 365 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 366 | gtk_tree_store_append(store, &iter, NULL); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 367 | |
| 368 | col_idx = 0; |
| 369 | |
Jiri Olsa | cf09404 | 2016-01-18 10:24:17 +0100 | [diff] [blame^] | 370 | perf_hpp_list__for_each_format(&perf_hpp_list, fmt) { |
Namhyung Kim | 361459f | 2015-12-23 02:07:08 +0900 | [diff] [blame] | 371 | if (perf_hpp__should_skip(fmt, h->hists)) |
Namhyung Kim | e67d49a | 2014-03-18 13:00:59 +0900 | [diff] [blame] | 372 | continue; |
| 373 | |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 374 | if (fmt->color) |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame] | 375 | fmt->color(fmt, &hpp, h); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 376 | else |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame] | 377 | fmt->entry(fmt, &hpp, h); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 378 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 379 | gtk_tree_store_set(store, &iter, col_idx++, s, -1); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 380 | } |
| 381 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 382 | if (symbol_conf.use_callchain && sort__has_sym) { |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 383 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
Namhyung Kim | e4cf6f8 | 2014-05-23 18:49:33 +0900 | [diff] [blame] | 384 | total = symbol_conf.cumulate_callchain ? |
| 385 | h->stat_acc->period : h->stat.period; |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 386 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 387 | perf_gtk__add_callchain(&h->sorted_chain, store, &iter, |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 388 | sym_col, total); |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 389 | } |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 390 | } |
| 391 | |
Namhyung Kim | 9d58d2f | 2013-06-04 18:22:17 +0900 | [diff] [blame] | 392 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE); |
| 393 | |
Namhyung Kim | 450f390 | 2013-06-04 18:22:16 +0900 | [diff] [blame] | 394 | g_signal_connect(view, "row-activated", |
| 395 | G_CALLBACK(on_row_activated), NULL); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 396 | gtk_container_add(GTK_CONTAINER(window), view); |
| 397 | } |
| 398 | |
| 399 | int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, |
| 400 | const char *help, |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 401 | struct hist_browser_timer *hbt __maybe_unused, |
| 402 | float min_pcnt) |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 403 | { |
| 404 | struct perf_evsel *pos; |
| 405 | GtkWidget *vbox; |
| 406 | GtkWidget *notebook; |
| 407 | GtkWidget *info_bar; |
| 408 | GtkWidget *statbar; |
| 409 | GtkWidget *window; |
| 410 | |
| 411 | signal(SIGSEGV, perf_gtk__signal); |
| 412 | signal(SIGFPE, perf_gtk__signal); |
| 413 | signal(SIGINT, perf_gtk__signal); |
| 414 | signal(SIGQUIT, perf_gtk__signal); |
| 415 | signal(SIGTERM, perf_gtk__signal); |
| 416 | |
| 417 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 418 | |
| 419 | gtk_window_set_title(GTK_WINDOW(window), "perf report"); |
| 420 | |
| 421 | g_signal_connect(window, "delete_event", gtk_main_quit, NULL); |
| 422 | |
| 423 | pgctx = perf_gtk__activate_context(window); |
| 424 | if (!pgctx) |
| 425 | return -1; |
| 426 | |
| 427 | vbox = gtk_vbox_new(FALSE, 0); |
| 428 | |
| 429 | notebook = gtk_notebook_new(); |
| 430 | |
Namhyung Kim | 6bf1a29 | 2012-12-21 17:20:14 +0900 | [diff] [blame] | 431 | gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); |
| 432 | |
| 433 | info_bar = perf_gtk__setup_info_bar(); |
| 434 | if (info_bar) |
| 435 | gtk_box_pack_start(GTK_BOX(vbox), info_bar, FALSE, FALSE, 0); |
| 436 | |
| 437 | statbar = perf_gtk__setup_statusbar(); |
| 438 | gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0); |
| 439 | |
| 440 | gtk_container_add(GTK_CONTAINER(window), vbox); |
| 441 | |
Arnaldo Carvalho de Melo | 0050f7a | 2014-01-10 10:37:27 -0300 | [diff] [blame] | 442 | evlist__for_each(evlist, pos) { |
Arnaldo Carvalho de Melo | 4ea062ed | 2014-10-09 13:13:41 -0300 | [diff] [blame] | 443 | struct hists *hists = evsel__hists(pos); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 444 | const char *evname = perf_evsel__name(pos); |
| 445 | GtkWidget *scrolled_window; |
| 446 | GtkWidget *tab_label; |
Namhyung Kim | 717e263 | 2013-01-22 18:09:44 +0900 | [diff] [blame] | 447 | char buf[512]; |
| 448 | size_t size = sizeof(buf); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 449 | |
Namhyung Kim | 717e263 | 2013-01-22 18:09:44 +0900 | [diff] [blame] | 450 | if (symbol_conf.event_group) { |
| 451 | if (!perf_evsel__is_group_leader(pos)) |
| 452 | continue; |
| 453 | |
| 454 | if (pos->nr_members > 1) { |
| 455 | perf_evsel__group_desc(pos, buf, size); |
| 456 | evname = buf; |
| 457 | } |
| 458 | } |
Namhyung Kim | fc24d7c | 2013-01-22 18:09:43 +0900 | [diff] [blame] | 459 | |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 460 | scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 461 | |
| 462 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
| 463 | GTK_POLICY_AUTOMATIC, |
| 464 | GTK_POLICY_AUTOMATIC); |
| 465 | |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 466 | perf_gtk__show_hists(scrolled_window, hists, min_pcnt); |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 467 | |
| 468 | tab_label = gtk_label_new(evname); |
| 469 | |
| 470 | gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label); |
| 471 | } |
| 472 | |
Namhyung Kim | 0da41ce9 | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 473 | gtk_widget_show_all(window); |
| 474 | |
| 475 | perf_gtk__resize_window(window); |
| 476 | |
| 477 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
| 478 | |
| 479 | ui_helpline__push(help); |
| 480 | |
| 481 | gtk_main(); |
| 482 | |
| 483 | perf_gtk__deactivate_context(&pgctx); |
| 484 | |
| 485 | return 0; |
| 486 | } |