提交 94a0793d 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

perf ui hists: Pass evsel to hpp->header/width functions explicitly

Those functions need evsel to investigate event group and it's passed
via hpp->ptr.  However as it can be missed easily so it's better to
pass it via an argument IMHO.
Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1394437440-11609-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 52a3cb8c
...@@ -952,8 +952,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp, ...@@ -952,8 +952,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp,
dfmt->header_width, buf); dfmt->header_width, buf);
} }
static int hpp__header(struct perf_hpp_fmt *fmt, static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
struct perf_hpp *hpp) struct perf_evsel *evsel __maybe_unused)
{ {
struct diff_hpp_fmt *dfmt = struct diff_hpp_fmt *dfmt =
container_of(fmt, struct diff_hpp_fmt, fmt); container_of(fmt, struct diff_hpp_fmt, fmt);
...@@ -963,7 +963,8 @@ static int hpp__header(struct perf_hpp_fmt *fmt, ...@@ -963,7 +963,8 @@ static int hpp__header(struct perf_hpp_fmt *fmt,
} }
static int hpp__width(struct perf_hpp_fmt *fmt, static int hpp__width(struct perf_hpp_fmt *fmt,
struct perf_hpp *hpp __maybe_unused) struct perf_hpp *hpp __maybe_unused,
struct perf_evsel *evsel __maybe_unused)
{ {
struct diff_hpp_fmt *dfmt = struct diff_hpp_fmt *dfmt =
container_of(fmt, struct diff_hpp_fmt, fmt); container_of(fmt, struct diff_hpp_fmt, fmt);
......
...@@ -165,7 +165,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, ...@@ -165,7 +165,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
struct perf_hpp hpp = { struct perf_hpp hpp = {
.buf = s, .buf = s,
.size = sizeof(s), .size = sizeof(s),
.ptr = hists_to_evsel(hists),
}; };
nr_cols = 0; nr_cols = 0;
...@@ -192,7 +191,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, ...@@ -192,7 +191,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
col_idx = 0; col_idx = 0;
perf_hpp__for_each_format(fmt) { perf_hpp__for_each_format(fmt) {
fmt->header(fmt, &hpp); fmt->header(fmt, &hpp, hists_to_evsel(hists));
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
-1, ltrim(s), -1, ltrim(s),
......
...@@ -118,29 +118,27 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, ...@@ -118,29 +118,27 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
#define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \
static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
struct perf_hpp *hpp) \ struct perf_hpp *hpp, \
struct perf_evsel *evsel) \
{ \ { \
int len = _min_width; \ int len = _min_width; \
\ \
if (symbol_conf.event_group) { \ if (symbol_conf.event_group) \
struct perf_evsel *evsel = hpp->ptr; \
\
len = max(len, evsel->nr_members * _unit_width); \ len = max(len, evsel->nr_members * _unit_width); \
} \ \
return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \
} }
#define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \ #define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \
static int hpp__width_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ static int hpp__width_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
struct perf_hpp *hpp __maybe_unused) \ struct perf_hpp *hpp __maybe_unused, \
struct perf_evsel *evsel) \
{ \ { \
int len = _min_width; \ int len = _min_width; \
\ \
if (symbol_conf.event_group) { \ if (symbol_conf.event_group) \
struct perf_evsel *evsel = hpp->ptr; \
\
len = max(len, evsel->nr_members * _unit_width); \ len = max(len, evsel->nr_members * _unit_width); \
} \ \
return len; \ return len; \
} }
...@@ -329,15 +327,13 @@ unsigned int hists__sort_list_width(struct hists *hists) ...@@ -329,15 +327,13 @@ unsigned int hists__sort_list_width(struct hists *hists)
struct perf_hpp_fmt *fmt; struct perf_hpp_fmt *fmt;
struct sort_entry *se; struct sort_entry *se;
int i = 0, ret = 0; int i = 0, ret = 0;
struct perf_hpp dummy_hpp = { struct perf_hpp dummy_hpp;
.ptr = hists_to_evsel(hists),
};
perf_hpp__for_each_format(fmt) { perf_hpp__for_each_format(fmt) {
if (i) if (i)
ret += 2; ret += 2;
ret += fmt->width(fmt, &dummy_hpp); ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
} }
list_for_each_entry(se, &hist_entry__sort_list, list) list_for_each_entry(se, &hist_entry__sort_list, list)
......
...@@ -379,7 +379,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -379,7 +379,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
struct perf_hpp dummy_hpp = { struct perf_hpp dummy_hpp = {
.buf = bf, .buf = bf,
.size = sizeof(bf), .size = sizeof(bf),
.ptr = hists_to_evsel(hists),
}; };
bool first = true; bool first = true;
size_t linesz; size_t linesz;
...@@ -398,7 +397,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -398,7 +397,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
else else
first = false; first = false;
fmt->header(fmt, &dummy_hpp); fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
fprintf(fp, "%s", bf); fprintf(fp, "%s", bf);
} }
...@@ -443,7 +442,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -443,7 +442,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
else else
first = false; first = false;
width = fmt->width(fmt, &dummy_hpp); width = fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists));
for (i = 0; i < width; i++) for (i = 0; i < width; i++)
fprintf(fp, "."); fprintf(fp, ".");
} }
......
...@@ -132,8 +132,10 @@ struct perf_hpp { ...@@ -132,8 +132,10 @@ struct perf_hpp {
}; };
struct perf_hpp_fmt { struct perf_hpp_fmt {
int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp); int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp); struct perf_evsel *evsel);
int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
struct perf_evsel *evsel);
int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
struct hist_entry *he); struct hist_entry *he);
int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册