diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 21:20:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-12 21:20:11 -0400 |
commit | ade0899b298ba2c43bfd6abd8cbc2545944cde0c (patch) | |
tree | a448dfb440b3b958b6306bb43620cd5d76f504bf /tools/perf/builtin-script.c | |
parent | 871a0596cb2f51b57dc583d1a7c4be0186582fe7 (diff) | |
parent | 95cf59ea72331d0093010543b8951bb43f262cac (diff) |
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar:
"This tree includes some late late perf items that missed the first
round:
tools:
- Bash auto completion improvements, now we can auto complete the
tools long options, tracepoint event names, etc, from Namhyung Kim.
- Look up thread using tid instead of pid in 'perf sched'.
- Move global variables into a perf_kvm struct, from David Ahern.
- Hists refactorings, preparatory for improved 'diff' command, from
Jiri Olsa.
- Hists refactorings, preparatory for event group viewieng work, from
Namhyung Kim.
- Remove double negation on optional feature macro definitions, from
Namhyung Kim.
- Remove several cases of needless global variables, on most
builtins.
- misc fixes
kernel:
- sysfs support for IBS on AMD CPUs, from Robert Richter.
- Support for an upcoming Intel CPU, the Xeon-Phi / Knights Corner
HPC blade PMU, from Vince Weaver.
- misc fixes"
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits)
perf: Fix perf_cgroup_switch for sw-events
perf: Clarify perf_cpu_context::active_pmu usage by renaming it to ::unique_pmu
perf/AMD/IBS: Add sysfs support
perf hists: Add more helpers for hist entry stat
perf hists: Move he->stat.nr_events initialization to a template
perf hists: Introduce struct he_stat
perf diff: Removing the total_period argument from output code
perf tool: Add hpp interface to enable/disable hpp column
perf tools: Removing hists pair argument from output path
perf hists: Separate overhead and baseline columns
perf diff: Refactor diff displacement possition info
perf hists: Add struct hists pointer to struct hist_entry
perf tools: Complete tracepoint event names
perf/x86: Add support for Intel Xeon-Phi Knights Corner PMU
perf evlist: Remove some unused methods
perf evlist: Introduce add_newtp method
perf kvm: Move global variables into a perf_kvm struct
perf tools: Convert to BACKTRACE_SUPPORT
perf tools: Long option completion support for each subcommands
perf tools: Complete long option names of perf command
...
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 90 |
1 files changed, 42 insertions, 48 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 1be843aa1546..fb9625083a2e 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -24,7 +24,6 @@ static u64 last_timestamp; | |||
24 | static u64 nr_unordered; | 24 | static u64 nr_unordered; |
25 | extern const struct option record_options[]; | 25 | extern const struct option record_options[]; |
26 | static bool no_callchain; | 26 | static bool no_callchain; |
27 | static bool show_full_info; | ||
28 | static bool system_wide; | 27 | static bool system_wide; |
29 | static const char *cpu_list; | 28 | static const char *cpu_list; |
30 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | 29 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
@@ -473,8 +472,6 @@ static int cleanup_scripting(void) | |||
473 | return scripting_ops->stop_script(); | 472 | return scripting_ops->stop_script(); |
474 | } | 473 | } |
475 | 474 | ||
476 | static const char *input_name; | ||
477 | |||
478 | static int process_sample_event(struct perf_tool *tool __maybe_unused, | 475 | static int process_sample_event(struct perf_tool *tool __maybe_unused, |
479 | union perf_event *event, | 476 | union perf_event *event, |
480 | struct perf_sample *sample, | 477 | struct perf_sample *sample, |
@@ -1156,20 +1153,40 @@ out: | |||
1156 | return n_args; | 1153 | return n_args; |
1157 | } | 1154 | } |
1158 | 1155 | ||
1159 | static const char * const script_usage[] = { | 1156 | static int have_cmd(int argc, const char **argv) |
1160 | "perf script [<options>]", | 1157 | { |
1161 | "perf script [<options>] record <script> [<record-options>] <command>", | 1158 | char **__argv = malloc(sizeof(const char *) * argc); |
1162 | "perf script [<options>] report <script> [script-args]", | 1159 | |
1163 | "perf script [<options>] <script> [<record-options>] <command>", | 1160 | if (!__argv) { |
1164 | "perf script [<options>] <top-script> [script-args]", | 1161 | pr_err("malloc failed\n"); |
1165 | NULL | 1162 | return -1; |
1166 | }; | 1163 | } |
1164 | |||
1165 | memcpy(__argv, argv, sizeof(const char *) * argc); | ||
1166 | argc = parse_options(argc, (const char **)__argv, record_options, | ||
1167 | NULL, PARSE_OPT_STOP_AT_NON_OPTION); | ||
1168 | free(__argv); | ||
1167 | 1169 | ||
1168 | static const struct option options[] = { | 1170 | system_wide = (argc == 0); |
1171 | |||
1172 | return 0; | ||
1173 | } | ||
1174 | |||
1175 | int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | ||
1176 | { | ||
1177 | bool show_full_info = false; | ||
1178 | const char *input_name = NULL; | ||
1179 | char *rec_script_path = NULL; | ||
1180 | char *rep_script_path = NULL; | ||
1181 | struct perf_session *session; | ||
1182 | char *script_path = NULL; | ||
1183 | const char **__argv; | ||
1184 | int i, j, err; | ||
1185 | const struct option options[] = { | ||
1169 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1186 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1170 | "dump raw trace in ASCII"), | 1187 | "dump raw trace in ASCII"), |
1171 | OPT_INCR('v', "verbose", &verbose, | 1188 | OPT_INCR('v', "verbose", &verbose, |
1172 | "be more verbose (show symbol address, etc)"), | 1189 | "be more verbose (show symbol address, etc)"), |
1173 | OPT_BOOLEAN('L', "Latency", &latency_format, | 1190 | OPT_BOOLEAN('L', "Latency", &latency_format, |
1174 | "show latency attributes (irqs/preemption disabled, etc)"), | 1191 | "show latency attributes (irqs/preemption disabled, etc)"), |
1175 | OPT_CALLBACK_NOOPT('l', "list", NULL, NULL, "list available scripts", | 1192 | OPT_CALLBACK_NOOPT('l', "list", NULL, NULL, "list available scripts", |
@@ -1179,8 +1196,7 @@ static const struct option options[] = { | |||
1179 | parse_scriptname), | 1196 | parse_scriptname), |
1180 | OPT_STRING('g', "gen-script", &generate_script_lang, "lang", | 1197 | OPT_STRING('g', "gen-script", &generate_script_lang, "lang", |
1181 | "generate perf-script.xx script in specified language"), | 1198 | "generate perf-script.xx script in specified language"), |
1182 | OPT_STRING('i', "input", &input_name, "file", | 1199 | OPT_STRING('i', "input", &input_name, "file", "input file name"), |
1183 | "input file name"), | ||
1184 | OPT_BOOLEAN('d', "debug-mode", &debug_mode, | 1200 | OPT_BOOLEAN('d', "debug-mode", &debug_mode, |
1185 | "do various checks like samples ordering and lost events"), | 1201 | "do various checks like samples ordering and lost events"), |
1186 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, | 1202 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
@@ -1195,10 +1211,9 @@ static const struct option options[] = { | |||
1195 | "comma separated output fields prepend with 'type:'. " | 1211 | "comma separated output fields prepend with 'type:'. " |
1196 | "Valid types: hw,sw,trace,raw. " | 1212 | "Valid types: hw,sw,trace,raw. " |
1197 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," | 1213 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," |
1198 | "addr,symoff", | 1214 | "addr,symoff", parse_output_fields), |
1199 | parse_output_fields), | ||
1200 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 1215 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
1201 | "system-wide collection from all CPUs"), | 1216 | "system-wide collection from all CPUs"), |
1202 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", | 1217 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
1203 | "only consider these symbols"), | 1218 | "only consider these symbols"), |
1204 | OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), | 1219 | OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), |
@@ -1208,37 +1223,16 @@ static const struct option options[] = { | |||
1208 | "display extended information from perf.data file"), | 1223 | "display extended information from perf.data file"), |
1209 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, | 1224 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, |
1210 | "Show the path of [kernel.kallsyms]"), | 1225 | "Show the path of [kernel.kallsyms]"), |
1211 | |||
1212 | OPT_END() | 1226 | OPT_END() |
1213 | }; | 1227 | }; |
1214 | 1228 | const char * const script_usage[] = { | |
1215 | static int have_cmd(int argc, const char **argv) | 1229 | "perf script [<options>]", |
1216 | { | 1230 | "perf script [<options>] record <script> [<record-options>] <command>", |
1217 | char **__argv = malloc(sizeof(const char *) * argc); | 1231 | "perf script [<options>] report <script> [script-args]", |
1218 | 1232 | "perf script [<options>] <script> [<record-options>] <command>", | |
1219 | if (!__argv) { | 1233 | "perf script [<options>] <top-script> [script-args]", |
1220 | pr_err("malloc failed\n"); | 1234 | NULL |
1221 | return -1; | 1235 | }; |
1222 | } | ||
1223 | |||
1224 | memcpy(__argv, argv, sizeof(const char *) * argc); | ||
1225 | argc = parse_options(argc, (const char **)__argv, record_options, | ||
1226 | NULL, PARSE_OPT_STOP_AT_NON_OPTION); | ||
1227 | free(__argv); | ||
1228 | |||
1229 | system_wide = (argc == 0); | ||
1230 | |||
1231 | return 0; | ||
1232 | } | ||
1233 | |||
1234 | int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | ||
1235 | { | ||
1236 | char *rec_script_path = NULL; | ||
1237 | char *rep_script_path = NULL; | ||
1238 | struct perf_session *session; | ||
1239 | char *script_path = NULL; | ||
1240 | const char **__argv; | ||
1241 | int i, j, err; | ||
1242 | 1236 | ||
1243 | setup_scripting(); | 1237 | setup_scripting(); |
1244 | 1238 | ||