Commit a8763445 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf symbols: Print symbol offsets conditionally

The __symbol__fprintf_symname_offs() always shows symbol offsets.  So
there's no difference between 'perf script -F ip,sym' and 'perf script
-F ip,sym,symoff'.  I don't think it's a desired behavior..
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20161116060634.28477-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3a5bfab6
...@@ -137,7 +137,8 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment, ...@@ -137,7 +137,8 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
if (print_symoffset) { if (print_symoffset) {
printed += __symbol__fprintf_symname_offs(node->sym, &node_al, printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
print_unknown_as_addr, fp); print_unknown_as_addr,
true, fp);
} else { } else {
printed += __symbol__fprintf_symname(node->sym, &node_al, printed += __symbol__fprintf_symname(node->sym, &node_al,
print_unknown_as_addr, fp); print_unknown_as_addr, fp);
...@@ -188,7 +189,8 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al, ...@@ -188,7 +189,8 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
printed += fprintf(fp, " "); printed += fprintf(fp, " ");
if (print_symoffset) { if (print_symoffset) {
printed += __symbol__fprintf_symname_offs(al->sym, al, printed += __symbol__fprintf_symname_offs(al->sym, al,
print_unknown_as_addr, fp); print_unknown_as_addr,
true, fp);
} else { } else {
printed += __symbol__fprintf_symname(al->sym, al, printed += __symbol__fprintf_symname(al->sym, al,
print_unknown_as_addr, fp); print_unknown_as_addr, fp);
......
...@@ -282,7 +282,8 @@ int symbol__annotation_init(void); ...@@ -282,7 +282,8 @@ int symbol__annotation_init(void);
struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
size_t __symbol__fprintf_symname_offs(const struct symbol *sym, size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, const struct addr_location *al,
bool unknown_as_addr, FILE *fp); bool unknown_as_addr,
bool print_offsets, FILE *fp);
size_t symbol__fprintf_symname_offs(const struct symbol *sym, size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, FILE *fp); const struct addr_location *al, FILE *fp);
size_t __symbol__fprintf_symname(const struct symbol *sym, size_t __symbol__fprintf_symname(const struct symbol *sym,
......
...@@ -15,14 +15,15 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp) ...@@ -15,14 +15,15 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp)
size_t __symbol__fprintf_symname_offs(const struct symbol *sym, size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, const struct addr_location *al,
bool unknown_as_addr, FILE *fp) bool unknown_as_addr,
bool print_offsets, FILE *fp)
{ {
unsigned long offset; unsigned long offset;
size_t length; size_t length;
if (sym && sym->name) { if (sym && sym->name) {
length = fprintf(fp, "%s", sym->name); length = fprintf(fp, "%s", sym->name);
if (al) { if (al && print_offsets) {
if (al->addr < sym->end) if (al->addr < sym->end)
offset = al->addr - sym->start; offset = al->addr - sym->start;
else else
...@@ -40,19 +41,19 @@ size_t symbol__fprintf_symname_offs(const struct symbol *sym, ...@@ -40,19 +41,19 @@ size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, const struct addr_location *al,
FILE *fp) FILE *fp)
{ {
return __symbol__fprintf_symname_offs(sym, al, false, fp); return __symbol__fprintf_symname_offs(sym, al, false, true, fp);
} }
size_t __symbol__fprintf_symname(const struct symbol *sym, size_t __symbol__fprintf_symname(const struct symbol *sym,
const struct addr_location *al, const struct addr_location *al,
bool unknown_as_addr, FILE *fp) bool unknown_as_addr, FILE *fp)
{ {
return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, fp); return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, false, fp);
} }
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp) size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
{ {
return __symbol__fprintf_symname_offs(sym, NULL, false, fp); return __symbol__fprintf_symname_offs(sym, NULL, false, false, fp);
} }
size_t dso__fprintf_symbols_by_name(struct dso *dso, size_t dso__fprintf_symbols_by_name(struct dso *dso,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment