7 #include "../helpline.h" 8 #include "../string2.h" 12 #define MAX_COLUMNS 32 25 len = va_arg(args,
int);
26 percent = va_arg(args,
double);
31 ret += scnprintf(buf, size, markup);
33 ret += scnprintf(buf + ret, size - ret, fmt, len, percent);
36 ret += scnprintf(buf + ret, size - ret,
"</span>");
41 #define __HPP_COLOR_PERCENT_FN(_type, _field) \ 42 static u64 he_get_##_field(struct hist_entry *he) \ 44 return he->stat._field; \ 47 static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ 48 struct perf_hpp *hpp, \ 49 struct hist_entry *he) \ 51 return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%", \ 52 __percent_color_snprintf, true); \ 55 #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ 56 static u64 he_get_acc_##_field(struct hist_entry *he) \ 58 return he->stat_acc->_field; \ 61 static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt, \ 62 struct perf_hpp *hpp, \ 63 struct hist_entry *he) \ 65 return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", \ 66 __percent_color_snprintf, true); \ 76 #undef __HPP_COLOR_PERCENT_FN 82 perf_gtk__hpp_color_overhead;
84 perf_gtk__hpp_color_overhead_sys;
86 perf_gtk__hpp_color_overhead_us;
88 perf_gtk__hpp_color_overhead_guest_sys;
90 perf_gtk__hpp_color_overhead_guest_us;
92 perf_gtk__hpp_color_overhead_acc;
96 GtkTreeIter *parent,
int col, u64 total)
99 bool has_single_node = (rb_first(root) == rb_last(root));
101 for (nd = rb_first(root); nd; nd = rb_next(nd)) {
104 GtkTreeIter iter, new_parent;
105 bool need_new_parent;
109 new_parent = *parent;
110 need_new_parent = !has_single_node;
117 gtk_tree_store_append(store, &iter, &new_parent);
120 gtk_tree_store_set(store, &iter, 0, buf, -1);
123 gtk_tree_store_set(store, &iter, col, buf, -1);
125 if (need_new_parent) {
131 need_new_parent =
false;
135 list_for_each_entry(chain, &node->
val,
list) {
138 gtk_tree_store_append(store, &iter, &new_parent);
141 gtk_tree_store_set(store, &iter, 0, buf, -1);
144 gtk_tree_store_set(store, &iter, col, buf, -1);
146 if (need_new_parent) {
152 need_new_parent =
false;
159 GtkTreeIter *parent,
int col, u64 total)
163 for (nd = rb_first(root); nd; nd = rb_next(nd)) {
168 char *
str, *str_alloc = NULL;
180 if (asprintf(&str,
"%s%s%s",
181 first ?
"" : str_alloc,
191 list_for_each_entry(chain, &node->
val,
list) {
196 if (asprintf(&str,
"%s%s%s",
197 first ?
"" : str_alloc,
207 gtk_tree_store_append(store, &iter, parent);
210 gtk_tree_store_set(store, &iter, 0, buf, -1);
212 gtk_tree_store_set(store, &iter, col, str, -1);
219 GtkTreeIter *parent,
int col, u64 total)
222 bool has_single_node = (rb_first(root) == rb_last(root));
224 for (nd = rb_first(root); nd; nd = rb_next(nd)) {
227 GtkTreeIter iter, new_parent;
228 bool need_new_parent;
233 new_parent = *parent;
234 need_new_parent = !has_single_node && (node->
val_nr > 1);
236 list_for_each_entry(chain, &node->
val,
list) {
239 gtk_tree_store_append(store, &iter, &new_parent);
242 gtk_tree_store_set(store, &iter, 0, buf, -1);
245 gtk_tree_store_set(store, &iter, col, buf, -1);
247 if (need_new_parent) {
253 need_new_parent =
false;
269 GtkTreeIter *parent,
int col, u64 total)
280 GtkTreeViewColumn *col __maybe_unused,
281 gpointer user_data __maybe_unused)
283 bool expanded = gtk_tree_view_row_expanded(view, path);
286 gtk_tree_view_collapse_row(view, path);
288 gtk_tree_view_expand_row(view, path, FALSE);
296 GtkCellRenderer *renderer;
313 col_types[nr_cols++] = G_TYPE_STRING;
315 store = gtk_tree_store_newv(nr_cols, col_types);
317 view = gtk_tree_view_new();
319 renderer = gtk_cell_renderer_text_new();
334 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
340 for (col_idx = 0; col_idx < nr_cols; col_idx++) {
341 GtkTreeViewColumn *column;
343 column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
344 gtk_tree_view_column_set_resizable(column, TRUE);
346 if (col_idx == sym_col) {
347 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
352 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
354 g_object_unref(GTK_TREE_MODEL(store));
356 for (nd = rb_first(&hists->
entries); nd; nd = rb_next(nd)) {
366 if (percent < min_pcnt)
369 gtk_tree_store_append(store, &iter, NULL);
378 fmt->
color(fmt, &hpp, h);
380 fmt->
entry(fmt, &hpp, h);
382 gtk_tree_store_set(store, &iter, col_idx++, s, -1);
396 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
398 g_signal_connect(view,
"row-activated",
400 gtk_container_add(GTK_CONTAINER(window), view);
404 struct rb_root *
root,
411 struct rb_node *
node;
418 for (node = rb_first(root); node; node = rb_next(node)) {
423 he = rb_entry(node,
struct hist_entry, rb_node);
428 if (percent < min_pcnt)
431 gtk_tree_store_append(store, &iter, parent);
440 fmt->
color(fmt, hpp, he);
442 fmt->
entry(fmt, hpp, he);
444 gtk_tree_store_set(store, &iter, col_idx++, hpp->
buf, -1);
453 ret = fmt->
color(fmt, hpp, he);
455 ret = fmt->
entry(fmt, hpp, he);
457 snprintf(hpp->
buf + ret, hpp->
size - ret,
" ");
461 gtk_tree_store_set(store, &iter, col_idx,
ltrim(
rtrim(bf)), -1);
475 snprintf(buf,
sizeof(buf),
"no entry >= %.2f%%",
478 gtk_tree_store_append(store, &child, &iter);
479 gtk_tree_store_set(store, &child, col_idx, buf, -1);
501 GtkCellRenderer *renderer;
508 bool first_node, first_col;
519 col_types[nr_cols++] = G_TYPE_STRING;
521 col_types[nr_cols++] = G_TYPE_STRING;
523 store = gtk_tree_store_newv(nr_cols, col_types);
524 view = gtk_tree_view_new();
525 renderer = gtk_cell_renderer_text_new();
533 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
542 list_for_each_entry_continue(fmt_node, &hists->
hpp_formats, list) {
556 fmt->
header(fmt, &hpp, hists, 0, NULL);
561 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
566 for (col_idx = 0; col_idx < nr_cols; col_idx++) {
567 GtkTreeViewColumn *column;
569 column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
570 gtk_tree_view_column_set_resizable(column, TRUE);
573 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
578 gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
579 g_object_unref(GTK_TREE_MODEL(store));
582 NULL, &hpp, min_pcnt);
584 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
586 g_signal_connect(view,
"row-activated",
588 gtk_container_add(GTK_CONTAINER(window), view);
609 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
611 gtk_window_set_title(GTK_WINDOW(window),
"perf report");
613 g_signal_connect(window,
"delete_event", gtk_main_quit, NULL);
619 vbox = gtk_vbox_new(FALSE, 0);
621 notebook = gtk_notebook_new();
623 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
627 gtk_box_pack_start(GTK_BOX(vbox), info_bar, FALSE, FALSE, 0);
630 gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0);
632 gtk_container_add(GTK_CONTAINER(window), vbox);
637 GtkWidget *scrolled_window;
638 GtkWidget *tab_label;
640 size_t size =
sizeof(buf);
652 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
654 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
655 GTK_POLICY_AUTOMATIC,
656 GTK_POLICY_AUTOMATIC);
663 tab_label = gtk_label_new(evname);
665 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label);
668 gtk_widget_show_all(window);
672 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
int perf_gtk__deactivate_context(struct perf_gtk_context **ctx)
#define __HPP_COLOR_PERCENT_FN(_type, _field)
bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *format)
u64 hists__total_period(struct hists *hists)
static bool perf_hpp__should_skip(struct perf_hpp_fmt *format, struct hists *hists)
int(* entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he)
static void perf_gtk__add_callchain_folded(struct rb_root *root, GtkTreeStore *store, GtkTreeIter *parent, int col, u64 total)
static GtkWidget * perf_gtk__setup_info_bar(void)
char * callchain_list__sym_name(struct callchain_list *cl, char *bf, size_t bfsize, bool show_dso)
struct perf_hpp_list * hpp_list
static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists, float min_pcnt)
static void perf_gtk__add_hierarchy_entries(struct hists *hists, struct rb_root *root, GtkTreeStore *store, GtkTreeIter *parent, struct perf_hpp *hpp, float min_pcnt)
static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store, GtkTreeIter *parent, int col, u64 total)
int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help, struct hist_browser_timer *hbt __maybe_unused, float min_pcnt)
#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field)
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format)
static struct hists * evsel__hists(struct perf_evsel *evsel)
static void perf_gtk__add_callchain_flat(struct rb_root *root, GtkTreeStore *store, GtkTreeIter *parent, int col, u64 total)
#define perf_hpp_list__for_each_format(_list, format)
static void on_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *col __maybe_unused, gpointer user_data __maybe_unused)
struct list_head hpp_formats
void ui_helpline__push(const char *msg)
static __pure bool hist_entry__has_callchains(struct hist_entry *he)
int perf_evsel__group_desc(struct perf_evsel *evsel, char *buf, size_t size)
int(* header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hists *hists, int line, int *span)
#define evlist__for_each_entry(evlist, evsel)
static int str(yyscan_t scanner, int token)
struct rb_root sorted_chain
void perf_gtk__signal(int sig)
#define hists__has(__h, __f)
bool hist_entry__has_hierarchy_children(struct hist_entry *he, float limit)
struct perf_hpp_fmt perf_hpp__format[]
void perf_gtk__init_hpp(void)
const char * perf_evsel__name(struct perf_evsel *evsel)
static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt,...)
struct perf_gtk_context * perf_gtk__activate_context(GtkWidget *window)
GtkWidget * perf_gtk__setup_statusbar(void)
#define hists__for_each_format(hists, format)
static int sym(yyscan_t scanner, int type, int config)
const char * perf_gtk__get_percent_color(double percent)
int(* color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, struct hist_entry *he)
static void advance_hpp(struct perf_hpp *hpp, int inc)
static __pure bool hists__has_callchains(struct hists *hists)
static double percent(int st, int tot)
struct perf_gtk_context * pgctx
static bool perf_evsel__is_group_leader(const struct perf_evsel *evsel)
static void perf_gtk__add_callchain_graph(struct rb_root *root, GtkTreeStore *store, GtkTreeIter *parent, int col, u64 total)
int callchain_node__make_parent_list(struct callchain_node *node)
struct he_stat * stat_acc
void perf_gtk__resize_window(GtkWidget *window)
static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, float min_pcnt)
struct list_head parent_val
static float hist_entry__get_percent_limit(struct hist_entry *he)
def store(time, event, cpu, thread, val, ena, run)
char * callchain_node__scnprintf_value(struct callchain_node *node, char *bf, size_t bfsize, u64 total)