Cannot run valgrind on an installed package

I would like to try and profile zoom-us with valgrind and kcachegrind but when I run valgrind I get the following message:

[nix-shell:~]$ valgrind --trace-children=yes --tool=callgrind zoom-us
==471081== Callgrind, a call-graph generating cache profiler
==471081== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==471081== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==471081== Command: /etc/profiles/per-user/hydrocat/bin/zoom-us
==471081==
==471081== For interactive control, run 'callgrind_control -h'.
==471081== Callgrind, a call-graph generating cache profiler
==471081== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==471081== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==471081== Command: /nix/store/rrixcakkw01rhi5l4z0gcpb9pd03g4rb-zoom-5.14.7.2928/opt/zoom/ZoomLauncher
==471081==
==471081== Error: can not open cache simulation output file `/nix/store/rrixcakkw01rhi5l4z0gcpb9pd03g4rb-zoom-5.14.7.2928/opt/zoom/callgrind.out.471081'

Seems like valgrind is trying to create a file in the nix store.

Apparently, valgrind does not have an option for controlling where the .out is created.

I’ve tried creating a derivation of zoom-us myself as state here : Nixpkgs/Modifying Packages - NixOS Wiki
but the resulting package still points to /nix/store.

I’ve tried running nix-build --store but that option does not exist

I could try and remount /nix/store with write permissions but that doesn’t seem right…

pplz help

Do you run it from a writable directory or the scrip changes the directory underneath you? Maybe --callgrind-out-file can accept an absolute path to help you.

2 Likes

Yeah man ! That was right!

Just as note for the next guy who faces this,

Don’t forget to add a %p to your filename, otherwise, every child process will have a callgraph with the same name and valgrind fails. Here’s an example:

valgrind --tool=callgrind --callgrind-out-file=`pwd`/callgrind.out.%p --trace-children=yes <your-command-here>
1 Like