Debian Codegraph @

extras/zsh-completion/_lttng-sessiond

raw
1 #compdef lttng-sessiond
2 #
3 # SPDX-FileCopyrightText: 2015-2025 Philippe Proulx <[email protected]>
4 # SPDX-License-Identifier: MIT
5 #
6 # This is a Zsh completion function for the lttng-sessiond(1) command
7 # (see <https://lttng.org/>), for versions 2.5 to 2.15.
8 #
9 # If you want, at your own risk, the function to work with versions
10 # above 2.15, set `LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT=1`.
11
12 # Sets the `minor_version` parameter to the minor version of
13 # LTTng-tools, or to `0` if not found.
14 __lttng_set_minor_version() {
15 minor_version=0
16
17 local -a match
18
19 if [[ $($words[1] --version) =~ '2\.([[:digit:]]+)' ]]; then
20 minor_version=$match[1]
21 fi
22 }
23
24 # Adds completions for an LTTng kernel probe name.
25 __lttng_complete_probe_modules() {
26 # Find relevant kernel module files
27 local dir="/usr/lib/modules/$(uname -r)/extra"
28
29 if [[ ! -d $dir ]]; then
30 dir="/usr/lib/modules/$(uname -r)/updates"
31
32 if [[ ! -d $dir ]]; then
33 _message "cannot find directory \"$dir\""
34 return 1
35 fi
36 fi
37
38 local probe_files=("$dir"/**/lttng-probe-*.(ko|ko.gz|ko.zst)(:t))
39
40 if (($#probe_files == 0)); then
41 _message "no probe modules found in \"$dir\""
42 return 1
43 fi
44
45 # Strip prefix and extension
46 probe_files=(${probe_files#lttng-probe-})
47 probe_files=(${probe_files%.gz})
48 probe_files=(${probe_files%.zst})
49 probe_files=(${probe_files%.ko})
50
51 # Add completions
52 compadd "$@" -a - probe_files
53 }
54
55 # Adds completions for the arguments of the `lttng-sessiond` command.
56 __lttng_complete_lttng_sessiond() {
57 local curcontext=$curcontext state state_descr line
58 local -A opt_args
59
60 # LTTng-tools 2.5+
61 local specs=(
62 '(-q --quiet)*'{-v,--verbose}'[increase verbosity]'
63 '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress all messages, including warnings and errors]'
64 '(- : *)'{-V,--version}'[show version and quit]'
65 '(- : *)'{-h,--help}'[show help]'
66 '(-c --client-sock)'{-c+,--client-sock=}'[set the path to the client Unix socket]:client Unix socket path:_files'
67 '(-a --apps-sock)'{-a+,--apps-sock=}'[set the path to the app Unix socket]:app Unix socket path:_files'
68 '--kconsumerd-err-sock=[set the path to the kernel consumer daemon error socket]:kernel consumer daemon error Unix socket path:_files'
69 '--kconsumerd-cmd-sock=[set the path to the kernel consumer daemon command socket]:kernel consumer daemon command Unix socket path:_files'
70 '--ustconsumerd32-err-sock=[set the path to the 32-bit UST consumer daemon error Unix socket]:32-bit UST consumer daemon error Unix socket path:_files'
71 '--ustconsumerd32-cmd-sock=[set the path to the 32-bit UST consumer daemon command Unix socket]:32-bit UST consumer daemon command Unix socket path:_files'
72 '--ustconsumerd64-err-sock=[set the path to the 64-bit UST consumer daemon error Unix socket]:64-bit UST consumer daemon error Unix socket path:_files'
73 '--ustconsumerd64-cmd-sock=[set the path to the 64-bit UST consumer daemon command Unix socket]:64-bit UST consumer daemon command Unix socket path:_files'
74 '--consumerd32-path=[set the path to the 32-bit UST consumer daemon]:32-bit UST consumer daemon path:_files'
75 '--consumerd32-libdir=[set the path to the directory containing 32-bit UST consumer daemon libraries]:32-bit UST consumer daemon libraries directory path:_directories'
76 '--consumerd64-path=[set the path to the 64-bit UST consumer daemon]:64-bit UST consumer daemon path:_files'
77 '--consumerd64-libdir=[set the path to the directory containing 64-bit UST consumer daemon libraries]:64-bit UST consumer daemon libraries directory path:_directories'
78 '(-d --daemonize -b --background)'{-d,--daemonize}'[start as daemon and close file descriptors (console)]'
79 '(-b --background -d --daemonize)'{-b,--background}'[start as daemon, but keep file descriptors (console) open]'
80 '(-g --group)'{-g+,--group=}'[set the Unix tracing group name]:Unix tracing group name:_groups'
81 '(-S --sig-parent)'{-S,--sig-parent}'[send the USR1 signal to the parent process to notify readiness]'
82 '(-p --pidfile)'{-p+,--pidfile=}'[set the path to the PID file]:PID file path:_files'
83 "--verbose-consumer[increase verbosity of consumer daemon]"
84 '(--kmod-probes --extra-kmod-probes)--no-kernel[disable the kernel tracer]'
85 '(-f --config)'{-f+,--config=}'[set the path to the INI daemon configuration file]:configuration file path:_files'
86 '(-l --load)'{-l+,--load=}'[set the path from which to load recording session configurations]:recording session configurations path:_files'
87 '(--no-kernel --kmod-probes)--extra-kmod-probes=[extra kernel probe modules to load]:kernel probe module:_sequence __lttng_complete_probe_modules'
88 )
89
90 # LTTng-tools 2.5 only
91 if ((minor_version == 5)); then
92 specs+=(
93 '--jul-tcp-port=[set the TCP port on which to listen for `java.util.logging` application registration]:JUL application registration TCP port: '
94 )
95 fi
96
97 # LTTng-tools 2.6+
98 if ((minor_version >= 6)); then
99 specs+=(
100 '--agent-tcp-port=[set the TCP port on which to listen for agent application registration]:agent application registration TCP port: '
101 '(--no-kernel --extra-kmod-probes)--kmod-probes=[kernel probe modules to load]:kernel probe module:_sequence __lttng_complete_probe_modules'
102 )
103 fi
104
105 # LTTng-tools 2.13+
106 if ((minor_version >= 13)); then
107 specs+=(
108 '--event-notifier-error-buffer-size-kernel=[set the size of the kernel event notifier error counter buffers]:kernel event notifier error counter buffer size (slots): '
109 '--event-notifier-error-buffer-size-userspace=[set the size of the user space event notifier error counter buffers]:user space event notifier error counter buffer size (slots): '
110 )
111 fi
112
113 # LTTng-tools 2.15+
114 if ((minor_version >= 15)); then
115 specs+=(
116 '--default-trace-format=[set the default trace format of recording sessions]:trace format:(ctf-1.8 ctf-2)'
117 )
118 fi
119
120 _arguments -s -w : $specs
121 }
122
123 # Ensure predictable Zsh behavior and prevent option leakage
124 emulate -L zsh
125 setopt extended_glob
126
127 # First, set the `minor_version` parameter to the minor version of
128 # LTTng-tools. Some features depend on a specific version and this
129 # completion function supports many versions from LTTng-tools 2.5.
130 local -i minor_version
131
132 __lttng_set_minor_version
133
134 # Exit now with LTTng-tools < 2.5 or LTTng-tools > 2.15
135 local -r ignore_version_limit=${LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT:-0}
136
137 if ((minor_version < 5 || (minor_version > 15 && !ignore_version_limit))); then
138 _message "completion not available for LTTng-tools 2.$minor_version; please update the completion files or set \`LTTNG_ZSH_COMP_IGNORE_VERSION_LIMIT=1\`"
139 return 1
140 fi
141
142 # Add completions for lttng-sessiond(1)
143 __lttng_complete_lttng_sessiond "$@"