(Assuming you're using Linux) Use echo $$
to get the PID of your current shell. Open a new terminal, and run:
sudo strace -fp <PID> -o log
Switch back to the old shell, try tab completion. Then switch to the new terminal and press CtrlC to end strace
. The output will be in the file named log
. You could also run the strace
command in the same shell (first authenticating to sudo
for caching credentials):
sudo -v
sudo strace -fp $$ -o log &
And then try tab completion. To kill it, fg
, followed by CtrlC.
However, if you're using bash, it might be better to try getting verbose debug output from it first:
set -o functrace xtrace
PS4=' ${BASH_SOURCE}:$FUNCNAME:$LINENO: '
And then try tab completion. You should everything that the completion function executes in the output that follows. For example:
bash-5.0$ set -o xtrace functrace
bash-5.0$ PS4=' ${BASH_SOURCE}:${FUNCNAME}:$LINENO: '
+ PS4=' ${BASH_SOURCE}:${FUNCNAME}:$LINENO: '
bash-5.0$ sudo su /usr/local/share/bash-completion/bash_completion:_completion_loader:3: local cmd=sudo
/usr/local/share/bash-completion/bash_completion:_completion_loader:5: __load_completion sudo
/usr/local/share/bash-completion/bash_completion:__load_completion:2: dirs=(${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions)
/usr/local/share/bash-completion/bash_completion:__load_completion:2: local -a dirs
/usr/local/share/bash-completion/bash_completion:__load_completion:3: local 'OIFS=
' IFS=: dir cmd=sudo compfile
/usr/local/share/bash-completion/bash_completion:__load_completion:2021: for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
/usr/local/share/bash-completion/bash_completion:__load_completion:5: dirs+=($dir/bash-completion/completions)
/usr/local/share/bash-completion/bash_completion:__load_completion:2021: for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
/usr/local/share/bash-completion/bash_completion:__load_completion:5: dirs+=($dir/bash-completion/completions)
/usr/local/share/bash-completion/bash_completion:__load_completion:7: IFS='
'
/usr/local/share/bash-completion/bash_completion:__load_completion:9: [[ /usr/local/share/bash-completion/bash_completion == */* ]]