From 18a641596714be00dfa907b519d07ff1ec0636b5 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Tue, 12 May 2020 00:38:29 +0900 Subject: [PATCH] Implement 'perf mem' completion --- src/_perf | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/_perf b/src/_perf index 434f406..e9099f7 100644 --- a/src/_perf +++ b/src/_perf @@ -38,6 +38,11 @@ _perf_c2c_coalesce() { _values -s ',' 'columns' $columns } +_perf_mem_type() { + local types=(load store) + _values -s ',' 'type' $types +} + _perf_test_list() { # TODO show test detail local -a test_list=(${(@f)$(perf test list 2>&1 | sed -n -e 's/^ *\([^ ]*\): \(.*\)$/\1/p')}) @@ -220,7 +225,18 @@ _perf() { && ret=0 ;; (mem) - # TODO not implemented + _arguments \ + '(-i --input)'{-i,--input=}'[input file name]:file:_files' \ + '(-f --force)'{-f,--force}'[do not ownership validation]' \ + '(-t --type)'{-t,--type=}'[select the memory operation type]:type:_perf_mem_type' \ + '(-D --dump-raw-samples)'{-D,--dump-raw-trace}'[dump the raw decoded samples]' \ + '(-x --field-separator)'{-x,--field-separator=}'[specify the field separator used when raw samples]:separator:' \ + '(-C --cpu)'{-C,--cpu=}'[monitor only on the list of CPUs provided]:cpus:' \ + '(-U --hide-unresolved)'{-U,--hide-unresolved}'[only display entries resolved to a symbol]' \ + '(-p --phys-data)'{-p,--phys-data}'[record/report sample phisical addresses]' \ + '1:command:(record report)' \ + '*::arg:->mem_args' \ + && ret=0 ;; (probe) _arguments \ @@ -439,6 +455,21 @@ _perf() { ;; esac ;; + (mem_args) + case $words[1] in + (record) + _arguments \ + \*{-e,--event=}'[event selector]:events:_perf_events' \ + '(-K --all-kernel)'{-K,--all-kernel}'[configure all used events to run in kernel space]' \ + '(-U --all-user)'{-K,--all-user}'[configure all used events to run in user space]' \ + '(-v --verbose)'{-v,--verbose}'[be more verbose]' \ + '--ldlat=[specify desired latency for loads event]:latency:' \ + '1:command:_command_names -e' \ + '*::args:_normal' \ + && ret=0 + ;; + esac + ;; esac }