Commit Graph

20 Commits

Author SHA1 Message Date
dc99b46254 libsysprof-capture: fix leak of mapped ring buffer structure 2023-05-12 14:02:46 -07:00
57183ab8e2 macros: add static assert helper
So that we can use this from gnu99 such as from GTK.
2020-07-04 16:11:31 -07:00
607af73676 libsysprof-capture: Stop defining G_LOG_DOMAIN
libsysprof-capture no longer calls any of the GLib logging functions
which make use of it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
1d865c5c8e libsysprof-capture: Use sysprof_{steal,clear}_pointer() instead of GLib
They work exactly the same way as the GLib functions.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
b0a5c4f700 libsysprof-capture: Use malloc() rather than g_new0() and friends
Another step away from GLib. This changes the OOM behaviour of the
library — previously it would immediately `abort()` on OOM. However, it
seems likely that given the small number of allocations
libsysprof-capture does, it should be able to recover from an OOM
situation more gracefully than larger libraries can — so the new
implementation tries to do that.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
951b46fddf libsysprof-capture: Use intrinsic atomics rather than g_atomic_*()
Use the intrinsic atomics provided by the compiler, instead of GLib’s
wrapper around them. This should work for all modern compilers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
b6fb272865 libsysprof-capture: Use fprintf() instead of g_printerr()
This removes one more dependency on GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
8e28ac6e81 libsysprof-capture: Use assert() instead of g_assert()
Also use it instead of `g_return_if_fail()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
5636bbf4f0 libsysprof-capture: Use stdbool instead of gboolean
Another step towards dropping GLib as a dependency of
libsysprof-capture.

Unlike the previous commit which replaced GLib integer types with the
bitwise equivalent C standard types, `stdbool` is potentially a different
width from `gboolean`, so this is an ABI break.

It therefore involves some changes to callback functions in the tests
and tools, and in libsysprof.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
2c2cbf6343 libsysprof-capture: Use C11 types instead of GLib types
This is an almost entirely mechanical* conversion from (for example)
`gint` → `int`, `guint8` → `uint8_t`, etc.

It is not entirely complete, as many GLib functions are still used in
libsysprof-capture, which necessitate some use of GLib types.

It also avoids renaming `gboolean` → `bool` as that’s a slightly more
controversial change which will happen in the following commit.

*Code was manually realigned afterwards.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
b449baa205 libsysprof-capture: Move MappedRingBufferSource to libsysprof
As preparation for dropping the GLib dependency from libsysprof-capture,
move the `GSource` which links a `MappedRingBuffer` to a `GMainContext`
from libsysprof-capture to libsysprof.

This requires adding one new piece of API to libsysprof-capture to check
whether the `MappedRingBuffer` is empty.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
be6b979714 libsysprof-capture: remove use of GAtomicRCBox
If we backport to an older GLib release, we won't have the newer atomic
helpers available. It's really not too much burden to do that manually if
it means we can run on older systems.
2020-02-20 10:39:33 -08:00
cd8a99402f build: fallback to __sync_synchronize()
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.
2020-02-20 10:38:35 -08:00
53a351b66e libsysprof-capture: add clear/reset API for mapped ring buffer 2020-02-16 17:57:06 -07:00
69e4fb2588 libsysprof-capture: allow using ring in readwrite mode
This is a first step to be able to use the ring buffer as the backing
buffer for the SysprofCaptureWriter.
2020-02-15 22:50:22 -07:00
36860b449e libsysprof-capture: unref GSource after attaching 2020-02-15 22:27:34 -07:00
c74c02a2d9 libsysprof-capture: update ring position while walking
This ensures that the producer can produce as soon as the reader has moved
past that data. Now that the callback has a mutable consumption value, they
can read the whole data in one shot anyway.
2020-02-15 21:55:08 -07:00
c0697c91cc libsysprof-capture: increase rate of buffer read
This ideally should be dynamic in the future to copy out data at a rate
that keeps us around 33% usage rate so that we can still burst if we need
to but keep things empty enough to not loose data.
2020-02-15 21:53:34 -07:00
e3ed30eb48 libsysprof-capture: remove framing data from MappedRingBuffer
This removes the 8 bytes of framing data from the MappedRingBuffer which
means we can write more data without racing. But also this means that we
can eventually use the mapped ring buffer as our normal buffer for
capture writing (to be done later).
2020-02-15 20:46:05 -07:00
77400c57c1 libsysprof-capture: add mmap()'d ring buffer
This is the start of a ring buffer to coordinate between processes without
the overhead of writing directly to files within the inferior process.
Instead, the parent process can monitor the ring buffer for framing
information and pass that along to the capture writer.
2020-02-13 18:50:20 -08:00