Hacker News new | ask | show | jobs
by whimsicalism 1427 days ago
It's unfortunate that so many of these great tools (like `perf` and I believe `valgrind`) are basically not available locally on the Mac.

And running in a container is not really a solution for most of these.

2 comments

Sanitizers and electric fence are ultra portable, they're definitely available on macos. The feature set from valgrind is a bit richer but not by much.
Valgrind does a lot of low level trickery so it hasn’t always supported the latest macOS releases straight away (or sometimes would support them with serious gotchas/limitations)
I am not familiar with electric fence but I remember from my experience that there are definitely important things that I got from `perf` and `valgrind` that the alternative sanitizers did not provide. Can't recall what now of course.
asan/ubsan do not detect uninitialized memory reads (though ubsan can detect when bools take on invalid bit patterns from uninitialized memory), and msan requires rebuilding the standard library or something, so I've never used msan. Valgrind is slow, but detects uninitialized memory reads properly, and doesn't require rebuilding the app (which is useful when running a complex or prebuilt app for short periods of time).

On the topic of profiling, callgrind can count exact function calls and generate accurate call graphs, which I find useful for not only profiling, but tracing the execution of unfamiliary code. I just wish rr had similarly fast tooling (pernosco is close enough to be useful, but I think there's value in exploring different workflows than what they picked).

>msan requires rebuilding the standard library or something

Yes, which is a PITA. But even then, macOS is not supported anyway:

https://clang.llvm.org/docs/MemorySanitizer.html#supported-p...

valgrind is available on mac. From the homepage: "It runs on the following platforms: (...) X86/Darwin and AMD64/Darwin (Mac OS X 10.12).". There's a notable omission of ARM64/Darwin in there, and I don't think it's an oversight.

What Mac is definitely lacking, though, is reverse debugging. Linux has rr, Windows has Time Travel Debugging. macOS still doesn't have an equivalent.

Valgrind, as I understand it, was essentially maintained by one engineer at Apple who has since left the company, so nobody has really updated it.
That's my understanding too, and I believe you're referring Greg Parker:

http://www.sealiesoftware.com/valgrind/

He's still at Apple, but he works on the Swift runtime these days rather than C/C++ tooling.
There have been 6 major releases since 10.12 (which was from late 2016). In other words, valgrind has basically stopped supporting macOS.
I don't think it means it doesn't work with newer versions.
I'm afraid you're wrong. It does not work with newer macOS versions, I've tried.