[PATCH 03/21] perf tools: Add callchain__printf for pure callchain dump

From: Jiri Olsa
Date: Wed Jan 24 2018 - 06:56:57 EST


Adding callchain__printf for the pure callchain dump
without the lbr portion, it will be used later in this
patchset. The lbr dump is now included in the new
perf_evsel__callchain__printf function.

Link: http://lkml.kernel.org/n/tip-xg1o9sr5p4yfxe61lu13m802@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/util/session.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index c71ced7db152..da0635e2f100 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -917,15 +917,11 @@ static void callchain__lbr_callstack_printf(struct perf_sample *sample)
}
}

-static void callchain__printf(struct perf_evsel *evsel,
- struct perf_sample *sample)
+static void callchain__printf(struct perf_sample *sample)
{
unsigned int i;
struct ip_callchain *callchain = sample->callchain;

- if (perf_evsel__has_branch_callstack(evsel))
- callchain__lbr_callstack_printf(sample);
-
printf("... FP chain: nr:%" PRIu64 "\n", callchain->nr);

for (i = 0; i < callchain->nr; i++)
@@ -933,6 +929,16 @@ static void callchain__printf(struct perf_evsel *evsel,
i, callchain->ips[i]);
}

+static void
+perf_evsel__callchain__printf(struct perf_evsel *evsel,
+ struct perf_sample *sample)
+{
+ if (perf_evsel__has_branch_callstack(evsel))
+ callchain__lbr_callstack_printf(sample);
+
+ callchain__printf(sample);
+}
+
static void branch_stack__printf(struct perf_sample *sample)
{
uint64_t i;
@@ -1095,7 +1101,7 @@ static void dump_sample(struct perf_evsel *evsel, union perf_event *event,
sample_type = evsel->attr.sample_type;

if (sample_type & PERF_SAMPLE_CALLCHAIN)
- callchain__printf(evsel, sample);
+ perf_evsel__callchain__printf(evsel, sample);

if ((sample_type & PERF_SAMPLE_BRANCH_STACK) && !perf_evsel__has_branch_callstack(evsel))
branch_stack__printf(sample);
--
2.13.6