Lines Matching refs:script

380 	return fprintf(fp, "[ perf script: Wrote %.3f MB %s (%" PRIu64 " samples) ]\n",
719 tod_scnprintf(struct perf_script *script, char *buf, int buflen,
730 if (buflen < 64 || !script)
733 env = &script->session->header.env;
780 static int perf_sample__fprintf_start(struct perf_script *script,
869 tod_scnprintf(script, tstr, sizeof(tstr), sample->time);
2110 static void perf_sample__fprint_metric(struct perf_script *script,
2132 evlist__alloc_stats(&stat_config, script->session->evlist, /*alloc_raw=*/false);
2191 static void process_event(struct perf_script *script,
2210 perf_sample__fprintf_start(script, sample, thread, evsel,
2219 if (!script->name_width)
2220 script->name_width = evlist__max_name_len(script->session->evlist);
2222 fprintf(fp, "%*s: ", script->name_width, evname ?: "[unknown]");
2270 if (script->stitch_lbr)
2322 perf_sample__fprint_metric(script, thread, evsel, sample, fp);
2390 pr_debug("\nperf script stopped\n");
2561 struct perf_script *script = container_of(tool, struct perf_script, tool);
2562 struct perf_session *session = script->session;
2580 perf_sample__fprintf_start(script, sample, thread, evsel,
2688 struct perf_script *script = container_of(tool, struct perf_script, tool);
2696 if (!script->show_switch_events)
2775 static void perf_script__fclose_per_event_dump(struct perf_script *script)
2777 struct evlist *evlist = script->session->evlist;
2788 static int perf_script__fopen_per_event_dump(struct perf_script *script)
2792 evlist__for_each_entry(script->session->evlist, evsel) {
2803 evsel->priv = evsel_script__new(evsel, script->session->data);
2811 perf_script__fclose_per_event_dump(script);
2815 static int perf_script__setup_per_event_dump(struct perf_script *script)
2819 if (script->per_event_dump)
2820 return perf_script__fopen_per_event_dump(script);
2824 evlist__for_each_entry(script->session->evlist, evsel)
2830 static void perf_script__exit_per_event_dump_stats(struct perf_script *script)
2834 evlist__for_each_entry(script->session->evlist, evsel) {
2843 static void perf_script__exit(struct perf_script *script)
2845 perf_thread_map__put(script->threads);
2846 perf_cpu_map__put(script->cpus);
2849 static int __cmd_script(struct perf_script *script)
2856 if (script->show_task_events) {
2857 script->tool.comm = process_comm_event;
2858 script->tool.fork = process_fork_event;
2859 script->tool.exit = process_exit_event;
2861 if (script->show_mmap_events) {
2862 script->tool.mmap = process_mmap_event;
2863 script->tool.mmap2 = process_mmap2_event;
2865 if (script->show_switch_events || (scripting_ops && scripting_ops->process_switch))
2866 script->tool.context_switch = process_switch_event;
2868 script->tool.auxtrace_error = process_auxtrace_error;
2869 if (script->show_namespace_events)
2870 script->tool.namespaces = process_namespaces_event;
2871 if (script->show_cgroup_events)
2872 script->tool.cgroup = process_cgroup_event;
2873 if (script->show_lost_events)
2874 script->tool.lost = process_lost_event;
2875 if (script->show_round_events) {
2876 script->tool.ordered_events = false;
2877 script->tool.finished_round = process_finished_round_event;
2879 if (script->show_bpf_events) {
2880 script->tool.ksymbol = process_bpf_events;
2881 script->tool.bpf = process_bpf_events;
2883 if (script->show_text_poke_events) {
2884 script->tool.ksymbol = process_bpf_events;
2885 script->tool.text_poke = process_text_poke_events;
2888 if (perf_script__setup_per_event_dump(script)) {
2893 ret = perf_session__process_events(script->session);
2895 if (script->per_event_dump)
2896 perf_script__exit_per_event_dump_stats(script);
2972 "perf script -s [spec:]script.[spec]):\n\n");
2980 /* Find script file relative to current directory or exec path */
2981 static char *find_script(const char *script)
2986 const char *ext = strrchr(script, '.');
2996 if (access(script, R_OK)) {
3002 exec_path, scripting_ops->dirname, script);
3004 script = path;
3005 if (access(script, R_OK))
3008 return strdup(script);
3015 const char *script, *ext;
3023 script = strchr(str, ':');
3024 if (script) {
3025 len = script - str;
3037 script++;
3039 script = str;
3040 ext = strrchr(script, '.');
3042 fprintf(stderr, "invalid script extension");
3047 fprintf(stderr, "invalid script extension");
3052 script_name = find_script(script);
3054 script_name = strdup(script);
3532 * Currently the only user of this function is the script browser, which
3694 static void script__setup_sample_type(struct perf_script *script)
3696 struct perf_session *session = script->session;
3701 if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) {
3704 script->stitch_lbr = false;
3737 static int set_maps(struct perf_script *script)
3739 struct evlist *evlist = script->session->evlist;
3741 if (!script->cpus || !script->threads)
3744 if (WARN_ONCE(script->allocated, "stats double allocation\n"))
3747 perf_evlist__set_maps(&evlist->core, script->cpus, script->threads);
3752 script->allocated = true;
3761 struct perf_script *script = container_of(tool, struct perf_script, tool);
3766 if (script->threads) {
3771 script->threads = thread_map__new_event(&event->thread_map);
3772 if (!script->threads)
3775 return set_maps(script);
3783 struct perf_script *script = container_of(tool, struct perf_script, tool);
3788 if (script->cpus) {
3793 script->cpus = cpu_map__new_data(&event->cpu_map.data);
3794 if (!script->cpus)
3797 return set_maps(script);
3817 struct perf_script *script = container_of(tool, struct perf_script, tool);
3819 ret = perf_script__setup_per_event_dump(script);
3903 struct perf_script script = {
3951 OPT_CALLBACK('s', "script", NULL, "name",
3952 "script file name (lang:script name, script name, or *)",
3954 OPT_STRING('g', "gen-script", &generate_script_lang, "lang",
3955 "generate perf-script.xx script in specified language"),
4021 OPT_BOOLEAN('\0', "show-task-events", &script.show_task_events,
4023 OPT_BOOLEAN('\0', "show-mmap-events", &script.show_mmap_events,
4025 OPT_BOOLEAN('\0', "show-switch-events", &script.show_switch_events,
4027 OPT_BOOLEAN('\0', "show-namespace-events", &script.show_namespace_events,
4029 OPT_BOOLEAN('\0', "show-cgroup-events", &script.show_cgroup_events,
4031 OPT_BOOLEAN('\0', "show-lost-events", &script.show_lost_events,
4033 OPT_BOOLEAN('\0', "show-round-events", &script.show_round_events,
4035 OPT_BOOLEAN('\0', "show-bpf-events", &script.show_bpf_events,
4037 OPT_BOOLEAN('\0', "show-text-poke-events", &script.show_text_poke_events,
4039 OPT_BOOLEAN('\0', "per-event-dump", &script.per_event_dump,
4055 OPT_STRING(0, "time", &script.time_str, "str",
4070 OPT_BOOLEAN('\0', "stitch-lbr", &script.stitch_lbr,
4072 OPTS_EVSWITCH(&script.evswitch),
4077 "perf script [<options>]",
4078 "perf script [<options>] record <script> [<record-options>] <command>",
4079 "perf script [<options>] report <script> [script-args]",
4080 "perf script [<options>] <script> [<record-options>] <command>",
4081 "perf script [<options>] <top-script> [script-args]",
4108 script.tool.ordered_events = false;
4124 "Please specify a valid report script"
4125 "(see 'perf script -l' for listing)\n");
4160 "Couldn't find script `%s'\n\n See perf"
4161 " script -l for available scripts.\n", argv[0]);
4173 "`%s' script requires options."
4174 "\n\n See perf script -l for available "
4300 session = perf_session__new(&data, &script.tool);
4305 script.tool.show_feat_hdr = SHOW_FEAT_HEADER;
4311 script.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO;
4327 script.session = session;
4328 script__setup_sample_type(&script);
4395 "perf-script");
4397 err = scripting_ops->generate_script(NULL, "perf-script");
4410 pr_debug("perf script started with script %s\n\n", script_name);
4419 if (script.time_str) {
4420 err = perf_time__parse_for_ranges_reltime(script.time_str, session,
4421 &script.ptime_range,
4422 &script.range_size,
4423 &script.range_num,
4429 script.ptime_range,
4430 script.range_num);
4433 err = evswitch__init(&script.evswitch, session->evlist, stderr);
4440 err = __cmd_script(&script);
4448 if (script.ptime_range) {
4450 zfree(&script.ptime_range);
4456 perf_script__exit(&script);