Commit 22ca2f7
perf script: Allow the generated script to be a path
Allow the script generated by "perf script -g <language>" to be a file
path and the language determined by the file extension.
This is useful in testing so that the generated script file can be
written to a test directory.
Committer testing:
$ perf record ls a.a
ls: cannot access 'a.a': No such file or directory
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.003 MB perf.data (7 samples) ]
$ perf script -g python
generated Python script: perf-script.py
$ perf script -g myscript.py
generated Python script: myscript.py
$ diff -u perf-script.py myscript.py
$ tail myscript.py
def trace_unhandled(event_name, context, event_fields_dict, perf_sample_dict):
print(get_dict_as_string(event_fields_dict))
print('Sample: {'+get_dict_as_string(perf_sample_dict['sample'], ', ')+'}')
def print_header(event_name, cpu, secs, nsecs, pid, comm):
print("%-20s %5u %05u.%09u %8u %-20s " % \
(event_name, cpu, secs, nsecs, pid, comm), end="")
def get_dict_as_string(a_dict, delimiter=' '):
return delimiter.join(['%s=%s'%(k,str(v))for k,v in sorted(a_dict.items())])
$
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Leo Yan <leo.yan@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>1 parent 9083ce5 commit 22ca2f7
2 files changed
Lines changed: 24 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
103 | 105 | | |
104 | 106 | | |
105 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4489 | 4489 | | |
4490 | 4490 | | |
4491 | 4491 | | |
| 4492 | + | |
4492 | 4493 | | |
4493 | 4494 | | |
4494 | 4495 | | |
| |||
4516 | 4517 | | |
4517 | 4518 | | |
4518 | 4519 | | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
4519 | 4531 | | |
4520 | | - | |
| 4532 | + | |
4521 | 4533 | | |
4522 | 4534 | | |
4523 | 4535 | | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
4524 | 4540 | | |
4525 | | - | |
4526 | | - | |
| 4541 | + | |
4527 | 4542 | | |
4528 | | - | |
| 4543 | + | |
4529 | 4544 | | |
| 4545 | + | |
4530 | 4546 | | |
4531 | 4547 | | |
4532 | 4548 | | |
| |||
0 commit comments