valgrind.sh 790 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. sh make.sh
  3. # 初始化参数变量
  4. tool_option=""
  5. valgrind_common_options=""
  6. gtest_filter=""
  7. massif=false
  8. # 处理命令行参数
  9. for arg in "$@"
  10. do
  11. case $arg in
  12. --massif)
  13. tool_option="--tool=massif --stacks=yes"
  14. massif=true
  15. shift
  16. ;;
  17. *)
  18. gtest_filter="--gtest_filter=$arg"
  19. shift
  20. ;;
  21. esac
  22. done
  23. # 设置 valgrind 命令的公共参数
  24. if [ "$massif" = true ]; then
  25. valgrind_common_options=""
  26. else
  27. valgrind_common_options="-s --track-origins=yes --leak-check=full --show-leak-kinds=all --exit-on-first-error=yes --error-exitcode=1 --num-callers=50"
  28. fi
  29. # 执行 valgrind 命令
  30. valgrind $tool_option $valgrind_common_options build/test/pikascript_test $gtest_filter