zsh-completions/src/_perf

384 lines
20 KiB
Plaintext
Raw Normal View History

2012-03-26 20:54:21 +00:00
#compdef perf
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Linux performance counters 3.3 (perf.wiki.kernel.org).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Julien Nicoulaud <julien.nicoulaud@gmail.com>
2020-05-09 11:44:00 +00:00
# * Shohei YOSHIDA <syohex@gmail.com>
2012-03-26 20:54:21 +00:00
#
# ------------------------------------------------------------------------------
2020-05-09 11:44:00 +00:00
_perf_events() {
local -a events=(${(@f)$(perf list | sed -n -e 's/^ \([^ =]*\).*$/\1/p')})
_values -s ',' 'events' $events
}
_perf_top_fields() {
local fields=(overhead overhead_sys overhead_us overhead_children sample period)
_values -s ',' 'fields' $fields
}
2012-03-26 20:54:21 +00:00
_perf_stat_command() {
_alternative "_command_names -e" "subcommand:command:(record report)"
}
2012-03-26 20:54:21 +00:00
_perf() {
local context curcontext="$curcontext" state line
typeset -A opt_args
2012-03-26 20:54:21 +00:00
local ret=1
_arguments -C \
'(- : *)--version[show version number and exit]' \
'(- : *)--help[show help]: :_perf_cmds' \
'1: :_perf_cmds' \
'*::arg:->args' \
&& ret=0
case $state in
(args)
curcontext="${curcontext%:*:*}:perf-cmd-$words[1]:"
case $line[1] in
(annotate)
# TODO Complete CPU list
# TODO Complete disassembler style
_arguments \
'(- : *)'{-a,--all}'[prints all the available commands on the standard output]' \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-d --dsos)'{-d,--dsos=}'[only consider symbols in these dsos]:dso list' \
'(-s --symbol)'{-s,--symbol=}'[symbol to annotate]:symbol' \
'(-f --force)'{-f,--force}'[do not complain, do it]' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'(-D --dump-raw-trace)'{-D,--dump-raw-trace}'[dump raw trace in ASCII]' \
'(-k --vmlinux)'{-k,--vmlinux=}'[vmlinux pathname]: :_files' \
'(-m --modules)'{-m,--modules}'[load module symbols]' \
'(-l --print-line)'{-l,--print-line}'[print matching source lines]' \
'(-P --full-paths)'{-P,--full-paths}'[don'\''t shorten the displayed pathnames]' \
'--stdio[use the stdio interface]' \
'--tui[use the TUI interface]' \
'(-C --cpu)'{-C,--cpu}'[only report samples for the list of CPUs provided]:CPU list' \
'--asm-raw[show raw instruction encoding of assembly instructions]' \
'(--no-source)--source[interleave source code with assembly code]' \
'(--source)--no-source[don'\''t interleave source code with assembly code]' \
'--symfs=[look for files with symbols relative to this directory]: :_files -/' \
'(-M --disassembler-style)'{-M,--disassembler-style=}'[set disassembler style for objdump]:disassembler style' \
'1::symbol name' \
&& ret=0
;;
(archive)
_arguments \
'1: :_files' \
&& ret=0
;;
(bench)
# TODO Complete subsystems
# TODO Complete suites
_arguments \
'(-f --format)'{-f,--format=}'[specify format style]: :((default\:mainly\ for\ human\ reading simple\:friendly\ for\ automated\ processing\ by\ scripts))' \
'1::subsystem' \
'2::suite' \
&& ret=0
;;
(buildid-cache)
_arguments \
'(-a --add)'{-a,--add=}'[add specified file to the cache]: :_files' \
'(-r --remove)'{-r,--remove=}'[remove specified file from the cache]: :_files' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
&& ret=0
;;
(buildid-list)
_arguments \
'(-H --with-hits)'{-H,--with-hits}'[show only DSOs with hits]' \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-f --force)'{-f,--force}'[don'\''t do ownership validation]' \
'(-k --kernel)'{-k,--kernel}'[show running kernel build id]' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
&& ret=0
;;
(diff)
_arguments \
'(-M --displacement)'{-M,--displacement}'[show position displacement relative to baseline]' \
'(-D --dump-raw-trace)'{-D,--dump-raw-trace}'[dump raw trace in ASCII]' \
'(-m --modules)'{-m,--modules}'[load module symbols]' \
'(-d --dsos)'{-d,--dsos=}'[only consider symbols in these dsos]:dso list' \
'(-C --comms)'{-C,--comms=}'[only consider symbols in these comms]:comm list' \
'(-S --symbols)'{-S,--symbols=}'[only consider these symbols]:symbol list' \
'(-s --sort)'{-s,--sort=}'[sort by key(s)]: :_values -s , key pid comm dso symbol' \
'(-t --field-separator)'{-t,--field-separator=}'[use a special separator character and don'\''t pad with spaces]:separator' \
'(-v --verbose)'{-v,--verbose}'[be verbose, for instance, show the raw counts in addition to the diff]' \
'(-f --force)'{-f,--force}'[don'\''t complain, do it]' \
'--symfs=[look for files with symbols relative to this directory]: :_files -/' \
'1:old file:_files' \
'2:new file:_files' \
&& ret=0
;;
(evlist)
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
&& ret=0
;;
(inject)
_arguments \
'(-b --build-ids)'{-b,--build-ids=}'[inject build-ids into the output stream]:build-id list' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
&& ret=0
;;
(kmem)
# TODO Complete 'record' command
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'--caller[show per-callsite statistics]' \
'--alloc[show per-allocation statistics]' \
'(-s --sort)'{-s,--sort=}'[sort by output]: :_values -s , key frag hit bytes' \
'(-n --lines)'{-n,--lines}'[print n lines only]:number' \
'1:command:((record\:record\ the\ kmem\ events\ of\ an\ arbitrary\ workload stat\:report\ kernel\ memory\ statistics))' \
&& ret=0
;;
(kvm)
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-o --output)'{-o,--output=}'[output file name]: :_files' \
'--host=[collect host side performance profile]:host' \
'--guest=[collect guest side performance profile]:guest' \
'--guestmount=[guest os root file system mount directory]: :_files -/' \
'--guestkallsyms=[guest os /proc/kallsyms file copy]: :_files' \
'--guestmodules=[guest os /proc/modules file copy]: :_files' \
'--guestvmlinux=[guest os kernel vmlinux]: :_files' \
'1:command:((top record report diff buildid-list))' \
&& ret=0
;;
(list)
_arguments \
'1:event type:((hw\:hardware\ events hardware\:hardware\ events sw\:software\ events software\:software\ events cache\:cache\ events hwcache\:cache\ events tracepoint\:tracepoint\ events))' \
&& ret=0
;;
(lock)
# TODO Complete 'record' command
# TODO Complete 'report' command options
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'(-D --dump-raw-trace)'{-D,--dump-raw-trace}'[dump raw trace in ASCII]' \
'1:command:((record\:record\ lock\ events trace\:show\ raw\ lock\ events report\:report\ statistical\ data))' \
&& ret=0
;;
(probe)
2020-05-10 01:50:16 +00:00
_arguments \
'(-k --vmlinux)'{-k,--vmlinux=}'[specify vmlinux path which has debuginfo]:path:_files' \
'(-m --module)'{-m,--module=}'[specify module name]:modname_or_path:_files' \
'(-s --source)'{-s,--source=}'[specify path to kernel source]:path:_files -/' \
'(-v --verbose -q --quiet)'{-v,--verbose}'[be more verbose]' \
'(-q --quiet -v --verbose)'{-q,--quiet}'[be quiet]' \
\*{-a,--add=}'[define a probe event]:probe:' \
\*{-d,--del=}'[delete probe events]:probe:' \
'(-l --list)'{-l,--list=}'[list up current probe events]:event:' \
'(-L --line)'{-L,--line=}'[show source code lines which can be probed]' \
\*{-V,--vars=}'[show available local variables at given probe point]:probe:' \
'--externs[show external defined variables]' \
'--no-inlines[search only for non-inlined functions]' \
\*{-F,--funcs=}'[show available functions in given module or kernel]:filter:' \
\*{-D,--definition=}'[show trace-event definition]:probe:' \
'*--filter=[set filter]:filter:' \
'(-f --force)'{-f,--force}'[forcibly add events with existing name]' \
'(-n --dry-run)'{-n,--dry-run}'[dry run]' \
'--cache[cache the probes]' \
'--max-probes=[set the maximum number of probe points for an event]:number:' \
'--target-ns=[obtain mount namespace information from the target pid]:pid:_pids' \
'(-x --exec)'{-x,--exec=}'[specify path to the executable of shared library]:path:_files' \
'--demangle-kernel[demangle kernel symbols]' \
&& ret=0
2012-03-26 20:54:21 +00:00
;;
(record)
# TODO not implemented
;;
(report)
# TODO not implemented
;;
(sched)
# TODO Complete 'record' command
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'(-D --dump-raw-trace)'{-D,--dump-raw-trace}'[dump raw trace in ASCII]' \
'1:command:((record\:record\ scheduling\ events script\:see\ a\ detailed\ trace replay\:simulate\ the\ workload map\:print\ a\ textual\ context-switching\ outline))' \
&& ret=0
;;
(script)
# TODO not implemented
;;
(stat)
_arguments \
'(-e --events)'{-e,--events=}'[select the PMU event]:event:_perf_events' \
'(-i --no-inherit)'{-i,--no-inherit}'[child tasks do not inherit conters]' \
'(-p --pid)'{-p,--pid=}'[stat events on existing process id]:pid:_pids' \
'(-t --tid)'{-t,--tid=}'[stat events on existing thread id]:tid:' \
'(-a --all-cpus)'{-a,--all-cpus}'[system-wide collection from all CPUs]' \
'--no-scale[do not scale/normalize counter values]' \
\*{-d,--detailed}'[print more detailed statistics]' \
'(-r --repeat)'{-r,--repeat=}'[repeat command and print average + stddev]:count:' \
'(-B --big-num)'{-B,--big-num}'[print large numbers with thousands separators according to locale]' \
'(-C --cpu)'{-C,--cpu=}'[count only the list of CPUs]:cpus:' \
'(-A --no-aggr)'{-A,--no-aggr}'[do not aggregate counts across all monitored CPUs]' \
'(-n --null)'{-n,--null}'[null run]' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'(-x --field-seperator)'{-x,--field-separator=}'[print separator]' \
'--table[display time for each run in a table format]' \
'(-G --cgroup)'{-G,--cgroup=}'[monitor only in the container called this name]' \
'(-o --output)'{-o,--output=}'[print the output into this file]:file:_files' \
'--append[append to the output file desinated with -o option]' \
'--log-fd[log output to fd, instead of stderr]' \
'--pre[pre measurement hook]: :_command_names -e' \
'--post[post measurement hook]: :_command_names -e' \
'(-I --interval-print)'{-I,--interval-print=}'[print count deltas every millseconds]:msec:' \
'--interval-count[print count delta for fixed number of times]:times:' \
'--interval-clear[clear the screen before next interval]' \
'--timeout[stop the perf stat session and print count after milliseconds]:msec:' \
'--metric-only[only print compted metrics]' \
'--per-socket[aggregate counts per processor socket for system-wide mode measurements]' \
'--per-die[aggregate counts per processor die for sytem-wide mode measurements]' \
'--per-core[aggregate counts per phisical processor for sytem-wide mode measurements]' \
'--per-thread[aggregate counts per mmonitored threads]' \
'(-D --delay)'{-D,--delay=}'[wait msecs before measuring]:msec:' \
'(-T --transaction)'{-T,--transaction}'[print statistics of transactional execution]' \
'(-)1:command:_perf_stat_command' \
'*::arg:_normal' \
&& ret=0
# TODO report/record sub-subcommand completion
2012-03-26 20:54:21 +00:00
;;
(test)
_arguments \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
&& ret=0
;;
(timechart)
# TODO Complete 'record' command
_arguments \
'(-i --input)'{-i,--input=}'[input file name]: :_files' \
'(-o --output)'{-o,--output=}'[output file name]: :_files' \
'(-w --width)'{-w,--width=}'[select the width of the SVG file]:width' \
'(-P --power-only)'{-P,--power-only}'[only output the CPU power section of the diagram]' \
'(-p --process)'{-p,--process}'[select the processes to display, by name or PID]:process' \
'--symfs=[look for files with symbols relative to this directory]: :_files -/' \
'1:command:((record))' \
&& ret=0
;;
(top)
2020-05-09 11:44:00 +00:00
_arguments \
'(-a --all-cpus)'{-a,--all-cpus}'[system wide collection]' \
'(-c --count)'{-c,--count=}'[event period to sample]:count:' \
'(-C --cpu)'{-C,--cpu=}'[monitor only the list of CPUs provided]:cpu_list:' \
'(-d --delay)'{-d,--delay=}'[number of seconds to delay between refreshes]' \
'(-e --event)'{-e,--event=}'[select the PMU event]:event:_perf_events' \
'(-E --entries)'{-E,--entries=}'[display thie many functions]' \
'(-f --count-filter)'{-f,--count-filter=}'[only display fnctions with more events than this]:count:' \
'--group[put the counters into a counter group]' \
'(-F --freq)'{-F,--freq=}'[profile at thie frequency]:freq:(max)' \
'(-i --inherit)'{-i,--inherit}'[child tasks do not inherit counters]' \
'(-k --vmlinux --ignore-vmlinux)'{-k,--vmlinux=}'[path to vmlinux]:vmlinux:_files' \
'(-k --vmlinux)--ignore-vmlinux[ignore vmlinux files]' \
'--kallsyms=[kallsyms pathname]:sym_path:_files' \
'(-m --mmap-pages)'{-m,--mmap-pages=}'[number of mmap data pages or size]:number:' \
'(-p --pid)'{-p,--pid=}'[profile events on existing process ID]:pid:_pids' \
'(-t --tid)'{-t,--tid=}'[profile events on existing thread ID]:tid:' \
'(-u --uid)'{-u,--uid=}'[record events in threads owned by uid]:uid:' \
'(-r --realtime)'{-r,--realtime=}'[collect data with this RT SCHED_FIFO priority]:priority:' \
'--sym-annotate=[annotate this symbol]' \
'(-K --hide_kernel_symbols)'{-K,--hide_kernel_symbols}'[hide kernel symbols]' \
'(-U --hide_user_symbols)'{-K,--hide_user_symbols}'[hide user symbols]' \
'--demangle-kernel[demangle kernel symbols]' \
'(-D --dump-symtab)'{-D,--dump-symtab}'[dump the symbol table used for profiling]' \
'(-v --verbose)'{-v,--verbose}'[be more verbose]' \
'(-z --zero)'{-z,--zero}'[zero history access display updates]' \
'(-s --sort)'{-s,--sort}'[sort by keys]' \
'--fields=[specify output field ]:fields:_perf_top_fields' \
'(-n --show-nr-samples)'{-n,--show-nr-samples}'[show a column with the number of samples]' \
'--show-total-period[show a column with the sum of periods]' \
'--dsos[only consider symbols in these dsos]' \
'--comms[only consider symbols in these comms]' \
'--symbols[only consider these symbols]' \
'(-M --disassembler-style)'{-M,--disassembler-style=}'[set disassembler style]:style:' \
'(--no-source)--source[interleave source code with assembly code]' \
'(--source)--no-source[disable interleaving source code]' \
'--asm-raw[show raw instruction encoding of assembly instructions]' \
'-g[Enables call-graph recording]' \
'--call-graph[setup and enable call-graph recording]' \
'--children[accumulate callchain of children to parent entry]' \
'--max-stack[set the stack depth limit]' \
'--ignore-callees=[ignore callees of functions regex]:regex:' \
'--percent-limit[do not show entries which have an overhead under that percent]' \
'(-w --column-widths)'{-w,--column-widths=}'[force each column width to this list]' \
'--proc-map-timeout[set timeout limit for processing process map]' \
'(-b --branch-any)'{-b,--branch-any}'[enable taken branch stack sampling]' \
'(-j --branch-filter)'{-j,--branch-filter}'[enable taken branch stack sampling]' \
'--raw-trace[do not use print fmt or plugins]' \
'--hierarchy[enable hierarchy output]' \
'--overwrite[overwrite records]' \
'--force[do not do ownership validation]' \
'--num-thread-synthesize[threads to run when synthesizing events for existing processes]'\
'--namespaces[record events of type PREF_RECORD_NAMESPACES]' \
'--switch-on=[only consider events after this event is found]:event:' \
'--switch-off=[stop considering events after this event is found]:event:' \
'--show-on-off-events[show the --switch-on/off events too]' \
&& ret=0
2012-03-26 20:54:21 +00:00
;;
(help)
_arguments \
'(- : *)'{-a,--all}'[prints all the available commands on the standard output]' \
'1: :_perf_cmds' \
&& ret=0
;;
*)
_call_function ret _perf_cmd_$words[1] && ret=0
(( ret )) && _message 'no more arguments'
;;
esac
;;
esac
}
# FIXME Parse 'perf --help' instead of hard-coding.
(( $+functions[_perf_cmds] )) ||
_perf_cmds() {
local commands; commands=(
'annotate:read perf.data (created by perf record) and display annotated code'
'archive:create archive with object files with build-ids found in perf.data file'
'bench:general framework for benchmark suites'
'buildid-cache:manage build-id cache'
'buildid-list:list the buildids in a perf.data file'
'diff:read two perf.data files and display the differential profile'
'evlist:list the event names in a perf.data file'
'inject:filter to augment the events stream with additional information'
'kmem:tool to trace/measure kernel memory(slab) properties'
'kvm:tool to trace/measure kvm guest os'
'list:list all symbolic event types'
'lock:analyze lock events'
'probe:define new dynamic tracepoints'
'record:run a command and record its profile into perf.data'
'report:read perf.data (created by perf record) and display the profile'
'sched:tool to trace/measure scheduler properties (latencies)'
'script:read perf.data (created by perf record) and display trace output'
'stat:run a command and gather performance counter statistics'
'test:runs sanity tests'
'timechart:tool to visualize total system behavior during a workload'
'top:system profiling tool'
'help:show command usage information'
)
_describe -t commands 'command' commands "$@"
}
_perf "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et