[PATCH 1/7] perf record: Combine some auxtrace initialization into a single function

From: Adrian Hunter
Date: Tue Mar 06 2018 - 04:16:24 EST


In preparation for adding AUX area sampling support, combine some auxtrace
initialization into a single function.

Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
---
tools/perf/builtin-record.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 907267206973..9b6338ce9c2b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -273,6 +273,24 @@ static void record__read_auxtrace_snapshot(struct record *rec)
}
}

+static int record__auxtrace_init(struct record *rec)
+{
+ int err;
+
+ if (!rec->itr) {
+ rec->itr = auxtrace_record__init(rec->evlist, &err);
+ if (err)
+ return err;
+ }
+
+ err = auxtrace_parse_snapshot_options(rec->itr, &rec->opts,
+ rec->opts.auxtrace_snapshot_opts);
+ if (err)
+ return err;
+
+ return auxtrace_parse_filters(rec->evlist);
+}
+
#else

static inline
@@ -293,6 +311,11 @@ int auxtrace_record__snapshot_start(struct auxtrace_record *itr __maybe_unused)
return 0;
}

+static int record__auxtrace_init(struct record *rec __maybe_unused)
+{
+ return 0;
+}
+
#endif

static int record__mmap_evlist(struct record *rec,
@@ -1711,17 +1734,6 @@ int cmd_record(int argc, const char **argv)
alarm(rec->switch_output.time);
}

- if (!rec->itr) {
- rec->itr = auxtrace_record__init(rec->evlist, &err);
- if (err)
- goto out;
- }
-
- err = auxtrace_parse_snapshot_options(rec->itr, &rec->opts,
- rec->opts.auxtrace_snapshot_opts);
- if (err)
- goto out;
-
/*
* Allow aliases to facilitate the lookup of symbols for address
* filters. Refer to auxtrace_parse_filters().
@@ -1730,7 +1742,7 @@ int cmd_record(int argc, const char **argv)

symbol__init(NULL);

- err = auxtrace_parse_filters(rec->evlist);
+ err = record__auxtrace_init(rec);
if (err)
goto out;

--
1.9.1