diff options
| author | Milian Wolff <milian.wolff@kdab.com> | 2016-04-11 09:18:11 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-11 21:18:14 -0400 |
| commit | 6186de9a491af030889b372193fc9f38c248e69a (patch) | |
| tree | c747688cdb6e840ff65ecb582d217c273b33b952 /tools | |
| parent | 72c0809856b9174e71eab4e293089f6a114e0d41 (diff) | |
perf evsel: Allow specifying a file to output in perf_evsel__print_ip
As this function will be used in 'perf trace'.
Cc: Jiri Olsa <jolsa@kernel.org>
Link: http://lkml.kernel.org/n/tip-8x297v9utnxq77onikevvlse@git.kernel.org
[ Split from a larger patch ]
Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/builtin-script.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 39 | ||||
| -rw-r--r-- | tools/perf/util/session.h | 3 |
3 files changed, 25 insertions, 21 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 8f6ab2ac855a..dbf208f0cdc2 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
| @@ -580,7 +580,7 @@ static void print_sample_bts(struct perf_sample *sample, | |||
| 580 | } | 580 | } |
| 581 | } | 581 | } |
| 582 | perf_evsel__print_ip(evsel, sample, al, print_opts, | 582 | perf_evsel__print_ip(evsel, sample, al, print_opts, |
| 583 | scripting_max_stack); | 583 | scripting_max_stack, stdout); |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | /* print branch_to information */ | 586 | /* print branch_to information */ |
| @@ -790,7 +790,7 @@ static void process_event(struct perf_script *script, | |||
| 790 | 790 | ||
| 791 | perf_evsel__print_ip(evsel, sample, al, | 791 | perf_evsel__print_ip(evsel, sample, al, |
| 792 | output[attr->type].print_ip_opts, | 792 | output[attr->type].print_ip_opts, |
| 793 | scripting_max_stack); | 793 | scripting_max_stack, stdout); |
| 794 | } | 794 | } |
| 795 | 795 | ||
| 796 | if (PRINT_FIELD(IREGS)) | 796 | if (PRINT_FIELD(IREGS)) |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index ef370557fb9a..bbac0efbc10c 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
| @@ -1955,7 +1955,8 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | |||
| 1955 | 1955 | ||
| 1956 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | 1956 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, |
| 1957 | struct addr_location *al, | 1957 | struct addr_location *al, |
| 1958 | unsigned int print_opts, unsigned int stack_depth) | 1958 | unsigned int print_opts, unsigned int stack_depth, |
| 1959 | FILE *fp) | ||
| 1959 | { | 1960 | { |
| 1960 | struct callchain_cursor_node *node; | 1961 | struct callchain_cursor_node *node; |
| 1961 | int print_ip = print_opts & PRINT_IP_OPT_IP; | 1962 | int print_ip = print_opts & PRINT_IP_OPT_IP; |
| @@ -1992,33 +1993,35 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | |||
| 1992 | goto next; | 1993 | goto next; |
| 1993 | 1994 | ||
| 1994 | if (print_ip) | 1995 | if (print_ip) |
| 1995 | printf("%c%16" PRIx64, s, node->ip); | 1996 | fprintf(fp, "%c%16" PRIx64, s, node->ip); |
| 1996 | 1997 | ||
| 1997 | if (node->map) | 1998 | if (node->map) |
| 1998 | addr = node->map->map_ip(node->map, node->ip); | 1999 | addr = node->map->map_ip(node->map, node->ip); |
| 1999 | 2000 | ||
| 2000 | if (print_sym) { | 2001 | if (print_sym) { |
| 2001 | printf(" "); | 2002 | fprintf(fp, " "); |
| 2002 | if (print_symoffset) { | 2003 | if (print_symoffset) { |
| 2003 | node_al.addr = addr; | 2004 | node_al.addr = addr; |
| 2004 | node_al.map = node->map; | 2005 | node_al.map = node->map; |
| 2005 | symbol__fprintf_symname_offs(node->sym, &node_al, stdout); | 2006 | symbol__fprintf_symname_offs(node->sym, |
| 2007 | &node_al, | ||
| 2008 | fp); | ||
| 2006 | } else | 2009 | } else |
| 2007 | symbol__fprintf_symname(node->sym, stdout); | 2010 | symbol__fprintf_symname(node->sym, fp); |
| 2008 | } | 2011 | } |
| 2009 | 2012 | ||
| 2010 | if (print_dso) { | 2013 | if (print_dso) { |
| 2011 | printf(" ("); | 2014 | fprintf(fp, " ("); |
| 2012 | map__fprintf_dsoname(node->map, stdout); | 2015 | map__fprintf_dsoname(node->map, fp); |
| 2013 | printf(")"); | 2016 | fprintf(fp, ")"); |
| 2014 | } | 2017 | } |
| 2015 | 2018 | ||
| 2016 | if (print_srcline) | 2019 | if (print_srcline) |
| 2017 | map__fprintf_srcline(node->map, addr, "\n ", | 2020 | map__fprintf_srcline(node->map, addr, "\n ", |
| 2018 | stdout); | 2021 | fp); |
| 2019 | 2022 | ||
| 2020 | if (!print_oneline) | 2023 | if (!print_oneline) |
| 2021 | printf("\n"); | 2024 | fprintf(fp, "\n"); |
| 2022 | 2025 | ||
| 2023 | stack_depth--; | 2026 | stack_depth--; |
| 2024 | next: | 2027 | next: |
| @@ -2030,25 +2033,25 @@ next: | |||
| 2030 | return; | 2033 | return; |
| 2031 | 2034 | ||
| 2032 | if (print_ip) | 2035 | if (print_ip) |
| 2033 | printf("%16" PRIx64, sample->ip); | 2036 | fprintf(fp, "%16" PRIx64, sample->ip); |
| 2034 | 2037 | ||
| 2035 | if (print_sym) { | 2038 | if (print_sym) { |
| 2036 | printf(" "); | 2039 | fprintf(fp, " "); |
| 2037 | if (print_symoffset) | 2040 | if (print_symoffset) |
| 2038 | symbol__fprintf_symname_offs(al->sym, al, | 2041 | symbol__fprintf_symname_offs(al->sym, al, |
| 2039 | stdout); | 2042 | fp); |
| 2040 | else | 2043 | else |
| 2041 | symbol__fprintf_symname(al->sym, stdout); | 2044 | symbol__fprintf_symname(al->sym, fp); |
| 2042 | } | 2045 | } |
| 2043 | 2046 | ||
| 2044 | if (print_dso) { | 2047 | if (print_dso) { |
| 2045 | printf(" ("); | 2048 | fprintf(fp, " ("); |
| 2046 | map__fprintf_dsoname(al->map, stdout); | 2049 | map__fprintf_dsoname(al->map, fp); |
| 2047 | printf(")"); | 2050 | fprintf(fp, ")"); |
| 2048 | } | 2051 | } |
| 2049 | 2052 | ||
| 2050 | if (print_srcline) | 2053 | if (print_srcline) |
| 2051 | map__fprintf_srcline(al->map, al->addr, "\n ", stdout); | 2054 | map__fprintf_srcline(al->map, al->addr, "\n ", fp); |
| 2052 | } | 2055 | } |
| 2053 | } | 2056 | } |
| 2054 | 2057 | ||
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index f96fc9e8c52e..0ee3d9dbc099 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
| @@ -106,7 +106,8 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, | |||
| 106 | 106 | ||
| 107 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, | 107 | void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample, |
| 108 | struct addr_location *al, | 108 | struct addr_location *al, |
| 109 | unsigned int print_opts, unsigned int stack_depth); | 109 | unsigned int print_opts, unsigned int stack_depth, |
| 110 | FILE *fp); | ||
| 110 | 111 | ||
| 111 | int perf_session__cpu_bitmap(struct perf_session *session, | 112 | int perf_session__cpu_bitmap(struct perf_session *session, |
| 112 | const char *cpu_list, unsigned long *cpu_bitmap); | 113 | const char *cpu_list, unsigned long *cpu_bitmap); |
