4 ms·
Zig apparently has valgrind support. Maybe it’s not turned on by default?
by skybrian 5y ago
Zig apparently has valgrind support. Maybe it’s not turned on by default?
- staticassertion 5y agoValgrind support is cool but it's not a solution to the problem.
- formerly_proven 5y agoI don't think Zig has any particular Valgrind support, it's just a binary after all. In order to properly utilize valgrind though you're going to have to change from the GPA or whatever allocator you're using to the libc one so that Valgrind can trace memory allocations correctly via preloading.
- skybrian 5y agoHere is some kind of valgrind API [1] and a here is a report from someone who tried using valgrind [2]. Yes, it doesn’t sound all that special. [1] https://github.com/ziglang/zig/blob/master/lib/std/valgrind.zig https://github.com/ziglang/zig/blob/master/lib/std/valgrind.... [2] https://dev.to/stein/some-notes-on-using-valgrind-with-zig-35c1 https://dev.to/stein/some-notes-on-using-valgrind-with-zig-3...
- AndyKelley 5y agoA better way to put it is "valgrind integration". It is enabled by default (when compiling for a target that has Valgrind support). Mainly it integrates with the `undefined` language feature which helps catch branching on undefined values. The nice thing you get beyond what C gives you, is that in Zig you can set things to undefined when you are done with them. Meanwhile in C, Valgrind is only aware of undefined for uninitialized variables. But as others have pointed out, although Valgrind is a nice debugging tool, you would not run your application in it under normal circumstances. It's also not available on some important targets, such as macOS and Windows.