2013-01-30 10:22:22 +00:00
# Don't go invoking valgrind unless it is installed
set -l skin tool
2020-05-18 18:10:03 +00:00
if valgrind --version 2 > /dev/null | string match -qr -- '-2\.[012]\.'
2019-05-05 10:53:09 +00:00
# In older versions of Valgrind, the skin selection option was
2005-09-20 13:31:55 +00:00
# '--skin'
2019-05-05 10:53:09 +00:00
# But someone decided that it would be fun to change this to
2005-09-20 13:31:55 +00:00
# '--tool' for no good reason
2019-05-05 10:53:09 +00:00
set skin skin
2005-09-20 13:31:55 +00:00
end
2020-03-09 18:36:12 +00:00
complete -xc valgrind -l $skin -d Skin -a "
2005-09-20 13:31:55 +00:00
memcheck\t Heavyweight\ memory\ checker
cachegrind\t Cache-miss\ profiler
addrcheck\t Lightweight\ memory\ checker
helgrind\t Data-race\ detector
massif\t Heap\ profiler
"
2005-10-15 17:09:14 +00:00
2020-09-19 09:39:51 +00:00
function __fish_valgrind_skin --argument-names tool -V skin
2024-01-22 06:42:45 +00:00
set -l cmd ( commandline -cpx )
2019-05-05 10:53:09 +00:00
# Quote $cmd so the tokens are separated with a space
if string match -qr -- " -- $skin (=| ) $tool " " $cmd "
return 0
2012-06-16 00:30:10 +00:00
end
2019-05-05 10:53:09 +00:00
# memcheck is the default tool/skin
test $tool = memcheck
and not string match -- $skin $cmd
2012-06-16 00:30:10 +00:00
end
2005-09-20 13:31:55 +00:00
2017-10-11 17:17:35 +00:00
complete -c valgrind -l help -d "Display help and exit"
complete -c valgrind -l help -debug -d "Display help and debug options"
complete -c valgrind -l version -d "Display version and exit"
complete -c valgrind -s q -l quiet -d "Quiet mode"
complete -c valgrind -s v -l verbose -d "Verbose mode"
complete -xc valgrind -l trace-children -d "Valgrind-ise children" -a "yes no"
complete -xc valgrind -l track-fds -d "Track file descriptors" -a "yes no"
2019-02-22 19:03:53 +00:00
complete -xc valgrind -l log-fd -d "Log to file descriptor" -a "0 1 2 3 4 5 6 7 8 9"
complete -rc valgrind -l log-file -d "Log to file"
2017-10-11 17:17:35 +00:00
complete -xc valgrind -l logsocket -d "Log to socket"
2005-09-20 13:31:55 +00:00
complete -c valgrind -l demangle -xd "Demangle C++ names" -a "yes no"
2017-10-11 17:17:35 +00:00
complete -xc valgrind -l num-callers -d "Callers in stack trace"
complete -xc valgrind -l error-limit -d "Stop showing errors if too many" -a "yes no"
complete -xc valgrind -l show-below-main -d "Continue trace below main()" -a "yes no"
2019-11-25 11:03:25 +00:00
complete -rc valgrind -l suppressions -d "Suppress errors from file"
2017-10-11 17:17:35 +00:00
complete -c valgrind -l gen-suppressions -d "Print suppressions for detected errors"
complete -xc valgrind -l db-attach -d "Start debugger on error" -a "yes no"
complete -rc valgrind -l db-command -d "Debugger command"
complete -xc valgrind -l input-fd -d "File descriptor for input" -a "0 1 2 3 4 5 6 7 8 9"
2005-09-20 13:31:55 +00:00
# Memcheck-specific options
2017-10-11 17:17:35 +00:00
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l leak-check -d "Check for memory leaks" -a "no\tDon\'t\ check\ for\ memory\ leaks summary\t'Show a leak summary' full\t'Describe memory leaks in detail'"
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l show-reachable -d "Show reachable leaked memory" -a "yes\t'Show reachable leaked memory' no\t'Do not show reachable leaked memory'"
2020-12-14 18:01:04 +00:00
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l leak-resolution -d "Determines how willingly Memcheck considers different backtraces to be the same" -a "low\t'Two entries need to match' med\t'Four entries need to match' high\t'All entries need to match'"
2017-10-11 17:17:35 +00:00
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l freelist-vol -d "Set size of freed memory pool"
2005-10-15 17:09:14 +00:00
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l partial-loads-ok -d 'How to handle loads of words that are partially addressible' -a 'yes\t"Do not emit errors on partial loads" no\t"Emit errors on partial loads"'
complete -n "__fish_valgrind_skin memcheck" -xc valgrind -l avoid-strlen-errors -d 'Whether to skip error reporting for the strlen function' -a 'yes no'
2005-09-20 13:31:55 +00:00
# Addrcheck-specific options
2017-10-11 17:17:35 +00:00
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l leak-check -d "Check for memory leaks" -a "no\t'Do not check for memory leaks' summary\t'Show a leak summary' full\t'Describe memory leaks in detail'"
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l show-reachable -d "Show reachable leaked memory" -a "yes\t'Show reachable leaked memory' no\t'Do not show reachable leaked memory'"
2020-12-14 18:01:04 +00:00
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l leak-resolution -d "Determines how willingly Addrcheck considers different backtraces to be the same" -a "low\t'Two entries need to match' med\t'Four entries need to match' high\t'All entries need to match'"
2017-10-11 17:17:35 +00:00
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l freelist-vol -d "Set size of freed memory pool"
2005-10-15 17:09:14 +00:00
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l partial-loads-ok -d 'How to handle loads of words that are partially addressible' -a 'yes\t"Do not emit errors on partial loads" no\t"Emit errors on partial loads"'
complete -n "__fish_valgrind_skin addrcheck" -xc valgrind -l avoid-strlen-errors -d 'Whether to skip error reporting for the strlen function' -a 'yes no'
2005-09-20 13:31:55 +00:00
# Cachegrind-specific options
2017-10-11 17:17:35 +00:00
complete -n "__fish_valgrind_skin cachegrind" -xc valgrind -l I1 -d "Type of L1 instruction cache"
complete -n "__fish_valgrind_skin cachegrind" -xc valgrind -l D1 -d "Type of L1 data cache"
complete -n "__fish_valgrind_skin cachegrind" -xc valgrind -l L2 -d "Type of L2 cache"
2005-09-20 13:31:55 +00:00
2019-12-03 10:12:12 +00:00
function __fish_print_function_prototypes -d "Prints the names of all function prototypes found in the headers in the current directory"
set -l headers *.h *.hh *.hpp *.hxx
if set -q headers [ 1 ]
sed -n "s/^\(.*[^[a-zA-Z_0-9]\|\)\([a-zA-Z_][a-zA-Z_0-9]*\) *(.*);.*\$/\2/p" $headers
end
end
2005-09-20 13:31:55 +00:00
# Massif-specific options
2017-10-11 17:17:35 +00:00
complete -c valgrind -n "__fish_valgrind_skin massif" -l alloc-fn -d "Specify a function that allocates memory" -x -a "(__fish_print_function_prototypes)"
2005-10-15 17:09:14 +00:00
complete -c valgrind -n "__fish_valgrind_skin massif" -x -l heap -d 'Profile heap usage' -a 'yes\t"Profile heap usage" no\t"Do not profile heap usage"'
2017-10-11 17:17:35 +00:00
complete -c valgrind -n "__fish_valgrind_skin massif" -x -l heap-admin -d "The number of bytes of heap overhead per allocation"
complete -c valgrind -n "__fish_valgrind_skin massif" -x -l stacks -d "Profile stack usage" -a 'yes\t"Profile stack usage" no\t"Do not profile stack usage"'
complete -c valgrind -n "__fish_valgrind_skin massif" -x -l depth -d "Depth of call chain"
complete -c valgrind -n "__fish_valgrind_skin massif" -x -l format -d "Profiling output format" -a "html\t'Produce html output' text\t'Produce text output'"