aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 6b4925f65bf0..0659dff4a21d 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -44,6 +44,7 @@ enum perf_output_field {
44 PERF_OUTPUT_ADDR = 1U << 10, 44 PERF_OUTPUT_ADDR = 1U << 10,
45 PERF_OUTPUT_SYMOFFSET = 1U << 11, 45 PERF_OUTPUT_SYMOFFSET = 1U << 11,
46 PERF_OUTPUT_SRCLINE = 1U << 12, 46 PERF_OUTPUT_SRCLINE = 1U << 12,
47 PERF_OUTPUT_PERIOD = 1U << 13,
47}; 48};
48 49
49struct output_option { 50struct output_option {
@@ -63,6 +64,7 @@ struct output_option {
63 {.str = "addr", .field = PERF_OUTPUT_ADDR}, 64 {.str = "addr", .field = PERF_OUTPUT_ADDR},
64 {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET}, 65 {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
65 {.str = "srcline", .field = PERF_OUTPUT_SRCLINE}, 66 {.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
67 {.str = "period", .field = PERF_OUTPUT_PERIOD},
66}; 68};
67 69
68/* default set to maintain compatibility with current format */ 70/* default set to maintain compatibility with current format */
@@ -229,6 +231,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
229 PERF_OUTPUT_CPU)) 231 PERF_OUTPUT_CPU))
230 return -EINVAL; 232 return -EINVAL;
231 233
234 if (PRINT_FIELD(PERIOD) &&
235 perf_evsel__check_stype(evsel, PERF_SAMPLE_PERIOD, "PERIOD",
236 PERF_OUTPUT_PERIOD))
237 return -EINVAL;
238
232 return 0; 239 return 0;
233} 240}
234 241
@@ -448,6 +455,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
448 455
449 print_sample_start(sample, thread, evsel); 456 print_sample_start(sample, thread, evsel);
450 457
458 if (PRINT_FIELD(PERIOD))
459 printf("%10" PRIu64 " ", sample->period);
460
451 if (PRINT_FIELD(EVNAME)) { 461 if (PRINT_FIELD(EVNAME)) {
452 const char *evname = perf_evsel__name(evsel); 462 const char *evname = perf_evsel__name(evsel);
453 printf("%s: ", evname ? evname : "[unknown]"); 463 printf("%s: ", evname ? evname : "[unknown]");
@@ -1543,7 +1553,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
1543 "comma separated output fields prepend with 'type:'. " 1553 "comma separated output fields prepend with 'type:'. "
1544 "Valid types: hw,sw,trace,raw. " 1554 "Valid types: hw,sw,trace,raw. "
1545 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," 1555 "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
1546 "addr,symoff", parse_output_fields), 1556 "addr,symoff,period", parse_output_fields),
1547 OPT_BOOLEAN('a', "all-cpus", &system_wide, 1557 OPT_BOOLEAN('a', "all-cpus", &system_wide,
1548 "system-wide collection from all CPUs"), 1558 "system-wide collection from all CPUs"),
1549 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", 1559 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",