diff options
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 4430340292c0..eb51325e8ad9 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "util/exec_cmd.h" | 6 | #include "util/exec_cmd.h" |
7 | #include "util/header.h" | 7 | #include "util/header.h" |
8 | #include "util/parse-options.h" | 8 | #include "util/parse-options.h" |
9 | #include "util/perf_regs.h" | ||
9 | #include "util/session.h" | 10 | #include "util/session.h" |
10 | #include "util/tool.h" | 11 | #include "util/tool.h" |
11 | #include "util/symbol.h" | 12 | #include "util/symbol.h" |
@@ -46,6 +47,7 @@ enum perf_output_field { | |||
46 | PERF_OUTPUT_SYMOFFSET = 1U << 11, | 47 | PERF_OUTPUT_SYMOFFSET = 1U << 11, |
47 | PERF_OUTPUT_SRCLINE = 1U << 12, | 48 | PERF_OUTPUT_SRCLINE = 1U << 12, |
48 | PERF_OUTPUT_PERIOD = 1U << 13, | 49 | PERF_OUTPUT_PERIOD = 1U << 13, |
50 | PERF_OUTPUT_IREGS = 1U << 14, | ||
49 | }; | 51 | }; |
50 | 52 | ||
51 | struct output_option { | 53 | struct output_option { |
@@ -66,6 +68,7 @@ struct output_option { | |||
66 | {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET}, | 68 | {.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET}, |
67 | {.str = "srcline", .field = PERF_OUTPUT_SRCLINE}, | 69 | {.str = "srcline", .field = PERF_OUTPUT_SRCLINE}, |
68 | {.str = "period", .field = PERF_OUTPUT_PERIOD}, | 70 | {.str = "period", .field = PERF_OUTPUT_PERIOD}, |
71 | {.str = "iregs", .field = PERF_OUTPUT_IREGS}, | ||
69 | }; | 72 | }; |
70 | 73 | ||
71 | /* default set to maintain compatibility with current format */ | 74 | /* default set to maintain compatibility with current format */ |
@@ -255,6 +258,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, | |||
255 | PERF_OUTPUT_PERIOD)) | 258 | PERF_OUTPUT_PERIOD)) |
256 | return -EINVAL; | 259 | return -EINVAL; |
257 | 260 | ||
261 | if (PRINT_FIELD(IREGS) && | ||
262 | perf_evsel__check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS", | ||
263 | PERF_OUTPUT_IREGS)) | ||
264 | return -EINVAL; | ||
265 | |||
258 | return 0; | 266 | return 0; |
259 | } | 267 | } |
260 | 268 | ||
@@ -352,6 +360,24 @@ out: | |||
352 | return 0; | 360 | return 0; |
353 | } | 361 | } |
354 | 362 | ||
363 | static void print_sample_iregs(union perf_event *event __maybe_unused, | ||
364 | struct perf_sample *sample, | ||
365 | struct thread *thread __maybe_unused, | ||
366 | struct perf_event_attr *attr) | ||
367 | { | ||
368 | struct regs_dump *regs = &sample->intr_regs; | ||
369 | uint64_t mask = attr->sample_regs_intr; | ||
370 | unsigned i = 0, r; | ||
371 | |||
372 | if (!regs) | ||
373 | return; | ||
374 | |||
375 | for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) { | ||
376 | u64 val = regs->regs[i++]; | ||
377 | printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val); | ||
378 | } | ||
379 | } | ||
380 | |||
355 | static void print_sample_start(struct perf_sample *sample, | 381 | static void print_sample_start(struct perf_sample *sample, |
356 | struct thread *thread, | 382 | struct thread *thread, |
357 | struct perf_evsel *evsel) | 383 | struct perf_evsel *evsel) |
@@ -525,6 +551,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample, | |||
525 | PERF_MAX_STACK_DEPTH); | 551 | PERF_MAX_STACK_DEPTH); |
526 | } | 552 | } |
527 | 553 | ||
554 | if (PRINT_FIELD(IREGS)) | ||
555 | print_sample_iregs(event, sample, thread, attr); | ||
556 | |||
528 | printf("\n"); | 557 | printf("\n"); |
529 | } | 558 | } |
530 | 559 | ||
@@ -1643,7 +1672,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1643 | "comma separated output fields prepend with 'type:'. " | 1672 | "comma separated output fields prepend with 'type:'. " |
1644 | "Valid types: hw,sw,trace,raw. " | 1673 | "Valid types: hw,sw,trace,raw. " |
1645 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," | 1674 | "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso," |
1646 | "addr,symoff,period,flags", parse_output_fields), | 1675 | "addr,symoff,period,iregs,flags", parse_output_fields), |
1647 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 1676 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
1648 | "system-wide collection from all CPUs"), | 1677 | "system-wide collection from all CPUs"), |
1649 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", | 1678 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |