Namhyung Kim | 0da41ce | 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 | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 11 | static int __percent_color_snprintf(char *buf, size_t size, double percent) |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 12 | { |
| 13 | int ret = 0; |
| 14 | const char *markup; |
| 15 | |
| 16 | markup = perf_gtk__get_percent_color(percent); |
| 17 | if (markup) |
| 18 | ret += scnprintf(buf, size, markup); |
| 19 | |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 20 | ret += scnprintf(buf + ret, size - ret, " %6.2f%%", percent); |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 21 | |
| 22 | if (markup) |
| 23 | ret += scnprintf(buf + ret, size - ret, "</span>"); |
| 24 | |
| 25 | return ret; |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 26 | } |
| 27 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 28 | |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 29 | static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he, |
| 30 | u64 (*get_field)(struct hist_entry *)) |
| 31 | { |
| 32 | int ret; |
| 33 | double percent = 0.0; |
| 34 | struct hists *hists = he->hists; |
Namhyung Kim | 759ff49 | 2013-03-05 14:53:26 +0900 | [diff] [blame] | 35 | struct perf_evsel *evsel = hists_to_evsel(hists); |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 36 | |
| 37 | if (hists->stats.total_period) |
| 38 | percent = 100.0 * get_field(he) / hists->stats.total_period; |
| 39 | |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 40 | ret = __percent_color_snprintf(hpp->buf, hpp->size, percent); |
| 41 | |
Namhyung Kim | 759ff49 | 2013-03-05 14:53:26 +0900 | [diff] [blame] | 42 | if (perf_evsel__is_group_event(evsel)) { |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 43 | int prev_idx, idx_delta; |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 44 | struct hist_entry *pair; |
| 45 | int nr_members = evsel->nr_members; |
| 46 | |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 47 | prev_idx = perf_evsel__group_idx(evsel); |
| 48 | |
| 49 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { |
| 50 | u64 period = get_field(pair); |
| 51 | u64 total = pair->hists->stats.total_period; |
| 52 | |
| 53 | evsel = hists_to_evsel(pair->hists); |
| 54 | idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1; |
| 55 | |
| 56 | while (idx_delta--) { |
| 57 | /* |
| 58 | * zero-fill group members in the middle which |
| 59 | * have no sample |
| 60 | */ |
| 61 | ret += __percent_color_snprintf(hpp->buf + ret, |
| 62 | hpp->size - ret, |
| 63 | 0.0); |
| 64 | } |
| 65 | |
| 66 | percent = 100.0 * period / total; |
| 67 | ret += __percent_color_snprintf(hpp->buf + ret, |
| 68 | hpp->size - ret, |
| 69 | percent); |
| 70 | |
| 71 | prev_idx = perf_evsel__group_idx(evsel); |
| 72 | } |
| 73 | |
| 74 | idx_delta = nr_members - prev_idx - 1; |
| 75 | |
| 76 | while (idx_delta--) { |
| 77 | /* |
| 78 | * zero-fill group members at last which have no sample |
| 79 | */ |
| 80 | ret += __percent_color_snprintf(hpp->buf + ret, |
| 81 | hpp->size - ret, |
| 82 | 0.0); |
| 83 | } |
| 84 | } |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 85 | return ret; |
| 86 | } |
| 87 | |
| 88 | #define __HPP_COLOR_PERCENT_FN(_type, _field) \ |
| 89 | static u64 he_get_##_field(struct hist_entry *he) \ |
| 90 | { \ |
| 91 | return he->stat._field; \ |
| 92 | } \ |
| 93 | \ |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame^] | 94 | static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
| 95 | struct perf_hpp *hpp, \ |
Namhyung Kim | 843985e | 2013-01-22 18:09:36 +0900 | [diff] [blame] | 96 | struct hist_entry *he) \ |
| 97 | { \ |
| 98 | return __hpp__color_fmt(hpp, he, he_get_##_field); \ |
| 99 | } |
| 100 | |
| 101 | __HPP_COLOR_PERCENT_FN(overhead, period) |
| 102 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys) |
| 103 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us) |
| 104 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys) |
| 105 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us) |
| 106 | |
| 107 | #undef __HPP_COLOR_PERCENT_FN |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 108 | |
| 109 | |
| 110 | void perf_gtk__init_hpp(void) |
| 111 | { |
| 112 | perf_hpp__column_enable(PERF_HPP__OVERHEAD); |
| 113 | |
| 114 | perf_hpp__init(); |
| 115 | |
| 116 | perf_hpp__format[PERF_HPP__OVERHEAD].color = |
| 117 | perf_gtk__hpp_color_overhead; |
| 118 | perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color = |
| 119 | perf_gtk__hpp_color_overhead_sys; |
| 120 | perf_hpp__format[PERF_HPP__OVERHEAD_US].color = |
| 121 | perf_gtk__hpp_color_overhead_us; |
| 122 | perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_SYS].color = |
| 123 | perf_gtk__hpp_color_overhead_guest_sys; |
| 124 | perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_US].color = |
| 125 | perf_gtk__hpp_color_overhead_guest_us; |
| 126 | } |
| 127 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 128 | static void callchain_list__sym_name(struct callchain_list *cl, |
| 129 | char *bf, size_t bfsize) |
| 130 | { |
| 131 | if (cl->ms.sym) |
| 132 | scnprintf(bf, bfsize, "%s", cl->ms.sym->name); |
| 133 | else |
| 134 | scnprintf(bf, bfsize, "%#" PRIx64, cl->ip); |
| 135 | } |
| 136 | |
| 137 | static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store, |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 138 | GtkTreeIter *parent, int col, u64 total) |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 139 | { |
| 140 | struct rb_node *nd; |
| 141 | bool has_single_node = (rb_first(root) == rb_last(root)); |
| 142 | |
| 143 | for (nd = rb_first(root); nd; nd = rb_next(nd)) { |
| 144 | struct callchain_node *node; |
| 145 | struct callchain_list *chain; |
| 146 | GtkTreeIter iter, new_parent; |
| 147 | bool need_new_parent; |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 148 | double percent; |
| 149 | u64 hits, child_total; |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 150 | |
| 151 | node = rb_entry(nd, struct callchain_node, rb_node); |
| 152 | |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 153 | hits = callchain_cumul_hits(node); |
| 154 | percent = 100.0 * hits / total; |
| 155 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 156 | new_parent = *parent; |
| 157 | need_new_parent = !has_single_node && (node->val_nr > 1); |
| 158 | |
| 159 | list_for_each_entry(chain, &node->val, list) { |
| 160 | char buf[128]; |
| 161 | |
| 162 | gtk_tree_store_append(store, &iter, &new_parent); |
| 163 | |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 164 | scnprintf(buf, sizeof(buf), "%5.2f%%", percent); |
| 165 | gtk_tree_store_set(store, &iter, 0, buf, -1); |
| 166 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 167 | callchain_list__sym_name(chain, buf, sizeof(buf)); |
| 168 | gtk_tree_store_set(store, &iter, col, buf, -1); |
| 169 | |
| 170 | if (need_new_parent) { |
| 171 | /* |
| 172 | * Only show the top-most symbol in a callchain |
| 173 | * if it's not the only callchain. |
| 174 | */ |
| 175 | new_parent = iter; |
| 176 | need_new_parent = false; |
| 177 | } |
| 178 | } |
| 179 | |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 180 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
| 181 | child_total = node->children_hit; |
| 182 | else |
| 183 | child_total = total; |
| 184 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 185 | /* Now 'iter' contains info of the last callchain_list */ |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 186 | perf_gtk__add_callchain(&node->rb_root, store, &iter, col, |
| 187 | child_total); |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
Namhyung Kim | 450f390 | 2013-06-04 18:22:16 +0900 | [diff] [blame] | 191 | static void on_row_activated(GtkTreeView *view, GtkTreePath *path, |
| 192 | GtkTreeViewColumn *col __maybe_unused, |
| 193 | gpointer user_data __maybe_unused) |
| 194 | { |
| 195 | bool expanded = gtk_tree_view_row_expanded(view, path); |
| 196 | |
| 197 | if (expanded) |
| 198 | gtk_tree_view_collapse_row(view, path); |
| 199 | else |
| 200 | gtk_tree_view_expand_row(view, path, FALSE); |
| 201 | } |
| 202 | |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 203 | static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, |
| 204 | float min_pcnt) |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 205 | { |
| 206 | struct perf_hpp_fmt *fmt; |
| 207 | GType col_types[MAX_COLUMNS]; |
| 208 | GtkCellRenderer *renderer; |
| 209 | struct sort_entry *se; |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 210 | GtkTreeStore *store; |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 211 | struct rb_node *nd; |
| 212 | GtkWidget *view; |
| 213 | int col_idx; |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 214 | int sym_col = -1; |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 215 | int nr_cols; |
| 216 | char s[512]; |
| 217 | |
| 218 | struct perf_hpp hpp = { |
| 219 | .buf = s, |
| 220 | .size = sizeof(s), |
Namhyung Kim | cb16008 | 2013-01-22 18:09:40 +0900 | [diff] [blame] | 221 | .ptr = hists_to_evsel(hists), |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | nr_cols = 0; |
| 225 | |
| 226 | perf_hpp__for_each_format(fmt) |
| 227 | col_types[nr_cols++] = G_TYPE_STRING; |
| 228 | |
| 229 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
| 230 | if (se->elide) |
| 231 | continue; |
| 232 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 233 | if (se == &sort_sym) |
| 234 | sym_col = nr_cols; |
| 235 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 236 | col_types[nr_cols++] = G_TYPE_STRING; |
| 237 | } |
| 238 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 239 | store = gtk_tree_store_newv(nr_cols, col_types); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 240 | |
| 241 | view = gtk_tree_view_new(); |
| 242 | |
| 243 | renderer = gtk_cell_renderer_text_new(); |
| 244 | |
| 245 | col_idx = 0; |
| 246 | |
| 247 | perf_hpp__for_each_format(fmt) { |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame^] | 248 | fmt->header(fmt, &hpp); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 249 | |
| 250 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), |
Namhyung Kim | 34b9564 | 2013-01-22 18:09:42 +0900 | [diff] [blame] | 251 | -1, ltrim(s), |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 252 | renderer, "markup", |
| 253 | col_idx++, NULL); |
| 254 | } |
| 255 | |
| 256 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
| 257 | if (se->elide) |
| 258 | continue; |
| 259 | |
| 260 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), |
| 261 | -1, se->se_header, |
| 262 | renderer, "text", |
| 263 | col_idx++, NULL); |
| 264 | } |
| 265 | |
Namhyung Kim | 1a30942 | 2013-06-04 18:22:15 +0900 | [diff] [blame] | 266 | for (col_idx = 0; col_idx < nr_cols; col_idx++) { |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 267 | GtkTreeViewColumn *column; |
| 268 | |
Namhyung Kim | 1a30942 | 2013-06-04 18:22:15 +0900 | [diff] [blame] | 269 | column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx); |
| 270 | gtk_tree_view_column_set_resizable(column, TRUE); |
| 271 | |
| 272 | if (col_idx == sym_col) { |
| 273 | gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view), |
| 274 | column); |
| 275 | } |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 276 | } |
| 277 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 278 | gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store)); |
| 279 | |
| 280 | g_object_unref(GTK_TREE_MODEL(store)); |
| 281 | |
| 282 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
| 283 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| 284 | GtkTreeIter iter; |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 285 | float percent = h->stat.period * 100.0 / |
| 286 | hists->stats.total_period; |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 287 | |
| 288 | if (h->filtered) |
| 289 | continue; |
| 290 | |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 291 | if (percent < min_pcnt) |
| 292 | continue; |
| 293 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 294 | gtk_tree_store_append(store, &iter, NULL); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 295 | |
| 296 | col_idx = 0; |
| 297 | |
| 298 | perf_hpp__for_each_format(fmt) { |
| 299 | if (fmt->color) |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame^] | 300 | fmt->color(fmt, &hpp, h); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 301 | else |
Jiri Olsa | 2c5d4b4 | 2013-01-31 23:31:11 +0100 | [diff] [blame^] | 302 | fmt->entry(fmt, &hpp, h); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 303 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 304 | gtk_tree_store_set(store, &iter, col_idx++, s, -1); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | list_for_each_entry(se, &hist_entry__sort_list, list) { |
| 308 | if (se->elide) |
| 309 | continue; |
| 310 | |
| 311 | se->se_snprintf(h, s, ARRAY_SIZE(s), |
| 312 | hists__col_len(hists, se->se_width_idx)); |
| 313 | |
Namhyung Kim | f1d9a53 | 2013-06-04 18:22:12 +0900 | [diff] [blame] | 314 | gtk_tree_store_set(store, &iter, col_idx++, s, -1); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 315 | } |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 316 | |
| 317 | if (symbol_conf.use_callchain && sort__has_sym) { |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 318 | u64 total; |
| 319 | |
| 320 | if (callchain_param.mode == CHAIN_GRAPH_REL) |
| 321 | total = h->stat.period; |
| 322 | else |
| 323 | total = hists->stats.total_period; |
| 324 | |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 325 | perf_gtk__add_callchain(&h->sorted_chain, store, &iter, |
Namhyung Kim | cc60f24 | 2013-06-04 18:22:14 +0900 | [diff] [blame] | 326 | sym_col, total); |
Namhyung Kim | 2bbc587 | 2013-06-04 18:22:13 +0900 | [diff] [blame] | 327 | } |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 328 | } |
| 329 | |
Namhyung Kim | 9d58d2f | 2013-06-04 18:22:17 +0900 | [diff] [blame] | 330 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE); |
| 331 | |
Namhyung Kim | 450f390 | 2013-06-04 18:22:16 +0900 | [diff] [blame] | 332 | g_signal_connect(view, "row-activated", |
| 333 | G_CALLBACK(on_row_activated), NULL); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 334 | gtk_container_add(GTK_CONTAINER(window), view); |
| 335 | } |
| 336 | |
| 337 | int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, |
| 338 | const char *help, |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 339 | struct hist_browser_timer *hbt __maybe_unused, |
| 340 | float min_pcnt) |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 341 | { |
| 342 | struct perf_evsel *pos; |
| 343 | GtkWidget *vbox; |
| 344 | GtkWidget *notebook; |
| 345 | GtkWidget *info_bar; |
| 346 | GtkWidget *statbar; |
| 347 | GtkWidget *window; |
| 348 | |
| 349 | signal(SIGSEGV, perf_gtk__signal); |
| 350 | signal(SIGFPE, perf_gtk__signal); |
| 351 | signal(SIGINT, perf_gtk__signal); |
| 352 | signal(SIGQUIT, perf_gtk__signal); |
| 353 | signal(SIGTERM, perf_gtk__signal); |
| 354 | |
| 355 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 356 | |
| 357 | gtk_window_set_title(GTK_WINDOW(window), "perf report"); |
| 358 | |
| 359 | g_signal_connect(window, "delete_event", gtk_main_quit, NULL); |
| 360 | |
| 361 | pgctx = perf_gtk__activate_context(window); |
| 362 | if (!pgctx) |
| 363 | return -1; |
| 364 | |
| 365 | vbox = gtk_vbox_new(FALSE, 0); |
| 366 | |
| 367 | notebook = gtk_notebook_new(); |
| 368 | |
Namhyung Kim | 6bf1a29 | 2012-12-21 17:20:14 +0900 | [diff] [blame] | 369 | gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); |
| 370 | |
| 371 | info_bar = perf_gtk__setup_info_bar(); |
| 372 | if (info_bar) |
| 373 | gtk_box_pack_start(GTK_BOX(vbox), info_bar, FALSE, FALSE, 0); |
| 374 | |
| 375 | statbar = perf_gtk__setup_statusbar(); |
| 376 | gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0); |
| 377 | |
| 378 | gtk_container_add(GTK_CONTAINER(window), vbox); |
| 379 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 380 | list_for_each_entry(pos, &evlist->entries, node) { |
| 381 | struct hists *hists = &pos->hists; |
| 382 | const char *evname = perf_evsel__name(pos); |
| 383 | GtkWidget *scrolled_window; |
| 384 | GtkWidget *tab_label; |
Namhyung Kim | 717e263 | 2013-01-22 18:09:44 +0900 | [diff] [blame] | 385 | char buf[512]; |
| 386 | size_t size = sizeof(buf); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 387 | |
Namhyung Kim | 717e263 | 2013-01-22 18:09:44 +0900 | [diff] [blame] | 388 | if (symbol_conf.event_group) { |
| 389 | if (!perf_evsel__is_group_leader(pos)) |
| 390 | continue; |
| 391 | |
| 392 | if (pos->nr_members > 1) { |
| 393 | perf_evsel__group_desc(pos, buf, size); |
| 394 | evname = buf; |
| 395 | } |
| 396 | } |
Namhyung Kim | fc24d7c | 2013-01-22 18:09:43 +0900 | [diff] [blame] | 397 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 398 | scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 399 | |
| 400 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
| 401 | GTK_POLICY_AUTOMATIC, |
| 402 | GTK_POLICY_AUTOMATIC); |
| 403 | |
Namhyung Kim | 064f198 | 2013-05-14 11:09:04 +0900 | [diff] [blame] | 404 | perf_gtk__show_hists(scrolled_window, hists, min_pcnt); |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 405 | |
| 406 | tab_label = gtk_label_new(evname); |
| 407 | |
| 408 | gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label); |
| 409 | } |
| 410 | |
Namhyung Kim | 0da41ce | 2012-12-21 17:20:13 +0900 | [diff] [blame] | 411 | gtk_widget_show_all(window); |
| 412 | |
| 413 | perf_gtk__resize_window(window); |
| 414 | |
| 415 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
| 416 | |
| 417 | ui_helpline__push(help); |
| 418 | |
| 419 | gtk_main(); |
| 420 | |
| 421 | perf_gtk__deactivate_context(&pgctx); |
| 422 | |
| 423 | return 0; |
| 424 | } |