]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts/kresd-dbg.sh: fix Massif and add Callgrind support
authorOto Šťáva <oto.stava@gmail.com>
Wed, 8 Feb 2023 09:17:12 +0000 (10:17 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Sun, 26 Feb 2023 16:01:22 +0000 (17:01 +0100)
scripts/kresd-dbg.sh

index c8c66dc5621a3293171f303b7d45c8f18407b449..73e72845f274ddc88a1f12e513d24bde7ed8fa62 100755 (executable)
@@ -63,6 +63,11 @@ Available options:
        -h, --help
                Displays this help and exits
 
+       -l, --callgrind [args]
+               Runs kresd under Valgrind Callgrind, optionally with the
+               specified arguments, with default output to
+               'callgrind.out.kresd' in the wrapper script directory
+
        -m, --massif [args]
                Runs kresd under Valgrind Massif, optionally with the specified
                arguments, with default output to 'massif.out.kresd' in
@@ -142,8 +147,8 @@ fi
 ## Process CLI arguments #######################################################
 
 GETOPT=$(getopt \
-       --options     'a::b::cdghm::npr::sx'\
-       --longoptions 'vim-debug::,debug::,clean,no-run,valgrind,help,massif::,no-delete,caps,rr::,sudo,xdp-if:'\
+       --options     'a::b::cdghl::m::npr::sx'\
+       --longoptions 'vim-debug::,debug::,clean,no-run,valgrind,help,callgrind::,massif::,no-delete,caps,rr::,sudo,xdp-if:'\
        --name 'krdbg'\
        -- "$@")
 
@@ -197,6 +202,12 @@ while true; do
                        echo "$help_text"
                        exit 0
                        ;;
+               '-l'|'--callgrind')
+                       callgrind=1
+                       callgrind_args="$2"
+                       shift 2
+                       continue
+                       ;;
                '-m'|'--massif')
                        massif=1
                        massif_args="$2"
@@ -300,8 +311,11 @@ fi
 if [ "$debug" == "1" ]; then
        kr_command="${debugger[@]} $kr_command"
 fi
+if [ "$callgrind" == "1" ]; then
+       kr_command="valgrind --tool=callgrind --callgrind-out-file=\"$script_dir/callgrind.out.kresd\" $callgrind_args -- $kr_command"
+fi
 if [ "$massif" == "1" ]; then
-       kr_command="valgrind --tool=massif --massif-out-file=\"$script_dir/massif.out.kresd $massif_args\" -- $kr_command"
+       kr_command="valgrind --tool=massif --massif-out-file=\"$script_dir/massif.out.kresd\" $massif_args -- $kr_command"
 fi
 if [ "$valgrind" == "1" ]; then
        kr_command="valgrind -- $kr_command"