50 lines
1 KiB
Bash
Executable file
50 lines
1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: scripts/valgrind_cdp <run|on|off|open> [path]
|
|
|
|
Commands:
|
|
run [binary] Run a binary under callgrind.
|
|
Default: ./target/release-with-debug/gitcomet
|
|
on Enable callgrind instrumentation.
|
|
off Disable callgrind instrumentation.
|
|
open [outfile] Open a callgrind output file in kcachegrind.
|
|
Default: callgrind.out
|
|
EOF
|
|
}
|
|
|
|
cmd="${1:-run}"
|
|
case "$cmd" in
|
|
run)
|
|
binary="${2:-./target/release-with-debug/gitcomet}"
|
|
valgrind \
|
|
--tool=callgrind \
|
|
--callgrind-out-file=callgrind.out \
|
|
--dump-instr=yes \
|
|
--instr-atstart=no \
|
|
--collect-jumps=yes \
|
|
--sigill-diagnostics=no \
|
|
--error-limit=no \
|
|
"$binary"
|
|
;;
|
|
on)
|
|
callgrind_control -i on
|
|
;;
|
|
off)
|
|
callgrind_control -i off
|
|
;;
|
|
open)
|
|
outfile="${2:-callgrind.out}"
|
|
kcachegrind "$outfile"
|
|
;;
|
|
-h|--help|help)
|
|
usage
|
|
;;
|
|
*)
|
|
echo "Unknown command: $cmd" >&2
|
|
usage >&2
|
|
exit 2
|
|
;;
|
|
esac
|