aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2013-10-22 03:34:07 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-10-23 09:27:03 -0400
commit6f3e5eda9d6cc74538430d8f9e8e4baa01249160 (patch)
tree2182f0d2fac4e75957b2ee0e96d22597ec5d06fe /tools/perf
parent156a2b022907687f28c72d1ba601015f295cd99e (diff)
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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-script.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 27de6068049d..0ae88c2538a1 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -542,18 +542,9 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
542 return 0; 542 return 0;
543} 543}
544 544
545static struct perf_tool perf_script = { 545struct perf_script {
546 .sample = process_sample_event, 546 struct perf_tool tool;
547 .mmap = perf_event__process_mmap, 547 struct perf_session *session;
548 .mmap2 = perf_event__process_mmap2,
549 .comm = perf_event__process_comm,
550 .exit = perf_event__process_exit,
551 .fork = perf_event__process_fork,
552 .attr = perf_event__process_attr,
553 .tracing_data = perf_event__process_tracing_data,
554 .build_id = perf_event__process_build_id,
555 .ordered_samples = true,
556 .ordering_requires_timestamps = true,
557}; 548};
558 549
559static void sig_handler(int sig __maybe_unused) 550static void sig_handler(int sig __maybe_unused)
@@ -561,13 +552,13 @@ static void sig_handler(int sig __maybe_unused)
561 session_done = 1; 552 session_done = 1;
562} 553}
563 554
564static int __cmd_script(struct perf_session *session) 555static int __cmd_script(struct perf_script *script)
565{ 556{
566 int ret; 557 int ret;
567 558
568 signal(SIGINT, sig_handler); 559 signal(SIGINT, sig_handler);
569 560
570 ret = perf_session__process_events(session, &perf_script); 561 ret = perf_session__process_events(script->session, &script->tool);
571 562
572 if (debug_mode) 563 if (debug_mode)
573 pr_err("Misordered timestamps: %" PRIu64 "\n", nr_unordered); 564 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)
1273 char *script_path = NULL; 1264 char *script_path = NULL;
1274 const char **__argv; 1265 const char **__argv;
1275 int i, j, err; 1266 int i, j, err;
1267 struct perf_script script = {
1268 .tool = {
1269 .sample = process_sample_event,
1270 .mmap = perf_event__process_mmap,
1271 .mmap2 = perf_event__process_mmap2,
1272 .comm = perf_event__process_comm,
1273 .exit = perf_event__process_exit,
1274 .fork = perf_event__process_fork,
1275 .attr = perf_event__process_attr,
1276 .tracing_data = perf_event__process_tracing_data,
1277 .build_id = perf_event__process_build_id,
1278 .ordered_samples = true,
1279 .ordering_requires_timestamps = true,
1280 },
1281 };
1276 const struct option options[] = { 1282 const struct option options[] = {
1277 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1283 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1278 "dump raw trace in ASCII"), 1284 "dump raw trace in ASCII"),
@@ -1498,10 +1504,12 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1498 if (!script_name) 1504 if (!script_name)
1499 setup_pager(); 1505 setup_pager();
1500 1506
1501 session = perf_session__new(&file, false, &perf_script); 1507 session = perf_session__new(&file, false, &script.tool);
1502 if (session == NULL) 1508 if (session == NULL)
1503 return -ENOMEM; 1509 return -ENOMEM;
1504 1510
1511 script.session = session;
1512
1505 if (cpu_list) { 1513 if (cpu_list) {
1506 if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap)) 1514 if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap))
1507 return -1; 1515 return -1;
@@ -1565,7 +1573,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1565 if (err < 0) 1573 if (err < 0)
1566 goto out; 1574 goto out;
1567 1575
1568 err = __cmd_script(session); 1576 err = __cmd_script(&script);
1569 1577
1570 perf_session__delete(session); 1578 perf_session__delete(session);
1571 cleanup_scripting(); 1579 cleanup_scripting();