valgrind: New completion.
This commit is contained in:
parent
43e8e2b504
commit
834379ef63
@ -300,6 +300,7 @@ bashcomp_DATA = a2x \
|
||||
useradd \
|
||||
userdel \
|
||||
usermod \
|
||||
valgrind \
|
||||
vipw \
|
||||
vncviewer \
|
||||
vpnc \
|
||||
|
182
completions/valgrind
Normal file
182
completions/valgrind
Normal file
@ -0,0 +1,182 @@
|
||||
# valgrind(1) completion -*- shell-script -*-
|
||||
|
||||
_valgrind()
|
||||
{
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
local i
|
||||
# Note: intentionally using COMP_WORDS and COMP_CWORD instead of
|
||||
# words and cword here due to splitting on = causing index differences
|
||||
# (_command_offset assumes the former).
|
||||
for (( i=1; i <= COMP_CWORD; i++ )); do
|
||||
if [[ ${COMP_WORDS[i]} != @([-=])* && ${COMP_WORDS[i-1]} != = ]]; then
|
||||
_command_offset $i
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
case $prev in
|
||||
-h|--help|--help-debug|--version|--log-fd|--log-socket|--xml-fd|\
|
||||
--xml-socket|--xml-user-comment|--num-callers|--error-exitcode|\
|
||||
--db-command|--input-fd|--max-strackframe|--main-stacksize|\
|
||||
--alignment)
|
||||
return
|
||||
;;
|
||||
--tool)
|
||||
# Tools seem to be named e.g. like memcheck-amd64-linux from which
|
||||
# we want to grab memcheck; the same dir may contain things like
|
||||
# default.supp, vgpreload_*.so etc which we want to skip.
|
||||
# TODO: probably needs adjustment to be more generic
|
||||
COMPREPLY=( $( compgen -W "$( \
|
||||
command ls -1 /usr{,/local}/lib{,64}/valgrind 2>/dev/null | \
|
||||
sed -e '/\.so$/d' -ne 's/^\(.*\)-\([^-]*\)-\([^-]*\)/\1/p' )" \
|
||||
-- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--trace-children|--child-silent-after-fork|--track-fds|--time-stamp|\
|
||||
--xml|--demangle|--error-limit|--show-below-main|--dsymutil|\
|
||||
--read-var-info|--run-libc-freeres|--show-emwarns)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--log-file|--xml-file|--suppressions|--db-attach)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--gen-suppressions)
|
||||
COMPREPLY=( $( compgen -W 'yes no all' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--smc-check)
|
||||
COMPREPLY=( $( compgen -W 'none stack all' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--sim-hints)
|
||||
COMPREPLY=( $( compgen -W 'lax-ioctls enable-outer' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--kernel-variant)
|
||||
COMPREPLY=( $( compgen -W 'bproc' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
# memcheck:
|
||||
--leak-check)
|
||||
COMPREPLY=( $( compgen -W 'no summary full' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--leak-resolution)
|
||||
COMPREPLY=( $( compgen -W 'low med high' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--show-reachable|--undef-value-errors|--track-origins|\
|
||||
--partial-loads-ok|--workaround-gcc296-bugs)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--freelist-vol|--ignore-ranges|--malloc-fill|--free-fill)
|
||||
return
|
||||
;;
|
||||
# cachegrind:
|
||||
--I1|--D1|--L2)
|
||||
return
|
||||
;;
|
||||
--cache-sim|--branch-sim)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--cachegrind-out-file)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
# callgrind (also --I1, --D1, and --L2 which are above in cachegrind):
|
||||
--simulate-cache|--simulate-wb|--simulate-hwpref|--cacheuse)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
# drd:
|
||||
--trace-addr)
|
||||
return
|
||||
;;
|
||||
--trace-barrier|--trace-cond|--trace-fork-join|--trace-mutex|\
|
||||
--trace-rwlock|--trace-semaphore)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
# exp-bbv:
|
||||
--bb-out-file|--pc-out-file)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--interval-size)
|
||||
return
|
||||
;;
|
||||
--instr-count-only)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
# exp-ptrcheck (also --partial-loads-ok which is above in memcheck):
|
||||
--enable-sg-checks)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
# helgrind:
|
||||
--track-lockorders)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--history-level)
|
||||
COMPREPLY=( $( compgen -W 'none approx full' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--conflict-cache-size)
|
||||
return
|
||||
;;
|
||||
# lackey:
|
||||
--basic-counts|--detailed-counts|--trace-mem|--trace-superblock)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--fnname)
|
||||
return
|
||||
;;
|
||||
# massif:
|
||||
--heap|--stacks)
|
||||
COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--heap-admin|--depth|--alloc-fn|--ignore-fn|--threshold|\
|
||||
--peak-inaccuracy|--detailed-freq|--max-snapshots)
|
||||
return
|
||||
;;
|
||||
--time-unit)
|
||||
COMPREPLY=( $( compgen -W 'i ms B' -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--massif-out-file)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
$split && return
|
||||
|
||||
if [[ $cur == -* ]]; then
|
||||
|
||||
local tool
|
||||
for (( i=1; i < ${#words[@]}; i++ )); do
|
||||
if [[ ${words[i]} == --tool=?* ]]; then
|
||||
tool=${words[i]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
COMPREPLY=( $( compgen -W '$( _parse_help "$1" "--help $tool" )' \
|
||||
-- "$cur" ) )
|
||||
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||
return
|
||||
fi
|
||||
} &&
|
||||
complete -F _valgrind valgrind
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
1
test/completion/valgrind.exp
Normal file
1
test/completion/valgrind.exp
Normal file
@ -0,0 +1 @@
|
||||
assert_source_completions valgrind
|
25
test/lib/completions/valgrind.exp
Normal file
25
test/lib/completions/valgrind.exp
Normal file
@ -0,0 +1,25 @@
|
||||
proc setup {} {
|
||||
save_env
|
||||
}
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
# b: assuming we have at least bash that starts with b in $PATH
|
||||
assert_complete_any "valgrind b"
|
||||
sync_after_int
|
||||
|
||||
assert_complete_any "valgrind -"
|
||||
sync_after_int
|
||||
|
||||
assert_complete_any "valgrind --tool="
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
Loading…
x
Reference in New Issue
Block a user