aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evsel.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-04-14 17:45:51 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-14 19:46:56 -0300
commit6f736735e30f51805f6be31d20a4bf5b0ae91bae (patch)
treebc26c54ba215e4891ee6fa60e881074aa543d744 /tools/perf/util/evsel.c
parentperf symbols: Move fprintf routines to separate object file (diff)
downloadlinux-dev-6f736735e30f51805f6be31d20a4bf5b0ae91bae.tar.xz
linux-dev-6f736735e30f51805f6be31d20a4bf5b0ae91bae.zip
perf evsel: Require that callchains be resolved before calling fprintf_{sym,callchain}
This way the print routine merely does printing, not requiring access to the resolving machinery, which helps disentangling the object files and easing creating subsets with a limited functionality set. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-2ti2jbra8fypdfawwwm3aee3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r--tools/perf/util/evsel.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 60bba67e6959..35c5a5282239 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2343,13 +2343,12 @@ out:
return ++printed;
}
-int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *sample,
- struct addr_location *al, int left_alignment,
- unsigned int print_opts, unsigned int stack_depth,
- FILE *fp)
+int sample__fprintf_callchain(struct perf_sample *sample,
+ struct addr_location *al, int left_alignment,
+ unsigned int print_opts, struct callchain_cursor *cursor,
+ FILE *fp)
{
int printed = 0;
- struct callchain_cursor cursor;
struct callchain_cursor_node *node;
int print_ip = print_opts & EVSEL__PRINT_IP;
int print_sym = print_opts & EVSEL__PRINT_SYM;
@@ -2363,22 +2362,15 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
if (sample->callchain) {
struct addr_location node_al;
- if (thread__resolve_callchain(al->thread, &cursor, evsel,
- sample, NULL, NULL,
- stack_depth) != 0) {
- if (verbose)
- error("Failed to resolve callchain. Skipping\n");
- return printed;
- }
- callchain_cursor_commit(&cursor);
+ callchain_cursor_commit(cursor);
if (print_symoffset)
node_al = *al;
- while (stack_depth) {
+ while (1) {
u64 addr = 0;
- node = callchain_cursor_current(&cursor);
+ node = callchain_cursor_current(cursor);
if (!node)
break;
@@ -2418,20 +2410,17 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
if (!print_oneline)
printed += fprintf(fp, "\n");
-
- stack_depth--;
next:
- callchain_cursor_advance(&cursor);
+ callchain_cursor_advance(cursor);
}
}
return printed;
}
-int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
- struct addr_location *al, int left_alignment,
- unsigned int print_opts, bool print_callchain,
- unsigned int stack_depth, FILE *fp)
+int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
+ int left_alignment, unsigned int print_opts,
+ struct callchain_cursor *cursor, FILE *fp)
{
int printed = 0;
int print_ip = print_opts & EVSEL__PRINT_IP;
@@ -2441,9 +2430,9 @@ int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample
int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
- if (print_callchain && sample->callchain) {
- printed += perf_evsel__fprintf_callchain(evsel, sample, al, left_alignment,
- print_opts, stack_depth, fp);
+ if (cursor != NULL) {
+ printed += sample__fprintf_callchain(sample, al, left_alignment,
+ print_opts, cursor, fp);
} else if (!(al->sym && al->sym->ignore)) {
printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");