-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider using findshlibs to find mappings #15
Comments
Ah nice. I was halfway through implementing the windows version, but using findshlibs would definitely be a lot easier, along with providing a macOS implementation for free (which I'm also interested in, incidentally ^^) |
There is another issue with findshlibs which is that it iterates the macOS libraries in a way that is explicitly documented to be thread-unsafe: calling So I'm leaning towards just using our own implementations. I'm working now on a macOS version; I don't think it should be too difficult ... |
I take that back. Writing it by hand seems also problematic because although there is the So maybe we should just use findshlibs (or something like it) and just document that on macOS it's undefined behavior if you are loading or unloading dylibs while setting up this library. But that's also a bit unsatisfying. |
aha, it seems there is a way to get the image name even when using |
I made a commit that replaces As you can see, there are some subtle differences between windows, macos and linux.
Also, somewhat annoyingly, upstream pprof doesn't handle With all of these (and some patches to jemalloc to add windows support), I get something that provides correct backtraces on windows, macos and Linux, at least for my use-cases. I don't provide the file_offset, as you've identified. This doesn't seem to impact anything, I'm not entirely sure what it's used for. I suspect it may be needed in programs that have multiple text segment, or when the text segment is not the first segment of the binary? |
There is a crate findshlibs which does 99% the same thing as our machinery for getting the list of shared objects on Linux, except that it has cross-platform support.
This can be an avenue for quickly spinning up macOS/Windows support. However, we might need to fix a few things about this library before using it (and thus possibly depend on a fork, rather than on the upstream gimli-rs repo, until they are willing to merge our changes).
0
for the file offset of a mappingwrapping_add
gimli-rs/findshlibs#81 as this will cause panics in debug mode on certain versions of Linux otherwise (see the comment here).u64
can be cast tousize
, see e.g. here . We need to either carefully audit every case of this and ensure that it is valid even on 32-bit platforms, or (my preference) banas
from the codebase and use properly checked conversions.Alternatively, we can decide not to use this library, and just write the Windows/macOS support by hand, as we already did for Linux.
Tagging @roblabla who has expressed interest in working on Windows support.
The text was updated successfully, but these errors were encountered: