perf script: Make perf_script a local variable

Change perf_script from being global to being local.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: David Ahern <dsahern@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1382427258-17495-4-git-send-email-adrian.hunter@intel.com
[ Made the minor consistency changes suggested by David Ahern ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Adrian Hunter 2013-10-22 10:34:07 +03:00 committed by Arnaldo Carvalho de Melo
parent 156a2b0229
commit 6f3e5eda9d

View file

@ -542,18 +542,9 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
return 0; return 0;
} }
static struct perf_tool perf_script = { struct perf_script {
.sample = process_sample_event, struct perf_tool tool;
.mmap = perf_event__process_mmap, struct perf_session *session;
.mmap2 = perf_event__process_mmap2,
.comm = perf_event__process_comm,
.exit = perf_event__process_exit,
.fork = perf_event__process_fork,
.attr = perf_event__process_attr,
.tracing_data = perf_event__process_tracing_data,
.build_id = perf_event__process_build_id,
.ordered_samples = true,
.ordering_requires_timestamps = true,
}; };
static void sig_handler(int sig __maybe_unused) static void sig_handler(int sig __maybe_unused)
@ -561,13 +552,13 @@ static void sig_handler(int sig __maybe_unused)
session_done = 1; session_done = 1;
} }
static int __cmd_script(struct perf_session *session) static int __cmd_script(struct perf_script *script)
{ {
int ret; int ret;
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
ret = perf_session__process_events(session, &perf_script); ret = perf_session__process_events(script->session, &script->tool);
if (debug_mode) if (debug_mode)
pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered);
@ -1273,6 +1264,21 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
char *script_path = NULL; char *script_path = NULL;
const char **__argv; const char **__argv;
int i, j, err; int i, j, err;
struct perf_script script = {
.tool = {
.sample = process_sample_event,
.mmap = perf_event__process_mmap,
.mmap2 = perf_event__process_mmap2,
.comm = perf_event__process_comm,
.exit = perf_event__process_exit,
.fork = perf_event__process_fork,
.attr = perf_event__process_attr,
.tracing_data = perf_event__process_tracing_data,
.build_id = perf_event__process_build_id,
.ordered_samples = true,
.ordering_requires_timestamps = true,
},
};
const struct option options[] = { const struct option options[] = {
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"), "dump raw trace in ASCII"),
@ -1498,10 +1504,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
if (!script_name) if (!script_name)
setup_pager(); setup_pager();
session = perf_session__new(&file, false, &perf_script); session = perf_session__new(&file, false, &script.tool);
if (session == NULL) if (session == NULL)
return -ENOMEM; return -ENOMEM;
script.session = session;
if (cpu_list) { if (cpu_list) {
if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap)) if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
return -1; return -1;
@ -1565,7 +1573,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
if (err < 0) if (err < 0)
goto out; goto out;
err = __cmd_script(session); err = __cmd_script(&script);
perf_session__delete(session); perf_session__delete(session);
cleanup_scripting(); cleanup_scripting();