Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
a8763445 3a5bfab6

+12 -8
+4 -2
tools/perf/util/evsel_fprintf.c
··· 137 137 138 138 if (print_symoffset) { 139 139 printed += __symbol__fprintf_symname_offs(node->sym, &node_al, 140 - print_unknown_as_addr, fp); 140 + print_unknown_as_addr, 141 + true, fp); 141 142 } else { 142 143 printed += __symbol__fprintf_symname(node->sym, &node_al, 143 144 print_unknown_as_addr, fp); ··· 189 188 printed += fprintf(fp, " "); 190 189 if (print_symoffset) { 191 190 printed += __symbol__fprintf_symname_offs(al->sym, al, 192 - print_unknown_as_addr, fp); 191 + print_unknown_as_addr, 192 + true, fp); 193 193 } else { 194 194 printed += __symbol__fprintf_symname(al->sym, al, 195 195 print_unknown_as_addr, fp);
+2 -1
tools/perf/util/symbol.h
··· 282 282 struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name); 283 283 size_t __symbol__fprintf_symname_offs(const struct symbol *sym, 284 284 const struct addr_location *al, 285 - bool unknown_as_addr, FILE *fp); 285 + bool unknown_as_addr, 286 + bool print_offsets, FILE *fp); 286 287 size_t symbol__fprintf_symname_offs(const struct symbol *sym, 287 288 const struct addr_location *al, FILE *fp); 288 289 size_t __symbol__fprintf_symname(const struct symbol *sym,
+6 -5
tools/perf/util/symbol_fprintf.c
··· 15 15 16 16 size_t __symbol__fprintf_symname_offs(const struct symbol *sym, 17 17 const struct addr_location *al, 18 - bool unknown_as_addr, FILE *fp) 18 + bool unknown_as_addr, 19 + bool print_offsets, FILE *fp) 19 20 { 20 21 unsigned long offset; 21 22 size_t length; 22 23 23 24 if (sym && sym->name) { 24 25 length = fprintf(fp, "%s", sym->name); 25 - if (al) { 26 + if (al && print_offsets) { 26 27 if (al->addr < sym->end) 27 28 offset = al->addr - sym->start; 28 29 else ··· 41 40 const struct addr_location *al, 42 41 FILE *fp) 43 42 { 44 - return __symbol__fprintf_symname_offs(sym, al, false, fp); 43 + return __symbol__fprintf_symname_offs(sym, al, false, true, fp); 45 44 } 46 45 47 46 size_t __symbol__fprintf_symname(const struct symbol *sym, 48 47 const struct addr_location *al, 49 48 bool unknown_as_addr, FILE *fp) 50 49 { 51 - return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, fp); 50 + return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, false, fp); 52 51 } 53 52 54 53 size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp) 55 54 { 56 - return __symbol__fprintf_symname_offs(sym, NULL, false, fp); 55 + return __symbol__fprintf_symname_offs(sym, NULL, false, false, fp); 57 56 } 58 57 59 58 size_t dso__fprintf_symbols_by_name(struct dso *dso,