Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1521835

[PATCH RESEND 1/7] perf symbol: Print symbol offsets conditionally

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH RESEND 1/7] perf symbol: Print symbol offsets conditionally
Date 2016-11-14 17:40 +0100
Message-ID <sDssx-YN-37@gated-at.bofh.it> (permalink)
References <sDs9b-RG-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 tools/perf/util/evsel_fprintf.c  |  6 ++++--
 tools/perf/util/symbol.h         |  3 ++-
 tools/perf/util/symbol_fprintf.c | 11 ++++++-----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c
index 662a0a6182e7..ccb602397b60 100644
--- a/tools/perf/util/evsel_fprintf.c
+++ b/tools/perf/util/evsel_fprintf.c
@@ -137,7 +137,8 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 
 				if (print_symoffset) {
 					printed += __symbol__fprintf_symname_offs(node->sym, &node_al,
-										  print_unknown_as_addr, fp);
+										  print_unknown_as_addr,
+										  true, fp);
 				} else {
 					printed += __symbol__fprintf_symname(node->sym, &node_al,
 									     print_unknown_as_addr, fp);
@@ -188,7 +189,8 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
 			printed += fprintf(fp, " ");
 			if (print_symoffset) {
 				printed += __symbol__fprintf_symname_offs(al->sym, al,
-									  print_unknown_as_addr, fp);
+									  print_unknown_as_addr,
+									  true, fp);
 			} else {
 				printed += __symbol__fprintf_symname(al->sym, al,
 								     print_unknown_as_addr, fp);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index d964844eb314..18f63f65607a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -281,7 +281,8 @@ int symbol__annotation_init(void);
 struct symbol *symbol__new(u64 start, u64 len, u8 binding, const char *name);
 size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
 				      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,
 				    const struct addr_location *al, FILE *fp);
 size_t __symbol__fprintf_symname(const struct symbol *sym,
diff --git a/tools/perf/util/symbol_fprintf.c b/tools/perf/util/symbol_fprintf.c
index a680bdaa65dc..7c6b33e8e2d2 100644
--- a/tools/perf/util/symbol_fprintf.c
+++ b/tools/perf/util/symbol_fprintf.c
@@ -15,14 +15,15 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp)
 
 size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
 				      const struct addr_location *al,
-				      bool unknown_as_addr, FILE *fp)
+				      bool unknown_as_addr,
+				      bool print_offsets, FILE *fp)
 {
 	unsigned long offset;
 	size_t length;
 
 	if (sym && sym->name) {
 		length = fprintf(fp, "%s", sym->name);
-		if (al) {
+		if (al && print_offsets) {
 			if (al->addr < sym->end)
 				offset = al->addr - sym->start;
 			else
@@ -40,19 +41,19 @@ size_t symbol__fprintf_symname_offs(const struct symbol *sym,
 				    const struct addr_location *al,
 				    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,
 				 const struct addr_location *al,
 				 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)
 {
-	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,
-- 
2.10.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:20 +0100
  [PATCH 4/7] perf sched timehist: Add -w/--wakeups option Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:20 +0100
  [PATCH 5/7] perf sched timehist: Add call graph options Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:20 +0100
  [PATCH 6/7] perf sched timehist: Add -V/--cpu-visual option Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:20 +0100
  [PATCH 3/7] perf sched timehist: Add summary options Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:20 +0100
  [PATCH 7/7] perf sched: Add documentation for timehist options Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:30 +0100
  Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) David Ahern <dsahern@gmail.com> - 2016-11-14 17:30 +0100
  [PATCH RESEND 1/7] perf symbol: Print symbol offsets conditionally Namhyung Kim <namhyung@kernel.org> - 2016-11-14 17:40 +0100
  Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) Ingo Molnar <mingo@kernel.org> - 2016-11-15 07:50 +0100
    Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) Namhyung Kim <namhyung@kernel.org> - 2016-11-15 08:00 +0100
      Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) Ingo Molnar <mingo@kernel.org> - 2016-11-15 08:40 +0100
        Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) David Ahern <dsahern@gmail.com> - 2016-11-15 16:20 +0100
          Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) Namhyung Kim <namhyung@kernel.org> - 2016-11-15 16:40 +0100
            Re: [PATCHSET 0/7] perf sched: Introduce timehist command, again (v1) David Ahern <dsahern@gmail.com> - 2016-11-15 19:30 +0100

csiph-web