perf inject: Move session handling out of __cmd_inject()
This is a preparation of fixing dso__load_kernel_sym(). It needs a session info before calling symbol__init(). Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1407825645-24586-6-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e3ed75bb53
commit
1cb8bdcca0
1 changed files with 17 additions and 12 deletions
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
struct perf_inject {
|
struct perf_inject {
|
||||||
struct perf_tool tool;
|
struct perf_tool tool;
|
||||||
|
struct perf_session *session;
|
||||||
bool build_ids;
|
bool build_ids;
|
||||||
bool sched_stat;
|
bool sched_stat;
|
||||||
const char *input_name;
|
const char *input_name;
|
||||||
|
@ -340,12 +341,8 @@ static int perf_evsel__check_stype(struct perf_evsel *evsel,
|
||||||
|
|
||||||
static int __cmd_inject(struct perf_inject *inject)
|
static int __cmd_inject(struct perf_inject *inject)
|
||||||
{
|
{
|
||||||
struct perf_session *session;
|
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
struct perf_data_file file = {
|
struct perf_session *session = inject->session;
|
||||||
.path = inject->input_name,
|
|
||||||
.mode = PERF_DATA_MODE_READ,
|
|
||||||
};
|
|
||||||
struct perf_data_file *file_out = &inject->output;
|
struct perf_data_file *file_out = &inject->output;
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
@ -357,10 +354,6 @@ static int __cmd_inject(struct perf_inject *inject)
|
||||||
inject->tool.tracing_data = perf_event__repipe_tracing_data;
|
inject->tool.tracing_data = perf_event__repipe_tracing_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
session = perf_session__new(&file, true, &inject->tool);
|
|
||||||
if (session == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (inject->build_ids) {
|
if (inject->build_ids) {
|
||||||
inject->tool.sample = perf_event__inject_buildid;
|
inject->tool.sample = perf_event__inject_buildid;
|
||||||
} else if (inject->sched_stat) {
|
} else if (inject->sched_stat) {
|
||||||
|
@ -396,8 +389,6 @@ static int __cmd_inject(struct perf_inject *inject)
|
||||||
perf_session__write_header(session, session->evlist, file_out->fd, true);
|
perf_session__write_header(session, session->evlist, file_out->fd, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
perf_session__delete(session);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +418,11 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
.mode = PERF_DATA_MODE_WRITE,
|
.mode = PERF_DATA_MODE_WRITE,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
struct perf_data_file file = {
|
||||||
|
.mode = PERF_DATA_MODE_READ,
|
||||||
|
};
|
||||||
|
int ret;
|
||||||
|
|
||||||
const struct option options[] = {
|
const struct option options[] = {
|
||||||
OPT_BOOLEAN('b', "build-ids", &inject.build_ids,
|
OPT_BOOLEAN('b', "build-ids", &inject.build_ids,
|
||||||
"Inject build-ids into the output stream"),
|
"Inject build-ids into the output stream"),
|
||||||
|
@ -461,8 +457,17 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.path = inject.input_name;
|
||||||
|
inject.session = perf_session__new(&file, true, &inject.tool);
|
||||||
|
if (inject.session == NULL)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (symbol__init() < 0)
|
if (symbol__init() < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return __cmd_inject(&inject);
|
ret = __cmd_inject(&inject);
|
||||||
|
|
||||||
|
perf_session__delete(inject.session);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue