about summary refs log tree commit diff
path: root/Completion/Unix/Command/_truss
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2016-07-17 12:32:02 +0200
committerOliver Kiddle <opk@zsh.org>2016-07-17 12:32:02 +0200
commit52f46cca751cc40db978b88dd6379866cad30b15 (patch)
tree903f96a00ba12a96825a16d3d03ac4db239701c9 /Completion/Unix/Command/_truss
parentccb45b320124d17f4a2594e85c80c970bb0259ef (diff)
downloadzsh-52f46cca751cc40db978b88dd6379866cad30b15.tar.gz
zsh-52f46cca751cc40db978b88dd6379866cad30b15.tar.xz
zsh-52f46cca751cc40db978b88dd6379866cad30b15.zip
38867: update strace completion
Also factor out completion for system calls and new functions for
truss and ltrace.
Diffstat (limited to 'Completion/Unix/Command/_truss')
-rw-r--r--Completion/Unix/Command/_truss76
1 files changed, 76 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_truss b/Completion/Unix/Command/_truss
new file mode 100644
index 000000000..656c94244
--- /dev/null
+++ b/Completion/Unix/Command/_truss
@@ -0,0 +1,76 @@
+#compdef truss
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+local args faults
+
+args=(
+  '(-c)-a[show argument strings with exec system call]'
+  '(-a -d -D -e -E -l -r -v -w -x)-c[count traced system calls, signals etc]'
+  '(-c)-d[include timestamps in output]'
+  '(-c)-D[include delta timestamps in output]'
+  '(-c)-e[show environment strings with exec system call]'
+  '-f[follow child processes created after a fork]'
+  '-o+[specify trace output file]:output file:_files'
+)
+
+case $OSTYPE in
+  aix*|solaris*)
+    args+=(
+      '(-c)-E[include delta timestamps of time spent within the system call]'
+      "-i[don't display interruptible sleeping system calls]"
+      '(-c)-l[include LWP id in each line of output]'
+      '-m+[specify machine faults to trace]: :->faults'
+      '(-c)-r+[show full contents of the I/O buffer for each read()]:file descriptor'
+      '-s+[specify signals to trace]:signal:_sequence _signals -M "B\:!="'
+      '-S+[specify signals at which process should be stopped and abandoned]:signal:_sequence _signals -M "B\:!="'
+      '-t+[specify system calls to trace or exclude]:system call:_sequence _sys_calls -a -M "B\:!="'
+      '-T+[specify system calls at which process should be stopped and abandoned]:system call:_sequence _sys_calls -a -M "B\:!="'
+      '*-u+[user-level function call tracing]: :->userfuncs'
+      '-U+[specify user-level functions at which process should be stopped and abandoned]: :->userfuncs'
+      '(-c)-v+[enable verbose output of structures for specified system calls]:system call:_sequence _sys_calls -a -M "B\:!="'
+      '(-c)-w+[show full contents of the I/O buffer for each write()]:file descriptor'
+      '(-c)-x+[enable raw output of structures for specified system calls]:system call:_sequence _sys_calls -a'
+      '-p[trace specified existing processes]'
+    )
+  ;;
+  dragonfly*|freebsd*)
+    args+=(
+      '-s+[specify the maximum string size to print]:maximum string size [32]'
+      "(-c)-S[don't report signals received by the process]"
+      '(*)-p[trace specified existing processes]:pid:_pids'
+    )
+  ;;
+esac
+
+_arguments -C -s : $args \
+  '*::arguments:->args' && ret=0
+
+case $state in
+  faults)
+    faults=( all ${${${(M)${(f)"$(</usr/include/sys/fault.h)"}:#?define[[:blank:]]##FLT*}#*[[:blank:]]FLT}%%[[:blank:]]*} ) 2>/dev/null
+    _sequence _wanted faults expl fault compadd - -M 'B:!=' -M 'B:[Ff][Ll][Tt]=' -M 'm:{a-z}={A-Z}' -a faults && ret=0
+  ;;
+  args)
+    if [[ $OSTYPE = solaris* ]] && (( $+opt_args[-p] )); then
+      _pids && ret=0
+    elif (( CURRENT == 1 )); then
+      _command_names -e && ret=0
+    else
+      _normal && ret=0
+    fi
+  ;;
+  userfuncs)
+    if [[ -prefix *: ]]; then
+      _message -e functions function
+    else
+      compset -P '*,'
+      compset -S '[,:]*'
+      _description -x libs expl lib
+      compadd "$expl[@]" -S '' lib && ret=0
+      compadd "$expl[@]" -qS, a.out && ret=0
+    fi
+  ;;
+esac
+
+return ret