|
9 | 9 |
|
10 | 10 | source lib/lib.sh |
11 | 11 |
|
| 12 | +arg_tool=massif |
| 13 | + |
| 14 | +for arg in "$@" |
| 15 | +do |
| 16 | + if [ "$arg" == "--help" ] || [ "$arg" == "-h" ] |
| 17 | + then |
| 18 | + echo "usage: ./valgrind.sh [OPTION]" |
| 19 | + echo "options:" |
| 20 | + echo " --tool=massif use valgrinds massif tool" |
| 21 | + echo " --tool=memcheck use valgrinds memcheck tool" |
| 22 | + echo " default tool: $arg_tool" |
| 23 | + exit 0 |
| 24 | + elif [ "${arg::2}" == "--" ] |
| 25 | + then |
| 26 | + if [[ "$arg" == "--tool="* ]] |
| 27 | + then |
| 28 | + arg_tool="$(printf '%s' "$arg" | cut -d= -f2-)" |
| 29 | + if [ "$arg_tool" = massif ] |
| 30 | + then |
| 31 | + true |
| 32 | + elif [ "$arg_tool" = memcheck ] |
| 33 | + then |
| 34 | + true |
| 35 | + else |
| 36 | + err "Invalid valgrind tool '$arg_tool'" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + else |
| 40 | + err "invalid argument '$arg' see '--help'" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | + else |
| 44 | + err "unexpected argument '$arg' see '--help'" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +done |
| 48 | + |
12 | 49 | check_deps "$1" |
13 | 50 | check_warnings |
14 | 51 | check_running |
|
61 | 98 | log_cmd="logfile $logfile" |
62 | 99 | fi |
63 | 100 |
|
64 | | -valgrind_tool=massif |
65 | 101 | run_cmd=noop |
66 | 102 |
|
67 | | -if [ "$valgrind_tool" = "massif" ] |
| 103 | +if [ "$arg_tool" = "massif" ] |
68 | 104 | then |
69 | 105 | massif_logpath="logs/massif_${COMMIT_HASH:-null}_$(date '+%F_%H-%M').out.txt" |
70 | 106 |
|
|
82 | 118 | --massif-out-file=$massif_logpath \ |
83 | 119 | ./$CFG_BIN -f autoexec.cfg "$log_cmd;#sid:$SERVER_UUID:valgrind.sh" |
84 | 120 | EOF |
85 | | -elif [ "$valgrind_tool" = "memcheck" ] |
| 121 | +elif [ "$arg_tool" = "memcheck" ] |
86 | 122 | then |
87 | 123 | read -rd '' run_cmd <<- EOF |
88 | 124 | $CFG_ENV_RUNTIME valgrind \ |
|
94 | 130 | ./$CFG_BIN -f autoexec.cfg "$log_cmd;#sid:$SERVER_UUID:valgrind.sh" |
95 | 131 | EOF |
96 | 132 | else |
97 | | - err "Error: unsupported valgrind tool '$valgrind_tool'" |
| 133 | + err "Error: unsupported valgrind tool '$arg_tool'" |
| 134 | + exit 1 |
98 | 135 | fi |
99 | 136 |
|
100 | 137 | log "$run_cmd" |
|
107 | 144 | log "applied patches: $git_patches" |
108 | 145 | fi |
109 | 146 |
|
110 | | -if [ "$valgrind_tool" = "massif" ] |
| 147 | +if [ "$arg_tool" = "massif" ] |
111 | 148 | then |
112 | 149 | log "created massif report at $massif_logpath" |
113 | 150 | log "you can inspect it using this command:" |
|
0 commit comments