diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-11 10:14:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-11 21:18:17 -0400 |
commit | ff0c107806cf9d237e50e21de66d6909391071cd (patch) | |
tree | b4a30706632161df4e73f1353b1daa8205102c3d | |
parent | 566a08859f63a33746e25246c5cda0f52528d2e4 (diff) |
perf evsel: Rename print_ip() to fprintf_sym()
As it receives a FILE, and its more than just the IP, which can even be
requested not to be printed.
For consistency with other similar methods in tools/perf/, name it as
perf_evsel__fprintf_sym() and make it return the number of bytes
printed, just like 'fprintf(3)'
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-84gawlqa3lhk63nf0t9vnqnn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-script.c | 10 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 4 | ||||
-rw-r--r-- | tools/perf/util/session.c | 60 | ||||
-rw-r--r-- | tools/perf/util/session.h | 8 |
4 files changed, 39 insertions, 43 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 60fde9f5025c..ddd5b79e94c2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -579,8 +579,8 @@ static void print_sample_bts(struct perf_sample *sample, | |||
579 | print_opts &= ~PRINT_IP_OPT_SRCLINE; | 579 | print_opts &= ~PRINT_IP_OPT_SRCLINE; |
580 | } | 580 | } |
581 | } | 581 | } |
582 | perf_evsel__print_ip(evsel, sample, al, 0, print_opts, | 582 | perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts, |
583 | scripting_max_stack, stdout); | 583 | scripting_max_stack, stdout); |
584 | } | 584 | } |
585 | 585 | ||
586 | /* print branch_to information */ | 586 | /* print branch_to information */ |
@@ -788,9 +788,9 @@ static void process_event(struct perf_script *script, | |||
788 | else | 788 | else |
789 | printf("\n"); | 789 | printf("\n"); |
790 | 790 | ||
791 | perf_evsel__print_ip(evsel, sample, al, 0, | 791 | perf_evsel__fprintf_sym(evsel, sample, al, 0, |
792 | output[attr->type].print_ip_opts, | 792 | output[attr->type].print_ip_opts, |
793 | scripting_max_stack, stdout); | 793 | scripting_max_stack, stdout); |
794 | } | 794 | } |
795 | 795 | ||
796 | if (PRINT_FIELD(IREGS)) | 796 | if (PRINT_FIELD(IREGS)) |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 8c587a8d3742..a0d5c680c39e 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -2203,8 +2203,8 @@ signed_print: | |||
2203 | event->header.type); | 2203 | event->header.type); |
2204 | goto out_put; | 2204 | goto out_put; |
2205 | } | 2205 | } |
2206 | perf_evsel__print_ip(evsel, sample, &al, 38, print_opts, | 2206 | perf_evsel__fprintf_sym(evsel, sample, &al, 38, print_opts, |
2207 | scripting_max_stack, trace->output); | 2207 | scripting_max_stack, trace->output); |
2208 | } | 2208 | } |
2209 | out: | 2209 | out: |
2210 | ttrace->entry_pending = false; | 2210 | ttrace->entry_pending = false; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 62b6d4051b99..0669a088ea0d 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -1953,11 +1953,12 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | |||
1953 | return NULL; | 1953 | return NULL; |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | 1956 | int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample, |
1957 | struct addr_location *al, int left_alignment, | 1957 | struct addr_location *al, int left_alignment, |
1958 | unsigned int print_opts, unsigned int stack_depth, | 1958 | unsigned int print_opts, unsigned int stack_depth, |
1959 | FILE *fp) | 1959 | FILE *fp) |
1960 | { | 1960 | { |
1961 | int printed = 0; | ||
1961 | struct callchain_cursor_node *node; | 1962 | struct callchain_cursor_node *node; |
1962 | int print_ip = print_opts & PRINT_IP_OPT_IP; | 1963 | int print_ip = print_opts & PRINT_IP_OPT_IP; |
1963 | int print_sym = print_opts & PRINT_IP_OPT_SYM; | 1964 | int print_sym = print_opts & PRINT_IP_OPT_SYM; |
@@ -1975,7 +1976,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | |||
1975 | stack_depth) != 0) { | 1976 | stack_depth) != 0) { |
1976 | if (verbose) | 1977 | if (verbose) |
1977 | error("Failed to resolve callchain. Skipping\n"); | 1978 | error("Failed to resolve callchain. Skipping\n"); |
1978 | return; | 1979 | return printed; |
1979 | } | 1980 | } |
1980 | callchain_cursor_commit(&callchain_cursor); | 1981 | callchain_cursor_commit(&callchain_cursor); |
1981 | 1982 | ||
@@ -1992,71 +1993,66 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | |||
1992 | if (node->sym && node->sym->ignore) | 1993 | if (node->sym && node->sym->ignore) |
1993 | goto next; | 1994 | goto next; |
1994 | 1995 | ||
1995 | fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); | 1996 | printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); |
1996 | 1997 | ||
1997 | if (print_ip) | 1998 | if (print_ip) |
1998 | fprintf(fp, "%c%16" PRIx64, s, node->ip); | 1999 | printed += fprintf(fp, "%c%16" PRIx64, s, node->ip); |
1999 | 2000 | ||
2000 | if (node->map) | 2001 | if (node->map) |
2001 | addr = node->map->map_ip(node->map, node->ip); | 2002 | addr = node->map->map_ip(node->map, node->ip); |
2002 | 2003 | ||
2003 | if (print_sym) { | 2004 | if (print_sym) { |
2004 | fprintf(fp, " "); | 2005 | printed += fprintf(fp, " "); |
2005 | if (print_symoffset) { | 2006 | if (print_symoffset) { |
2006 | node_al.addr = addr; | 2007 | node_al.addr = addr; |
2007 | node_al.map = node->map; | 2008 | node_al.map = node->map; |
2008 | symbol__fprintf_symname_offs(node->sym, | 2009 | printed += symbol__fprintf_symname_offs(node->sym, &node_al, fp); |
2009 | &node_al, | ||
2010 | fp); | ||
2011 | } else | 2010 | } else |
2012 | symbol__fprintf_symname(node->sym, fp); | 2011 | printed += symbol__fprintf_symname(node->sym, fp); |
2013 | } | 2012 | } |
2014 | 2013 | ||
2015 | if (print_dso) { | 2014 | if (print_dso) { |
2016 | fprintf(fp, " ("); | 2015 | printed += fprintf(fp, " ("); |
2017 | map__fprintf_dsoname(node->map, fp); | 2016 | printed += map__fprintf_dsoname(node->map, fp); |
2018 | fprintf(fp, ")"); | 2017 | printed += fprintf(fp, ")"); |
2019 | } | 2018 | } |
2020 | 2019 | ||
2021 | if (print_srcline) | 2020 | if (print_srcline) |
2022 | map__fprintf_srcline(node->map, addr, "\n ", | 2021 | printed += map__fprintf_srcline(node->map, addr, "\n ", fp); |
2023 | fp); | ||
2024 | 2022 | ||
2025 | if (!print_oneline) | 2023 | if (!print_oneline) |
2026 | fprintf(fp, "\n"); | 2024 | printed += fprintf(fp, "\n"); |
2027 | 2025 | ||
2028 | stack_depth--; | 2026 | stack_depth--; |
2029 | next: | 2027 | next: |
2030 | callchain_cursor_advance(&callchain_cursor); | 2028 | callchain_cursor_advance(&callchain_cursor); |
2031 | } | 2029 | } |
2032 | 2030 | ||
2033 | } else { | 2031 | } else if (!(al->sym && al->sym->ignore)) { |
2034 | if (al->sym && al->sym->ignore) | 2032 | printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); |
2035 | return; | ||
2036 | |||
2037 | fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); | ||
2038 | 2033 | ||
2039 | if (print_ip) | 2034 | if (print_ip) |
2040 | fprintf(fp, "%16" PRIx64, sample->ip); | 2035 | printed += fprintf(fp, "%16" PRIx64, sample->ip); |
2041 | 2036 | ||
2042 | if (print_sym) { | 2037 | if (print_sym) { |
2043 | fprintf(fp, " "); | 2038 | printed += fprintf(fp, " "); |
2044 | if (print_symoffset) | 2039 | if (print_symoffset) |
2045 | symbol__fprintf_symname_offs(al->sym, al, | 2040 | printed += symbol__fprintf_symname_offs(al->sym, al, fp); |
2046 | fp); | ||
2047 | else | 2041 | else |
2048 | symbol__fprintf_symname(al->sym, fp); | 2042 | printed += symbol__fprintf_symname(al->sym, fp); |
2049 | } | 2043 | } |
2050 | 2044 | ||
2051 | if (print_dso) { | 2045 | if (print_dso) { |
2052 | fprintf(fp, " ("); | 2046 | printed += fprintf(fp, " ("); |
2053 | map__fprintf_dsoname(al->map, fp); | 2047 | printed += map__fprintf_dsoname(al->map, fp); |
2054 | fprintf(fp, ")"); | 2048 | printed += fprintf(fp, ")"); |
2055 | } | 2049 | } |
2056 | 2050 | ||
2057 | if (print_srcline) | 2051 | if (print_srcline) |
2058 | map__fprintf_srcline(al->map, al->addr, "\n ", fp); | 2052 | printed += map__fprintf_srcline(al->map, al->addr, "\n ", fp); |
2059 | } | 2053 | } |
2054 | |||
2055 | return printed; | ||
2060 | } | 2056 | } |
2061 | 2057 | ||
2062 | int perf_session__cpu_bitmap(struct perf_session *session, | 2058 | int perf_session__cpu_bitmap(struct perf_session *session, |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index a6bc4ddbae3e..ac834908bb35 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -104,10 +104,10 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); | |||
104 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | 104 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, |
105 | unsigned int type); | 105 | unsigned int type); |
106 | 106 | ||
107 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | 107 | int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample, |
108 | struct addr_location *al, int left_alignment, | 108 | struct addr_location *al, int left_alignment, |
109 | unsigned int print_opts, unsigned int stack_depth, | 109 | unsigned int print_opts, unsigned int stack_depth, |
110 | FILE *fp); | 110 | FILE *fp); |
111 | 111 | ||
112 | int perf_session__cpu_bitmap(struct perf_session *session, | 112 | int perf_session__cpu_bitmap(struct perf_session *session, |
113 | const char *cpu_list, unsigned long *cpu_bitmap); | 113 | const char *cpu_list, unsigned long *cpu_bitmap); |