From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19874 invoked from network); 25 Aug 2021 22:23:12 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Aug 2021 22:23:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date: Content-Transfer-Encoding:Content-ID:Content-Type:MIME-Version:Subject:To: From:Reply-To:Cc:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=lvYao6+9Eg0JrtQTLGz0YyJDYaZV24F5gimHB4LlpSQ=; b=CM55priIYqQlwD07wMZQaBpJtP UN+GCMpE8A/j+oB4BQRKatKYt+Afncnf29Qss6W1SRzzonZDnCkGIr1wPwBtk50TudXmy8rZ716AG h4V2kuM9/A3DjJN4id/17Zv3Q1xro5KhEzJ81EA7Gga9/OboFePNP4zqc7e5KPqESUfXdDxKmLdKK 2vfJdBY/hKs7T6NKjiXEGcbOKz/mjXW9s/M6ZeZIEu6GNLvAMrDFE3NHoINcnpeS+6fzu6NmQhvwW e1o1o5FNDgSmqDkBQ6C+a/Q+uQN3WJDuYkcv8UL5EbZONT+FiQwxj/LN87dHqWiKkHvv8wuckZ7qb AUpU37Pw==; Received: from authenticated user by zero.zsh.org with local id 1mJ1Id-000Gmt-Tz; Wed, 25 Aug 2021 22:23:11 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1mJ1IL-000GTz-0v; Wed, 25 Aug 2021 22:22:53 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.94.2) (envelope-from ) id 1mJ1IJ-0004uj-Fc for zsh-workers@zsh.org; Thu, 26 Aug 2021 00:22:51 +0200 From: Oliver Kiddle To: Zsh workers Subject: PATCH: update strace completion to reflect addition of long options MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18891.1629930171.1@hydra> Content-Transfer-Encoding: quoted-printable Date: Thu, 26 Aug 2021 00:22:51 +0200 Message-ID: <18892-1629930171.481331@uHSH.AX4g.L4Un> X-Seq: 49309 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: This updates the strace completion through strace 5.13. It appears that they have added long forms for all the options so this is mostly just adding those in but there was also a couple of new options mixed in. Oliver diff --git Completion/Linux/Command/_strace Completion/Linux/Command/_stra= ce index 7d4595a33..b3b6f5096 100644 --- Completion/Linux/Command/_strace +++ Completion/Linux/Command/_strace @@ -1,50 +1,66 @@ #compdef strace strace64 = -local curcontext=3D"$curcontext" state line root expl ret=3D1 +local curcontext=3D"$curcontext" root +local -i prec=3D1 form=3D1 ret=3D1 +local -a state line expl alts suf typeset -A opt_args = -(( EUID )) && root=3D'!' +(( EUID && ! $+_comp_priv_prefix )) && root=3D'!' = _arguments -C -s \ - '-a+[align return values in a specific column]:column number [40]' \ - '(-c)-i[print instruction pointer at time of syscall]' \ - '-o+[write the trace output to the file]:output file:->file-pipe' \ - '-q[suppress messages about attaching, detaching etc.]' \ - '(-q)-qq[suppress messages about process exit status]' \ - '(-c)-r[print a relative timestamp upon entry to each system call]' \ - '-s+[specify the maximum string size to print]:maximum string size [32]= ' \ - '(-c -ttt)-t[prefix each line of the trace with the time of day]' \ - '(-c -ttt -tt)-tt[prefix each line of the trace with the time of day in= cluding the microseconds]' \ - '(-c -tt -t)-ttt[prefix each line of the trace with the number of secon= ds and microseconds since the epoch]' \ - '(-c)-T[show the time spent in system calls]' \ - '(-xx)-x[print all non-ASCII strings in hexadecimal string format]' \ - '(-x)-xx[print all strings in hexadecimal string format]' \ - '-X+[set the format for printing of named constants and flags]:format:(= raw abbrev verbose)' \ - '(-c -yy)-y[print paths associated with file descriptor arguments]' \ - '(-c -y)-yy[print protocol specific information associated with socket = file descriptors]' \ - '(-C -i -k -r -ff -t -tt -ttt -T -y -yy)-c[count time, calls, and error= s for each system call and report a summary]' \ - '(-c)-C[count time, calls, and errors for each system call and report a= summary in addition to regular output]' \ - '-O+[overhead for tracing system calls]:overhead (microseconds)' \ - '-S+[sort the output of the histogram (-c option) by the specified crit= erion]:sort criterion [time]:(time calls errors name nothing)' \ - '-w[summarise syscall latency]' \ - '*-e+[select events to trace or how to trace]:system call:->expressions= ' \ - '*-P+[trace only system calls accessing given path]:path:_files' \ - '(-Z)-z[trace only system calls that return success]' \ - '(-z)-Z[trace only system calls that return an error]' \ - '-b+[detach from process on specified syscall]:syscall:(execve)' \ - '-f[trace child processes as they are created by currently traced proce= sses]' \ - '(-c -C)-ff[write each process trace to . (when using -o= ]' \ - '-D[run tracer as detached grandchild, keeping traced process as direct= child of calling process]' \ - '-I+[when strace can be interrupted by signals]:interruptible:((1\:"no = signals are blocked" 2\:"fatal signals are blocked while decoding syscall = (default)" 3\:"fatal signals are always blocked (default with -o)" 4\:"fat= al signals and SIGTSTP are always blocked"))' \ - '*-E+[set or remove exported environment variable]:variable:->envars' \ - "${root}-u+[run as specified user]:user:_users" \ - '(:)*-p+[attach to the process with specified process ID and begin trac= ing]:process ID:_pids' \ + \*{-E+,--env=3D}'[set or remove exported environment variable]:variable= :->envars' \ + '(:)*'{-p+,--attach=3D}'[attach to the process with specified process I= D and begin tracing]:process ID:_pids' \ + "${root}(-u --user)"{-u+,--user=3D}'[run as specified user]:user:_users= ' \ + '(-b --detach-on)'{-b+,--detach-on=3D}'[detach from process on specifie= d syscall]:syscall:(execve)' \ + '(--daemonize)-D[run tracer as detached grandchild, keeping traced proc= ess as direct child of calling process]' \ + '(-D)--daemonize=3D-[specify how to run tracer process]::method:(grandc= hild pgroup session)' \ + '(-f --follow-forks)'{-f,--follow-forks}'[trace child processes as they= are created by currently traced processes]' \ + '(-I --interruptible)'{-I+,--interruptible=3D}'[specify when strace can= be interrupted by signals]:interruptible:((1\:"no signals are blocked" 2\= :"fatal signals are blocked while decoding syscall (default)" 3\:"fatal si= gnals are always blocked (default with -o)" 4\:"fatal signals and SIGTSTP = are always blocked"))' \ + \*{-e+,--trace=3D}'[select events to trace or how to trace]:system call= :->expressions' \ + \*{-P+,--path=3D}'[trace only system calls accessing given path]:path:_= files' \ + '(-z -Z --successful-only --failed-only)'{-z,--successful-only}'[trace = only system calls that return success]' \ + '(-z -Z --successful-only --failed-only)'{-Z,--failed-only}'[trace only= system calls that return an error]' \ + '(-a --columns)'{-a+,--columns=3D}'[align return values in a specific c= olumn]:column number [40]' \ + '(-i --instruction-pointer -c --summary-only)'{-i,--instruction-pointer= }'[print instruction pointer at time of syscall]' \ + '(-c --summary-only -k --stack-traces)'{-k,--stack-traces}'[obtain stac= k trace between each syscall]' \ + '(-n --syscall-number)'{-n,--syscall-number}'[print syscall number]' \ + '(-o --output)'{-o+,--output=3D}'[send trace output to the specified fi= le]:output file:->file-pipe' \ + '(-A --output-append-mode)'{-A,--output-append-mode}'[open the file pro= vided with the -o option in append mode]' \ + '--output-separately[output to separate files for child processes (by a= ppending pid to file names)]' \ + '(--quiet)-q[suppress messages about attaching, detaching etc]' \ + '(-q --quiet)-qq[suppress messages about process exit status]' \ + '(-q -qq --quiet)-qqq[suppress all suppressible messages]' \ + '(-q -qq -qqq)--quiet=3D[suppress messages about attaching, detaching e= tc]:suppression:_sequence compadd - attach personality exit all' \ + '(--relative-timestamps -c --summary-only)-r[print a relative timestamp= upon entry to each system call]' \ + '(-r -c --summary-only)--relative-timestamps=3D-[print a relative times= tamp upon entry to each system call]:precision [us]:compadd -o nosort s ms= us ns' \ + '(--absolute-timestamps)-t[prefix each line of the trace with the wall = clock time]' \ + '(-t)--absolute-timestamps=3D-[prefix each line of the trace with the w= all clock time]:: :->time-formats' \ + '!(-t --absolute-timestamps)--timestamps=3D-:: :->time-formats' \ + '(-s --string-limit)'{-s+,--string-limit=3D}'[specify the maximum strin= g size to print]:maximum string size [32]' \ + '(-c --summary-only -ttt)-t[prefix each line of the trace with the time= of day]' \ + '(-c --summary-only -ttt -tt)-tt[prefix each line of the trace with the= time of day including the microseconds]' \ + '(-c --summary-only -tt -t)-ttt[prefix each line of the trace with the = number of seconds and microseconds since the epoch]' \ + '(--syscall-times -c --summary-only)-T[show the time spent in system ca= lls]' \ + '(-T -c --summary-only)--syscall-times=3D-[show the time spent in syste= m calls]::precision [us]:compadd -o nosort s ms us ns' \ + '(-v --no-abbrev)'{-v,--no-abbrev}'[print unabbreviated versions of env= ironment, stat, termios, etc. calls]' \ + '(-xx --strings-in-hex)-x[print all non-ASCII strings in hexadecimal st= ring format]' \ + '(-x --strings-in-hex)-xx[print all strings in hexadecimal string forma= t]' \ + '(-x -xx)--strings-in-hex=3D[specify strings to print in hexadecimal fo= rmat]:string type:(all non-ascii)' \ + '(-X --const-print-style)'{-X+,--const-print-style=3D}'[set the format = for printing of named constants and flags]:format:(raw abbrev verbose)' \ + '(-c --summary-only -yy --decode-fds)-y[print paths associated with fil= e descriptor arguments]' \ + '(-c --summary-only -y --decode-fds)-yy[print protocol specific informa= tion associated with socket file descriptors]' \ + '(-c --summary-only -y -yy)--decode-fds=3D-[print information associate= d with file descriptors]::information [none]:_sequence compadd - none all = path socket dev pidfd' \ + '(-c --summary-only -C --summary -i --instruction-pointer -k --stack-tr= aces -r --relative-timestamps -ff -t -tt -ttt --absolute-timestamps -T --s= yscall-times -y -yy --decode-fds)'{-c,--summary-only}'[count time, calls, = and errors for each system call and report a summary]' \ + '(-c --summary-only -C --summary)'{-C,--summary}'[count time, calls, an= d errors for each system call and report a summary in addition to regular = output]' \ + '(-O --summary-syscall-overhead)'{-O+,--summary-syscall-overhead=3D}'[s= pecify overhead for tracing system calls]:overhead (microseconds)' \ + '(-S --summary-sort-by)'{-S+,--summary-sort-by=3D}'[sort the output of = the histogram (-c option) by the specified criterion]:sort criterion [time= ]:(time min-time max-time avg-time calls errors name nothing)' \ + '(-U --summary-columns)'{-U+,--summary-columns=3D}'[show specific colum= ns in the summary report]:column:_sequence compadd - time-percent total-ti= me min-time max-time avg-time calls errors name' \ + '(-w --summary-wall-clock)'{-w,--summary-wall-clock}'[summarise syscall= latency]' \ + '(-c --summary-only -C)-ff[write each process trace to .= (when using -o ]' \ + '(-d --debug)'{-d,--debug}'[show debug output of strace itself on stand= ard error]' \ + '(- 1 *)'{-h,--help}'[display help information]' \ '--seccomp-bpf[enable seccomp-bpf filtering]' \ - '-d[show debug output of strace itself on standard error]' \ - '-v[print unabbreviated versions of environment, stat, termios, etc. ca= lls]' \ - '(- 1 *)-h[display help information]' \ - '(- 1 *)-V[display version information]' \ - '(-c)-k[obtain stack trace between each syscall]' \ + '(- 1 *)'{-V,--version}'[display version information]' \ '(-):command name: _command_names -e' \ '*::arguments:_normal' && ret=3D0 = @@ -61,7 +77,9 @@ case $state in 'fault[perform syscall fault injection]:system call:_sys_calls -a -= n' \ 'inject[perform syscall tampering]:system call:_sys_calls -a -n' \ 'status[trace system calls with given return status]:status:->statu= s' \ - 'kvm[print the exit reason of kvm vcpu]: :(vcpu)' && ret=3D0 + 'quiet[suppress various information messages]:message [none]:_seque= nce compadd - none attach exit path-resolution personality thread-execve s= uperseded' \ + 'kvm[print the exit reason of kvm vcpu]: :(vcpu)' \ + 'decode-fds[print information associated with file descriptors]:inf= ormation [none]:_sequence compadd - none all path socket dev pidfd' && ret= =3D0 if [[ $state =3D status ]]; then _values -s , 'return status [all]' \ all successful failed \ @@ -69,15 +87,17 @@ case $state in 'unavailable[system calls that return but strace fails to fetch t= he error]' \ 'detached[system calls where strace detaches before the return]' = && ret=3D0 elif [[ $words[CURRENT] !=3D *=3D* || $state =3D syscalls ]]; then - local dedup sets suf=3D"-qS," + local dedup sets compset -P '!' dedup=3D( ${(Ms.,.)PREFIX##*,} ${(Ms.,.)SUFFIX%%,*} ) - compset -S ',*' || suf=3D"" + compset -S ',*' || suf=3D( "-qS," ) compset -P '*,' if compset -P /; then _wanted syscalls expl "system call (regex)" _sys_calls -a -n $suf= -F dedup && ret=3D0 else sets=3D( + '%clock:trace system calls that read or modify system clocks' + '%creds:trace system calls that read or modify user and group i= dentifiers or capability sets' {%,}'file:trace all system calls which take a file name as an a= rgument' {%,}'process:trace all system calls which involve process manag= ement' {%net,{%,}network}':trace all the network related system calls' @@ -122,6 +142,22 @@ case $state in _parameters -qS=3D -g "*export*" && ret=3D0 fi ;; + time-formats) + alts=3D() + compset -P '(precision:*|s|ms|us|ns),' && prec=3D0 + compset -P '(format:*|none|time|unix),' && form=3D0 + compset -S ',*' || (( !prec + !form )) || suf=3D( -S , ) + if compset -P 'precision:'; then + form=3D0 + elif compset -P 'format:'; then + prec=3D0 + else + alts=3D( 'prefixes:prefix:compadd -S ":" ${${(s. .):-format x}[form= ]} ${${(s. .):-precision x}[prec]}' ) + fi + (( prec )) && alts+=3D( 'precisions:precision [s]:compadd -o nosort $= suf s ms us ns' ) + (( form )) && alts+=3D( 'formats:format [time]:compadd $suf none time= unix' ) + _alternative $alts && ret=3D0 + ;; esac = return ret