Adding 'struct perf_hpp_fmt' into hpp callbacks, so commands
can access their private data.
It'll be handy for diff command in future to be able to access
file related data for each column.
Signed-off-by: Jiri Olsa
Cc: Arnaldo Carvalho de Melo
Cc: Peter Zijlstra
Cc: Ingo Molnar
Cc: Paul Mackerras
Cc: Corey Ashford
Cc: Frederic Weisbecker
Cc: Namhyung Kim
---
tools/perf/ui/browsers/hists.c | 10 +--
tools/perf/ui/gtk/browser.c| 10 +--
tools/perf/ui/hist.c | 159 +++--
tools/perf/ui/stdio/hist.c | 4 +-
tools/perf/util/hist.h | 10 +--
5 files changed, 127 insertions(+), 66 deletions(-)
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 57b82c2..b560abd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -568,8 +568,10 @@ static int hist_browser__show_callchain(struct
hist_browser *browser,
}
#define HPP__COLOR_FN(_name, _field) \
-static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \
-struct hist_entry *he) \
+static int hist_browser__hpp_color_ ## _name( \
+ struct perf_hpp_fmt *fmt __maybe_unused,\
+ struct perf_hpp *hpp, \
+ struct hist_entry *he) \
{ \
struct hists *hists = he->hists;\
double percent = 100.0 * he->stat._field / hists->stats.total_period; \
@@ -647,7 +649,7 @@ static int hist_browser__show_entry(struct hist_browser
*browser,
if (fmt->color) {
hpp.ptr = &percent;
/* It will set percent for us. See
HPP__COLOR_FN above. */
- width -= fmt->color(&hpp, entry);
+ width -= fmt->color(fmt, &hpp, entry);
ui_browser__set_percent_color(&browser->b,
percent, current_entry);
@@ -661,7 +663,7 @@ static int hist_browser__show_entry(struct hist_browser
*browser,
if (!current_entry || !browser->b.navkeypressed)
ui_browser__set_color(&browser->b,
HE_COLORSET_NORMAL);
} else {
- width -= fmt->entry(&hpp, entry);
+ width -= fmt->entry(fmt, &hpp, entry);
slsmg_printf("%s", s);
}
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c
index e59ba33..e3ae11a 100644
--- a/tools/perf/ui/gtk/browser.c
+++ b/tools/perf/ui/gtk/browser.c
@@ -46,7 +46,9 @@ static const char *perf_gtk__get_percent_color(double percent)
}
#define HPP__COLOR_FN(_name, _field)
\
-static int perf_gtk__hpp_color_ ## _name(struct perf_hpp *hpp,
\
+static int
\
+perf_gtk__hpp_color_ ## _name(struct perf_hpp_fmt *fmt __maybe_unused,
\
+struct perf_hpp *hpp,
\
struct hist_entry *he)
\
{
\
struct hists *hists = he->hists;
\
@@ -129,7 +131,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct
hists *hists)
col_idx = 0;
perf_hpp__for_each_format(fmt) {
- fmt->header(&hpp);
+ fmt->header(fmt, &hpp);
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-1, s,
renderer, "markup",
@@ -163,9 +165,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct
hists *hists)
perf_hpp__for_each_format(fmt) {
if (fmt->color)
- fmt->color(&hpp, h);
+ fmt->color(fmt, &hpp, h);
else
- fmt->entry(&hpp, h);
+ fmt->entry(fmt, &hpp, h);
gtk_list_store_set(store, &iter, col_idx++, s, -1);
}
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 1889c12..093ccf3 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -6,17 +6,20 @@
/* hist period print (hpp) functions */
-static int hpp__header_overhead(struct perf_hpp *hpp)
+static int hpp__header_overhead(struct perf_hpp_fmt *fmt __maybe_unused,
+