diff options
| author | Ingo Molnar <mingo@kernel.org> | 2014-08-14 10:38:40 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-08-14 10:38:40 +0200 |
| commit | f373da34282560c60f0c197690eecb1b2dc49fc0 (patch) | |
| tree | 599bf61a8ebc9244f14636aaced884e5bdcfff45 /tools/perf/builtin-script.c | |
| parent | ddcd0973fe02aad3d4bdc59dd0f1db90f51105a9 (diff) | |
| parent | 1c65056c547141a0cb52fb8e6056f63524d2bbf2 (diff) | |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/probe fixes and improvements from Arnaldo Carvalho de Melo:
User visible changes:
* Do not show +/- callchain expansion when there are no childs (top/report) (Namhyung Kim)
* Fix -z and add respective 'z' hotkey to zero samples before refresh
in 'perf top' (Namhyung Kim)
* Capability probing fixes, improving the detection of
kernel features for non-priviledged users (Adrian Hunter)
* Add beautifier for mremap flags param in 'trace' (Alex Snast)
* Fix --list and --del options to show events when just uprobes is
enabled (Masami Hiramatsu)
* perf script: Allow callchains if any event samples them
* Don't look for kernel idle symbols in all DSOs in 'perf top' (Arnaldo Carvalho de Melo)
* Add cpu_startup_entry to the list of kernel idle symbols (Arnaldo Carvalho de Melo)
* 'perf top' terminal output fixes (Jiri Olsa)
* Fix stdin handling for 'perf kvm stat live' (Jiri Olsa)
* Fix missing label symbols (Adrian Hunter)
* Don't demangle C++ parameters and such by default, only in
--verbose mode (Namhyung Kim)
* Set proper sort__mode for the branch option (Naohiro Aota)
* Check recorded kernel version when finding vmlinux (Namhyung Kim)
Infrastructure changes:
* More prep work for intel PT (Adrian Hunter)
* Fix possible memory leaks (Namhyung Kim)
* Fix a memory leak in vmlinux_path__init() (Namhyung Kim)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/builtin-script.c')
| -rw-r--r-- | tools/perf/builtin-script.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 868c17d09762..c1b7029884b1 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -184,10 +184,6 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, if (perf_evsel__check_stype(evsel, PERF_SAMPLE_IP, "IP", PERF_OUTPUT_IP)) return -EINVAL; - - if (!no_callchain && - !(attr->sample_type & PERF_SAMPLE_CALLCHAIN)) - symbol_conf.use_callchain = false; } if (PRINT_FIELD(ADDR) && @@ -290,6 +286,19 @@ static int perf_session__check_output_opt(struct perf_session *session) set_print_ip_opts(&evsel->attr); } + if (!no_callchain) { + bool use_callchain = false; + + evlist__for_each(session->evlist, evsel) { + if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { + use_callchain = true; + break; + } + } + if (!use_callchain) + symbol_conf.use_callchain = false; + } + /* * set default for tracepoints to print symbols only * if callchains are present @@ -1471,12 +1480,13 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) bool show_full_info = false; bool header = false; bool header_only = false; + bool script_started = false; char *rec_script_path = NULL; char *rep_script_path = NULL; struct perf_session *session; char *script_path = NULL; const char **__argv; - int i, j, err; + int i, j, err = 0; struct perf_script script = { .tool = { .sample = process_sample_event, @@ -1718,8 +1728,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) exit(-1); } - if (symbol__init() < 0) - return -1; if (!script_name) setup_pager(); @@ -1730,14 +1738,18 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) if (header || header_only) { perf_session__fprintf_info(session, stdout, show_full_info); if (header_only) - return 0; + goto out_delete; } + if (symbol__init(&session->header.env) < 0) + goto out_delete; + script.session = session; if (cpu_list) { - if (perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap)) - return -1; + err = perf_session__cpu_bitmap(session, cpu_list, cpu_bitmap); + if (err < 0) + goto out_delete; } if (!no_callchain) @@ -1752,53 +1764,60 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) if (output_set_by_user()) { fprintf(stderr, "custom fields not supported for generated scripts"); - return -1; + err = -EINVAL; + goto out_delete; } input = open(file.path, O_RDONLY); /* input_name */ if (input < 0) { + err = -errno; perror("failed to open file"); - return -1; + goto out_delete; } err = fstat(input, &perf_stat); if (err < 0) { perror("failed to stat file"); - return -1; + goto out_delete; } if (!perf_stat.st_size) { fprintf(stderr, "zero-sized file, nothing to do!\n"); - return 0; + goto out_delete; } scripting_ops = script_spec__lookup(generate_script_lang); if (!scripting_ops) { fprintf(stderr, "invalid language specifier"); - return -1; + err = -ENOENT; + goto out_delete; } err = scripting_ops->generate_script(session->tevent.pevent, "perf-script"); - goto out; + goto out_delete; } if (script_name) { err = scripting_ops->start_script(script_name, argc, argv); if (err) - goto out; + goto out_delete; pr_debug("perf script started with script %s\n\n", script_name); + script_started = true; } err = perf_session__check_output_opt(session); if (err < 0) - goto out; + goto out_delete; err = __cmd_script(&script); +out_delete: perf_session__delete(session); - cleanup_scripting(); + + if (script_started) + cleanup_scripting(); out: return err; } |
