aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2012-03-08 17:47:46 -0500
committerIngo Molnar <mingo@elte.hu>2012-03-09 02:26:08 -0500
commit330aa675b4f92a422cb6d3acbbfd16a628017520 (patch)
treeb1feef795c8de616b31e8a0683c7c0e7498d2d33 /tools/perf
parenta5aabdacde9caff54886ae454e0fad2f26929753 (diff)
perf record: Add HEADER_BRANCH_STACK tag
This patch adds a new feature bit, namely, HEADER_BRANCH_STACK. When present, it indicates that sample records may contain branch stack. This could be useful to a viewer to switch to branch mode without having to parse all the samples or without a specific cmdline option. This will be used in a subsequent patch to enhance perf report with branch stacks. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331246868-19905-3-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c3
-rw-r--r--tools/perf/util/header.c13
-rw-r--r--tools/perf/util/header.h2
3 files changed, 17 insertions, 1 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index a7c53a9ef372..be4e1eee782e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -473,6 +473,9 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
473 if (!have_tracepoints(&evsel_list->entries)) 473 if (!have_tracepoints(&evsel_list->entries))
474 perf_header__clear_feat(&session->header, HEADER_TRACE_INFO); 474 perf_header__clear_feat(&session->header, HEADER_TRACE_INFO);
475 475
476 if (!rec->opts.branch_stack)
477 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
478
476 if (!rec->file_new) { 479 if (!rec->file_new) {
477 err = perf_session__read_header(session, output); 480 err = perf_session__read_header(session, output);
478 if (err < 0) 481 if (err < 0)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c851495b9b48..0d9b6da86a39 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1023,6 +1023,12 @@ write_it:
1023 return do_write_string(fd, buffer); 1023 return do_write_string(fd, buffer);
1024} 1024}
1025 1025
1026static int write_branch_stack(int fd __used, struct perf_header *h __used,
1027 struct perf_evlist *evlist __used)
1028{
1029 return 0;
1030}
1031
1026static void print_hostname(struct perf_header *ph, int fd, FILE *fp) 1032static void print_hostname(struct perf_header *ph, int fd, FILE *fp)
1027{ 1033{
1028 char *str = do_read_string(fd, ph); 1034 char *str = do_read_string(fd, ph);
@@ -1315,6 +1321,12 @@ static void print_cpuid(struct perf_header *ph, int fd, FILE *fp)
1315 free(str); 1321 free(str);
1316} 1322}
1317 1323
1324static void print_branch_stack(struct perf_header *ph __used, int fd __used,
1325 FILE *fp)
1326{
1327 fprintf(fp, "# contains samples with branch stack\n");
1328}
1329
1318static int __event_process_build_id(struct build_id_event *bev, 1330static int __event_process_build_id(struct build_id_event *bev,
1319 char *filename, 1331 char *filename,
1320 struct perf_session *session) 1332 struct perf_session *session)
@@ -1519,6 +1531,7 @@ static const struct feature_ops feat_ops[HEADER_LAST_FEATURE] = {
1519 FEAT_OPA(HEADER_CMDLINE, cmdline), 1531 FEAT_OPA(HEADER_CMDLINE, cmdline),
1520 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology), 1532 FEAT_OPF(HEADER_CPU_TOPOLOGY, cpu_topology),
1521 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology), 1533 FEAT_OPF(HEADER_NUMA_TOPOLOGY, numa_topology),
1534 FEAT_OPA(HEADER_BRANCH_STACK, branch_stack),
1522}; 1535};
1523 1536
1524struct header_print_data { 1537struct header_print_data {
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h
index e68f617d082f..21a6be09c129 100644
--- a/tools/perf/util/header.h
+++ b/tools/perf/util/header.h
@@ -27,7 +27,7 @@ enum {
27 HEADER_EVENT_DESC, 27 HEADER_EVENT_DESC,
28 HEADER_CPU_TOPOLOGY, 28 HEADER_CPU_TOPOLOGY,
29 HEADER_NUMA_TOPOLOGY, 29 HEADER_NUMA_TOPOLOGY,
30 30 HEADER_BRANCH_STACK,
31 HEADER_LAST_FEATURE, 31 HEADER_LAST_FEATURE,
32 HEADER_FEAT_BITS = 256, 32 HEADER_FEAT_BITS = 256,
33}; 33};