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

perf report: Fix alignment of symbol column when -v is given

When -v option is given, the symbol sort key prints its address also but
it wasn't properly aligned since hists__calc_col_len() misses the
additional part.  Also it missed 2 spaces for 0x prefix when printing.

  $ perf report --stdio -v -s sym
  # Samples: 133  of event 'cycles'
  # Event count (approx.): 50536717
  #
  # Overhead                          Symbol
  # ........  ..............................
  #
      12.20%  0xffffffff81384c50 v [k] intel_idle
       7.62%  0xffffffff8170976a v [k] ftrace_caller
       7.02%  0x2d986d         B [.] 0x00000000002d986d
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: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1364816125-12212-4-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 ceb2acbc
...@@ -70,9 +70,17 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) ...@@ -70,9 +70,17 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
int symlen; int symlen;
u16 len; u16 len;
if (h->ms.sym) /*
hists__new_col_len(hists, HISTC_SYMBOL, h->ms.sym->namelen + 4); * +4 accounts for '[x] ' priv level info
else { * +2 accounts for 0x prefix on raw addresses
* +3 accounts for ' y ' symtab origin info
*/
if (h->ms.sym) {
symlen = h->ms.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL, symlen);
} else {
symlen = unresolved_col_width + 4 + 2; symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL, symlen); hists__new_col_len(hists, HISTC_SYMBOL, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO); hists__set_unres_dso_col_len(hists, HISTC_DSO);
...@@ -91,12 +99,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) ...@@ -91,12 +99,10 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen); hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen);
if (h->branch_info) { if (h->branch_info) {
/*
* +4 accounts for '[x] ' priv level info
* +2 account of 0x prefix on raw addresses
*/
if (h->branch_info->from.sym) { if (h->branch_info->from.sym) {
symlen = (int)h->branch_info->from.sym->namelen + 4; symlen = (int)h->branch_info->from.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen); hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
symlen = dso__name_len(h->branch_info->from.map->dso); symlen = dso__name_len(h->branch_info->from.map->dso);
...@@ -109,6 +115,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) ...@@ -109,6 +115,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
if (h->branch_info->to.sym) { if (h->branch_info->to.sym) {
symlen = (int)h->branch_info->to.sym->namelen + 4; symlen = (int)h->branch_info->to.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen); hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
symlen = dso__name_len(h->branch_info->to.map->dso); symlen = dso__name_len(h->branch_info->to.map->dso);
...@@ -121,10 +129,6 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) ...@@ -121,10 +129,6 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
} }
if (h->mem_info) { if (h->mem_info) {
/*
* +4 accounts for '[x] ' priv level info
* +2 account of 0x prefix on raw addresses
*/
if (h->mem_info->daddr.sym) { if (h->mem_info->daddr.sym) {
symlen = (int)h->mem_info->daddr.sym->namelen + 4 symlen = (int)h->mem_info->daddr.sym->namelen + 4
+ unresolved_col_width + 2; + unresolved_col_width + 2;
......
...@@ -194,7 +194,7 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym, ...@@ -194,7 +194,7 @@ static int _hist_entry__sym_snprintf(struct map *map, struct symbol *sym,
if (verbose) { if (verbose) {
char o = map ? dso__symtab_origin(map->dso) : '!'; char o = map ? dso__symtab_origin(map->dso) : '!';
ret += repsep_snprintf(bf, size, "%-#*llx %c ", ret += repsep_snprintf(bf, size, "%-#*llx %c ",
BITS_PER_LONG / 4, ip, o); BITS_PER_LONG / 4 + 2, ip, o);
} }
ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level); ret += repsep_snprintf(bf + ret, size - ret, "[%c] ", level);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册