perf hists: Reset width of output fields with header length
Some fields missed to set default column length so it broke align in --stdio output. Add perf_hpp__reset_width() to set it to a sane default value. Note that this change will ignore -w/--column-widths option for now. Before: $ perf report -F cpu,comm,overhead --stdio ... # CPU Command Overhead # ............... ........ # 0 firefox 2.65% 0 kworker/0:0 1.45% 0 swapper 5.52% 0 synergys 0.92% 1 firefox 4.54% After: # CPU Command Overhead # ... ............... ........ # 0 firefox 2.65% 0 kworker/0:0 1.45% 0 swapper 5.52% 0 synergys 0.92% 1 firefox 4.54% Signed-off-by: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1400480762-22852-17-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
This commit is contained in:
parent
e67d49a72d
commit
678a500d07
@ -369,12 +369,10 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
|
|||||||
int max_cols, float min_pcnt, FILE *fp)
|
int max_cols, float min_pcnt, FILE *fp)
|
||||||
{
|
{
|
||||||
struct perf_hpp_fmt *fmt;
|
struct perf_hpp_fmt *fmt;
|
||||||
struct sort_entry *se;
|
|
||||||
struct rb_node *nd;
|
struct rb_node *nd;
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
const char *sep = symbol_conf.field_sep;
|
const char *sep = symbol_conf.field_sep;
|
||||||
const char *col_width = symbol_conf.col_width_list_str;
|
|
||||||
int nr_rows = 0;
|
int nr_rows = 0;
|
||||||
char bf[96];
|
char bf[96];
|
||||||
struct perf_hpp dummy_hpp = {
|
struct perf_hpp dummy_hpp = {
|
||||||
@ -387,22 +385,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
|
|||||||
|
|
||||||
init_rem_hits();
|
init_rem_hits();
|
||||||
|
|
||||||
list_for_each_entry(se, &hist_entry__sort_list, list) {
|
|
||||||
if (se->elide)
|
perf_hpp__for_each_format(fmt)
|
||||||
continue;
|
perf_hpp__reset_width(fmt, hists);
|
||||||
width = strlen(se->se_header);
|
|
||||||
if (symbol_conf.col_width_list_str) {
|
|
||||||
if (col_width) {
|
|
||||||
hists__set_col_len(hists, se->se_width_idx,
|
|
||||||
atoi(col_width));
|
|
||||||
col_width = strchr(col_width, ',');
|
|
||||||
if (col_width)
|
|
||||||
++col_width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hists__new_col_len(hists, se->se_width_idx, width))
|
|
||||||
width = hists__col_len(hists, se->se_width_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!show_header)
|
if (!show_header)
|
||||||
goto print_entries;
|
goto print_entries;
|
||||||
|
@ -202,6 +202,7 @@ void perf_hpp__append_sort_keys(void);
|
|||||||
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
|
bool perf_hpp__is_sort_entry(struct perf_hpp_fmt *format);
|
||||||
bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
|
bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b);
|
||||||
bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
|
bool perf_hpp__should_skip(struct perf_hpp_fmt *format);
|
||||||
|
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
|
||||||
|
|
||||||
typedef u64 (*hpp_field_fn)(struct hist_entry *he);
|
typedef u64 (*hpp_field_fn)(struct hist_entry *he);
|
||||||
typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
|
typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
|
||||||
|
@ -1089,6 +1089,18 @@ bool perf_hpp__same_sort_entry(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b)
|
|||||||
return hse_a->se == hse_b->se;
|
return hse_a->se == hse_b->se;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
|
||||||
|
{
|
||||||
|
struct hpp_sort_entry *hse;
|
||||||
|
|
||||||
|
if (!perf_hpp__is_sort_entry(fmt))
|
||||||
|
return;
|
||||||
|
|
||||||
|
hse = container_of(fmt, struct hpp_sort_entry, hpp);
|
||||||
|
hists__new_col_len(hists, hse->se->se_width_idx,
|
||||||
|
strlen(hse->se->se_header));
|
||||||
|
}
|
||||||
|
|
||||||
static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
static int __sort__hpp_header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp,
|
||||||
struct perf_evsel *evsel)
|
struct perf_evsel *evsel)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user