Lines Matching refs:script

374 	return fprintf(fp, "[ perf script: Wrote %.3f MB %s (%" PRIu64 " samples) ]\n",
712 tod_scnprintf(struct perf_script *script, char *buf, int buflen,
723 if (buflen < 64 || !script)
726 env = &script->session->header.env;
773 static int perf_sample__fprintf_start(struct perf_script *script,
862 tod_scnprintf(script, tstr, sizeof(tstr), sample->time);
2056 static void perf_sample__fprint_metric(struct perf_script *script,
2078 evlist__alloc_stats(&stat_config, script->session->evlist, /*alloc_raw=*/false);
2137 static void process_event(struct perf_script *script,
2156 perf_sample__fprintf_start(script, sample, thread, evsel,
2165 if (!script->name_width)
2166 script->name_width = evlist__max_name_len(script->session->evlist);
2168 fprintf(fp, "%*s: ", script->name_width, evname ?: "[unknown]");
2216 if (script->stitch_lbr)
2268 perf_sample__fprint_metric(script, thread, evsel, sample, fp);
2336 pr_debug("\nperf script stopped\n");
2507 struct perf_script *script = container_of(tool, struct perf_script, tool);
2508 struct perf_session *session = script->session;
2526 perf_sample__fprintf_start(script, sample, thread, evsel,
2634 struct perf_script *script = container_of(tool, struct perf_script, tool);
2642 if (!script->show_switch_events)
2721 static void perf_script__fclose_per_event_dump(struct perf_script *script)
2723 struct evlist *evlist = script->session->evlist;
2734 static int perf_script__fopen_per_event_dump(struct perf_script *script)
2738 evlist__for_each_entry(script->session->evlist, evsel) {
2749 evsel->priv = evsel_script__new(evsel, script->session->data);
2757 perf_script__fclose_per_event_dump(script);
2761 static int perf_script__setup_per_event_dump(struct perf_script *script)
2765 if (script->per_event_dump)
2766 return perf_script__fopen_per_event_dump(script);
2770 evlist__for_each_entry(script->session->evlist, evsel)
2776 static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
2780 evlist__for_each_entry(script->session->evlist, evsel) {
2789 static void perf_script__exit(struct perf_script *script)
2791 perf_thread_map__put(script->threads);
2792 perf_cpu_map__put(script->cpus);
2795 static int __cmd_script(struct perf_script *script)
2802 if (script->show_task_events) {
2803 script->tool.comm = process_comm_event;
2804 script->tool.fork = process_fork_event;
2805 script->tool.exit = process_exit_event;
2807 if (script->show_mmap_events) {
2808 script->tool.mmap = process_mmap_event;
2809 script->tool.mmap2 = process_mmap2_event;
2811 if (script->show_switch_events || (scripting_ops && scripting_ops->process_switch))
2812 script->tool.context_switch = process_switch_event;
2814 script->tool.auxtrace_error = process_auxtrace_error;
2815 if (script->show_namespace_events)
2816 script->tool.namespaces = process_namespaces_event;
2817 if (script->show_cgroup_events)
2818 script->tool.cgroup = process_cgroup_event;
2819 if (script->show_lost_events)
2820 script->tool.lost = process_lost_event;
2821 if (script->show_round_events) {
2822 script->tool.ordered_events = false;
2823 script->tool.finished_round = process_finished_round_event;
2825 if (script->show_bpf_events) {
2826 script->tool.ksymbol = process_bpf_events;
2827 script->tool.bpf = process_bpf_events;
2829 if (script->show_text_poke_events) {
2830 script->tool.ksymbol = process_bpf_events;
2831 script->tool.text_poke = process_text_poke_events;
2834 if (perf_script__setup_per_event_dump(script)) {
2839 ret = perf_session__process_events(script->session);
2841 if (script->per_event_dump)
2842 perf_script__exit_per_event_dump_stats(script);
2918 "perf script -s [spec:]script.[spec]):\n\n");
2926 /* Find script file relative to current directory or exec path */
2927 static char *find_script(const char *script)
2932 const char *ext = strrchr(script, '.');
2942 if (access(script, R_OK)) {
2948 exec_path, scripting_ops->dirname, script);
2950 script = path;
2951 if (access(script, R_OK))
2954 return strdup(script);
2961 const char *script, *ext;
2969 script = strchr(str, ':');
2970 if (script) {
2971 len = script - str;
2983 script++;
2985 script = str;
2986 ext = strrchr(script, '.');
2988 fprintf(stderr, "invalid script extension");
2993 fprintf(stderr, "invalid script extension");
2998 script_name = find_script(script);
3000 script_name = strdup(script);
3471 * Currently the only user of this function is the script browser, which
3633 static void script__setup_sample_type(struct perf_script *script)
3635 struct perf_session *session = script->session;
3640 if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) {
3643 script->stitch_lbr = false;
3676 static int set_maps(struct perf_script *script)
3678 struct evlist *evlist = script->session->evlist;
3680 if (!script->cpus || !script->threads)
3683 if (WARN_ONCE(script->allocated, "stats double allocation\n"))
3686 perf_evlist__set_maps(&evlist->core, script->cpus, script->threads);
3691 script->allocated = true;
3700 struct perf_script *script = container_of(tool, struct perf_script, tool);
3705 if (script->threads) {
3710 script->threads = thread_map__new_event(&event->thread_map);
3711 if (!script->threads)
3714 return set_maps(script);
3722 struct perf_script *script = container_of(tool, struct perf_script, tool);
3727 if (script->cpus) {
3732 script->cpus = cpu_map__new_data(&event->cpu_map.data);
3733 if (!script->cpus)
3736 return set_maps(script);
3756 struct perf_script *script = container_of(tool, struct perf_script, tool);
3758 ret = perf_script__setup_per_event_dump(script);
3828 struct perf_script script = {
3876 OPT_CALLBACK('s', "script", NULL, "name",
3877 "script file name (lang:script name, script name, or *)",
3879 OPT_STRING('g', "gen-script", &generate_script_lang, "lang",
3880 "generate perf-script.xx script in specified language"),
3946 OPT_BOOLEAN('\0', "show-task-events", &script.show_task_events,
3948 OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events,
3950 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
3952 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
3954 OPT_BOOLEAN('\0', "show-cgroup-events", &script.show_cgroup_events,
3956 OPT_BOOLEAN('\0', "show-lost-events", &script.show_lost_events,
3958 OPT_BOOLEAN('\0', "show-round-events", &script.show_round_events,
3960 OPT_BOOLEAN('\0', "show-bpf-events", &script.show_bpf_events,
3962 OPT_BOOLEAN('\0', "show-text-poke-events", &script.show_text_poke_events,
3964 OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
3980 OPT_STRING(0, "time", &script.time_str, "str",
3995 OPT_BOOLEAN('\0', "stitch-lbr", &script.stitch_lbr,
3997 OPTS_EVSWITCH(&script.evswitch),
4002 "perf script [<options>]",
4003 "perf script [<options>] record <script> [<record-options>] <command>",
4004 "perf script [<options>] report <script> [script-args]",
4005 "perf script [<options>] <script> [<record-options>] <command>",
4006 "perf script [<options>] <top-script> [script-args]",
4033 script.tool.ordered_events = false;
4049 "Please specify a valid report script"
4050 "(see 'perf script -l' for listing)\n");
4085 "Couldn't find script `%s'\n\n See perf"
4086 " script -l for available scripts.\n", argv[0]);
4098 "`%s' script requires options."
4099 "\n\n See perf script -l for available "
4225 session = perf_session__new(&data, &script.tool);
4230 script.tool.show_feat_hdr = SHOW_FEAT_HEADER;
4236 script.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO;
4252 script.session = session;
4253 script__setup_sample_type(&script);
4320 "perf-script");
4322 err = scripting_ops->generate_script(NULL, "perf-script");
4335 pr_debug("perf script started with script %s\n\n", script_name);
4344 if (script.time_str) {
4345 err = perf_time__parse_for_ranges_reltime(script.time_str, session,
4346 &script.ptime_range,
4347 &script.range_size,
4348 &script.range_num,
4354 script.ptime_range,
4355 script.range_num);
4358 err = evswitch__init(&script.evswitch, session->evlist, stderr);
4365 err = __cmd_script(&script);
4370 if (script.ptime_range) {
4372 zfree(&script.ptime_range);
4378 perf_script__exit(&script);