Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include "../evlist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include "../callchain.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include "../evsel.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include "../sort.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include "../hist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include "../helpline.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "../string2.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "gtk.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <stdlib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define MAX_COLUMNS			32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static int __percent_color_snprintf(struct perf_hpp *hpp, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	va_list args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	double percent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	const char *markup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	char *buf = hpp->buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	size_t size = hpp->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	va_start(args, fmt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	len = va_arg(args, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	percent = va_arg(args, double);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	va_end(args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	markup = perf_gtk__get_percent_color(percent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	if (markup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		ret += scnprintf(buf, size, markup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	ret += scnprintf(buf + ret, size - ret, fmt, len, percent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	if (markup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		ret += scnprintf(buf + ret, size - ret, "</span>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define __HPP_COLOR_PERCENT_FN(_type, _field)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static u64 he_get_##_field(struct hist_entry *he)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return he->stat._field;							\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 				       struct perf_hpp *hpp,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				       struct hist_entry *he)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	return hpp__fmt(fmt, hpp, he, he_get_##_field, " %*.2f%%",		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 			__percent_color_snprintf, true);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define __HPP_COLOR_ACC_PERCENT_FN(_type, _field)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static u64 he_get_acc_##_field(struct hist_entry *he)				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	return he->stat_acc->_field;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) }										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 				       struct perf_hpp *hpp,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				       struct hist_entry *he)			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {										\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return hpp__fmt_acc(fmt, hpp, he, he_get_acc_##_field, " %*.2f%%", 	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			    __percent_color_snprintf, true);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) __HPP_COLOR_PERCENT_FN(overhead, period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) __HPP_COLOR_PERCENT_FN(overhead_us, period_us)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) __HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #undef __HPP_COLOR_PERCENT_FN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) void perf_gtk__init_hpp(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	perf_hpp__format[PERF_HPP__OVERHEAD].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 				perf_gtk__hpp_color_overhead;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 				perf_gtk__hpp_color_overhead_sys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	perf_hpp__format[PERF_HPP__OVERHEAD_US].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 				perf_gtk__hpp_color_overhead_us;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_SYS].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 				perf_gtk__hpp_color_overhead_guest_sys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	perf_hpp__format[PERF_HPP__OVERHEAD_GUEST_US].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				perf_gtk__hpp_color_overhead_guest_us;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 				perf_gtk__hpp_color_overhead_acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void perf_gtk__add_callchain_flat(struct rb_root *root, GtkTreeStore *store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 					 GtkTreeIter *parent, int col, u64 total)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct rb_node *nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	bool has_single_node = (rb_first(root) == rb_last(root));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	for (nd = rb_first(root); nd; nd = rb_next(nd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		struct callchain_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		struct callchain_list *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		GtkTreeIter iter, new_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		bool need_new_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		node = rb_entry(nd, struct callchain_node, rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		new_parent = *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		need_new_parent = !has_single_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		callchain_node__make_parent_list(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		list_for_each_entry(chain, &node->parent_val, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			char buf[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			gtk_tree_store_append(store, &iter, &new_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			callchain_node__scnprintf_value(node, buf, sizeof(buf), total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			gtk_tree_store_set(store, &iter, 0, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			callchain_list__sym_name(chain, buf, sizeof(buf), false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			gtk_tree_store_set(store, &iter, col, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			if (need_new_parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 				 * Only show the top-most symbol in a callchain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 				 * if it's not the only callchain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 				new_parent = iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 				need_new_parent = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		list_for_each_entry(chain, &node->val, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			char buf[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			gtk_tree_store_append(store, &iter, &new_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			callchain_node__scnprintf_value(node, buf, sizeof(buf), total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			gtk_tree_store_set(store, &iter, 0, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			callchain_list__sym_name(chain, buf, sizeof(buf), false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			gtk_tree_store_set(store, &iter, col, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			if (need_new_parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				 * Only show the top-most symbol in a callchain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 				 * if it's not the only callchain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 				new_parent = iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 				need_new_parent = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static void perf_gtk__add_callchain_folded(struct rb_root *root, GtkTreeStore *store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 					   GtkTreeIter *parent, int col, u64 total)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct rb_node *nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	for (nd = rb_first(root); nd; nd = rb_next(nd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		struct callchain_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		struct callchain_list *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		char buf[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		char *str, *str_alloc = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		bool first = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		node = rb_entry(nd, struct callchain_node, rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		callchain_node__make_parent_list(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		list_for_each_entry(chain, &node->parent_val, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			char name[1024];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			callchain_list__sym_name(chain, name, sizeof(name), false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			if (asprintf(&str, "%s%s%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				     first ? "" : str_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				     first ? "" : symbol_conf.field_sep ?: "; ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				     name) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			first = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			free(str_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			str_alloc = str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		list_for_each_entry(chain, &node->val, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			char name[1024];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			callchain_list__sym_name(chain, name, sizeof(name), false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			if (asprintf(&str, "%s%s%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				     first ? "" : str_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				     first ? "" : symbol_conf.field_sep ?: "; ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				     name) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 				return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			first = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			free(str_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			str_alloc = str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		gtk_tree_store_append(store, &iter, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		callchain_node__scnprintf_value(node, buf, sizeof(buf), total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		gtk_tree_store_set(store, &iter, 0, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		gtk_tree_store_set(store, &iter, col, str, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		free(str_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static void perf_gtk__add_callchain_graph(struct rb_root *root, GtkTreeStore *store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 					  GtkTreeIter *parent, int col, u64 total)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	struct rb_node *nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	bool has_single_node = (rb_first(root) == rb_last(root));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	for (nd = rb_first(root); nd; nd = rb_next(nd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		struct callchain_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		struct callchain_list *chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		GtkTreeIter iter, new_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		bool need_new_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		u64 child_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		node = rb_entry(nd, struct callchain_node, rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		new_parent = *parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		need_new_parent = !has_single_node && (node->val_nr > 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		list_for_each_entry(chain, &node->val, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 			char buf[128];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			gtk_tree_store_append(store, &iter, &new_parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			callchain_node__scnprintf_value(node, buf, sizeof(buf), total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			gtk_tree_store_set(store, &iter, 0, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			callchain_list__sym_name(chain, buf, sizeof(buf), false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			gtk_tree_store_set(store, &iter, col, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			if (need_new_parent) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 				 * Only show the top-most symbol in a callchain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 				 * if it's not the only callchain.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 				new_parent = iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 				need_new_parent = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		if (callchain_param.mode == CHAIN_GRAPH_REL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			child_total = node->children_hit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			child_total = total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		/* Now 'iter' contains info of the last callchain_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		perf_gtk__add_callchain_graph(&node->rb_root, store, &iter, col,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 					      child_total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static void perf_gtk__add_callchain(struct rb_root *root, GtkTreeStore *store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 				    GtkTreeIter *parent, int col, u64 total)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	if (callchain_param.mode == CHAIN_FLAT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		perf_gtk__add_callchain_flat(root, store, parent, col, total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	else if (callchain_param.mode == CHAIN_FOLDED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		perf_gtk__add_callchain_folded(root, store, parent, col, total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		perf_gtk__add_callchain_graph(root, store, parent, col, total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static void on_row_activated(GtkTreeView *view, GtkTreePath *path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 			     GtkTreeViewColumn *col __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			     gpointer user_data __maybe_unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	bool expanded = gtk_tree_view_row_expanded(view, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	if (expanded)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		gtk_tree_view_collapse_row(view, path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 		gtk_tree_view_expand_row(view, path, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				 float min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	struct perf_hpp_fmt *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	GType col_types[MAX_COLUMNS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	GtkCellRenderer *renderer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	GtkTreeStore *store;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	struct rb_node *nd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	GtkWidget *view;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	int col_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	int sym_col = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	int nr_cols;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	char s[512];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	struct perf_hpp hpp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		.buf		= s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		.size		= sizeof(s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	nr_cols = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	hists__for_each_format(hists, fmt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		col_types[nr_cols++] = G_TYPE_STRING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	store = gtk_tree_store_newv(nr_cols, col_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	view = gtk_tree_view_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	col_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	hists__for_each_format(hists, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		if (perf_hpp__should_skip(fmt, hists))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		 * XXX no way to determine where symcol column is..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		 *     Just use last column for now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		if (perf_hpp__is_sort_entry(fmt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			sym_col = col_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 							    -1, fmt->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 							    renderer, "markup",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 							    col_idx++, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	for (col_idx = 0; col_idx < nr_cols; col_idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		gtk_tree_view_column_set_resizable(column, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		if (col_idx == sym_col) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 							  column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	g_object_unref(GTK_TREE_MODEL(store));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	for (nd = rb_first_cached(&hists->entries); nd; nd = rb_next(nd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		u64 total = hists__total_period(h->hists);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		float percent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		if (h->filtered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		percent = hist_entry__get_percent_limit(h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 		if (percent < min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		gtk_tree_store_append(store, &iter, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		col_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		hists__for_each_format(hists, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 			if (perf_hpp__should_skip(fmt, h->hists))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			if (fmt->color)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 				fmt->color(fmt, &hpp, h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 				fmt->entry(fmt, &hpp, h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 			gtk_tree_store_set(store, &iter, col_idx++, s, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		if (hist_entry__has_callchains(h) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 		    symbol_conf.use_callchain && hists__has(hists, sym)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 			if (callchain_param.mode == CHAIN_GRAPH_REL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 				total = symbol_conf.cumulate_callchain ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 					h->stat_acc->period : h->stat.period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			perf_gtk__add_callchain(&h->sorted_chain, store, &iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 						sym_col, total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	g_signal_connect(view, "row-activated",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 			 G_CALLBACK(on_row_activated), NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	gtk_container_add(GTK_CONTAINER(window), view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static void perf_gtk__add_hierarchy_entries(struct hists *hists,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 					    struct rb_root_cached *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 					    GtkTreeStore *store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 					    GtkTreeIter *parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 					    struct perf_hpp *hpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 					    float min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	int col_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	struct rb_node *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	struct hist_entry *he;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	struct perf_hpp_fmt *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	struct perf_hpp_list_node *fmt_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	u64 total = hists__total_period(hists);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	for (node = rb_first_cached(root); node; node = rb_next(node)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		GtkTreeIter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		float percent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		char *bf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		he = rb_entry(node, struct hist_entry, rb_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 		if (he->filtered)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		percent = hist_entry__get_percent_limit(he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 		if (percent < min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		gtk_tree_store_append(store, &iter, parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		col_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 		/* the first hpp_list_node is for overhead columns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		fmt_node = list_first_entry(&hists->hpp_formats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 					    struct perf_hpp_list_node, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			if (fmt->color)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 				fmt->color(fmt, hpp, he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 				fmt->entry(fmt, hpp, he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			gtk_tree_store_set(store, &iter, col_idx++, hpp->buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		bf = hpp->buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		size = hpp->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		perf_hpp_list__for_each_format(he->hpp_list, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 			int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			if (fmt->color)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 				ret = fmt->color(fmt, hpp, he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 				ret = fmt->entry(fmt, hpp, he);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 			snprintf(hpp->buf + ret, hpp->size - ret, "  ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			advance_hpp(hpp, ret + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		gtk_tree_store_set(store, &iter, col_idx, strim(bf), -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		if (!he->leaf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 			hpp->buf = bf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 			hpp->size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 			perf_gtk__add_hierarchy_entries(hists, &he->hroot_out,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 							store, &iter, hpp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 							min_pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			if (!hist_entry__has_hierarchy_children(he, min_pcnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 				char buf[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 				GtkTreeIter child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 				snprintf(buf, sizeof(buf), "no entry >= %.2f%%",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 					 min_pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 				gtk_tree_store_append(store, &child, &iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 				gtk_tree_store_set(store, &child, col_idx, buf, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		if (he->leaf && hist_entry__has_callchains(he) && symbol_conf.use_callchain) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 			if (callchain_param.mode == CHAIN_GRAPH_REL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 				total = symbol_conf.cumulate_callchain ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 					he->stat_acc->period : he->stat.period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 			perf_gtk__add_callchain(&he->sorted_chain, store, &iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 						col_idx, total);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 				     float min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	struct perf_hpp_fmt *fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	struct perf_hpp_list_node *fmt_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 	GType col_types[MAX_COLUMNS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	GtkCellRenderer *renderer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	GtkTreeStore *store;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	GtkWidget *view;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	int col_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	int nr_cols = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	char s[512];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	char buf[512];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	bool first_node, first_col;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	struct perf_hpp hpp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		.buf		= s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		.size		= sizeof(s),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	hists__for_each_format(hists, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		if (perf_hpp__is_sort_entry(fmt) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 		    perf_hpp__is_dynamic_entry(fmt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		col_types[nr_cols++] = G_TYPE_STRING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	col_types[nr_cols++] = G_TYPE_STRING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	store = gtk_tree_store_newv(nr_cols, col_types);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	view = gtk_tree_view_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	renderer = gtk_cell_renderer_text_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	col_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	/* the first hpp_list_node is for overhead columns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	fmt_node = list_first_entry(&hists->hpp_formats,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 				    struct perf_hpp_list_node, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 		gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 							    -1, fmt->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 							    renderer, "markup",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 							    col_idx++, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	/* construct merged column header since sort keys share single column */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	buf[0] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	first_node = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 	list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		if (!first_node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 			strcat(buf, " / ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		first_node = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 		first_col = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		perf_hpp_list__for_each_format(&fmt_node->hpp ,fmt) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 			if (perf_hpp__should_skip(fmt, hists))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 			if (!first_col)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 				strcat(buf, "+");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 			first_col = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 			fmt->header(fmt, &hpp, hists, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 			strcat(buf, strim(hpp.buf));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 						    -1, buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 						    renderer, "markup",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 						    col_idx++, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	for (col_idx = 0; col_idx < nr_cols; col_idx++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		GtkTreeViewColumn *column;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 		column = gtk_tree_view_get_column(GTK_TREE_VIEW(view), col_idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 		gtk_tree_view_column_set_resizable(column, TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		if (col_idx == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 			gtk_tree_view_set_expander_column(GTK_TREE_VIEW(view),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 							  column);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	g_object_unref(GTK_TREE_MODEL(store));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	perf_gtk__add_hierarchy_entries(hists, &hists->entries, store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 					NULL, &hpp, min_pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	g_signal_connect(view, "row-activated",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 			 G_CALLBACK(on_row_activated), NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	gtk_container_add(GTK_CONTAINER(window), view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) int perf_evlist__gtk_browse_hists(struct evlist *evlist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 				  const char *help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 				  struct hist_browser_timer *hbt __maybe_unused,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 				  float min_pcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	struct evsel *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	GtkWidget *vbox;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	GtkWidget *notebook;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	GtkWidget *info_bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	GtkWidget *statbar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 	GtkWidget *window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 	signal(SIGSEGV, perf_gtk__signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 	signal(SIGFPE,  perf_gtk__signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	signal(SIGINT,  perf_gtk__signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	signal(SIGQUIT, perf_gtk__signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 	signal(SIGTERM, perf_gtk__signal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 	gtk_window_set_title(GTK_WINDOW(window), "perf report");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	pgctx = perf_gtk__activate_context(window);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	if (!pgctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	vbox = gtk_vbox_new(FALSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	notebook = gtk_notebook_new();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	info_bar = perf_gtk__setup_info_bar();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	if (info_bar)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 		gtk_box_pack_start(GTK_BOX(vbox), info_bar, FALSE, FALSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	statbar = perf_gtk__setup_statusbar();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	gtk_box_pack_start(GTK_BOX(vbox), statbar, FALSE, FALSE, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	gtk_container_add(GTK_CONTAINER(window), vbox);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	evlist__for_each_entry(evlist, pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		struct hists *hists = evsel__hists(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		const char *evname = evsel__name(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 		GtkWidget *scrolled_window;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 		GtkWidget *tab_label;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 		char buf[512];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 		size_t size = sizeof(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 		if (symbol_conf.event_group) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 			if (!evsel__is_group_leader(pos))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 			if (pos->core.nr_members > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 				evsel__group_desc(pos, buf, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 				evname = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		scrolled_window = gtk_scrolled_window_new(NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 		gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 							GTK_POLICY_AUTOMATIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 							GTK_POLICY_AUTOMATIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 		if (symbol_conf.report_hierarchy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 			perf_gtk__show_hierarchy(scrolled_window, hists, min_pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 			perf_gtk__show_hists(scrolled_window, hists, min_pcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 		tab_label = gtk_label_new(evname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 		gtk_notebook_append_page(GTK_NOTEBOOK(notebook), scrolled_window, tab_label);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	gtk_widget_show_all(window);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	perf_gtk__resize_window(window);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	ui_helpline__push(help);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 	gtk_main();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 	perf_gtk__deactivate_context(&pgctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) }