Rather than defining them piecemeal in each C and H file, and having
problems with headers being included in different orders so that
`_POSIX_C_SOURCE` gets a value which is too low, just define the feature
test flags in `meson.build`.
See `man 7 feature_test_macros`.
This is useful for when building sysprof as a subproject beneath a
project which doesn’t define these macros, or which targets an older C
standard than `gnu11`.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
This avoids making the project depend on all its dependencies, some of
which are optional, when being built as a Meson subproject.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
If the system doesn’t provide `strlcpy()` (FreeBSD does, Linux doesn’t),
use an inbuilt copy instead.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
When building on older systems such as RHEL 7, it can be convenient
to have access to libdazzle directly.
This also has to work around a problem that RHEL 7 does not support
the version of git that Meson requires for [wrap-git] by using a
specific release.
If we're running on a GCC older than 4.9, then we won't have the
stdatomic.h available. We can just use a full barrier instead using
__sync_synchronize() to get the same effect, albeit slower.
This brings over some of the techniques from the old memprof design.
Sysprof and memprof shared a lot of code, so it is pretty natural to
bring back the same callgraph view based on memory allocations.
This reuses the StackStash just like it did in memprof. While it
would be nice to reuse some existing tools out there, the fit of
memprof with sysprof is so naturally aligned, it's not really a
big deal to bring back the LD_PRELOAD. The value really comes
from seeing all this stuff together instead of multiple apps.
There are plenty of things we can implement on top of this that
we are not doing yet such as temporary allocations, cross-thread
frees, graphing the heap, and graphing differences between the
heap at to points in time. I'd like all of these things, given
enough time to make them useful.
This is still a bit slow though due to the global lock we take
to access the writer. To improve the speed here we need to get
rid of that lock and head towards a design that allows a thread
to request a new writer from Sysprof and save it in TLS (to be
destroyed when the thread exits).
GLib is already doing this, which broke a number of auto-generated code.
This tracks those changes and manually sets the annotations so that we
are guaranteed to get this behavior.
We'll need to fix other uses (such as in Mutter), but we have to do that
already because of the change in GLib.
Fixes#17
We want the viewer to be usable on Mac/Windows/FreeBSD, even if our
profiler tooling isn't (yet).
Another option could be to do a simplified viewer window for those
platforms, but I think that is more work to maintain than abstracting
some of the stuff better in libsysprof.