Commit Graph

873 Commits

Author SHA1 Message Date
691b6ef342 macros: simplify static assert fallback to use __COUNTER__
It is rather annoying that the other sizeof form doesn't work with Clang.
This at least gets things working (assuming you have __COUNTER__ support)
which most things we care about do at this point (including MSVC).
2020-08-14 12:59:29 -07:00
620f1f0ff0 build: fix build warnigns with Clang 2020-08-14 12:57:50 -07:00
5311f9d80a sysprof-dump: include <errno.h> where appropriate 2020-08-08 10:52:16 -04:00
51a5b20de3 libsysprof: include <errno.h> where appropriate 2020-08-08 10:51:26 -04:00
16b7cb0a96 tests: include <errno.h> where appropriate 2020-08-08 10:50:56 -04:00
cae28263ff build: remove 0.54 meson feature
Since this causes us to fail to build with GTK CI
2020-07-28 11:09:52 -07:00
2769ad9aaf build: give access to profiler path from dependency 2020-07-28 10:27:04 -07:00
462e08270e libsysprof-capture: Don’t unset SYSPROF_CONTROL_FD
By design, it needs to be usable from multiple threads so they can each
request a thread-local mapped ring buffer. This becomes particularly
obvious if you want to send `sysprof_collector_mark()`s from two
libraries (say, GLib and libsoup); the first thread/library to call
`sysprof_collector_mark()` will win.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-17 19:12:01 +01:00
72d70b8514 sysprof-capture: fix typo 2020-07-07 07:50:58 -07:00
555ec04e32 macros: check for C++ 14 feature macros 2020-07-06 16:09:03 -07:00
1c32c1ece5 libsysprof-capture: Add a missing string.h include
It’s needed for `strdup()` which is now used in a macro in this header.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-06 11:27:44 +01:00
eae4eb4ad7 build: Drop redundant _GNU_SOURCE definitions
It’s defined in `meson.build` now. See the previous commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-06 11:27:28 +01:00
6b1cd7a722 build: add internal variable for profiler xml file 2020-07-04 16:42:10 -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
50d33452ab macros: add helper to check for gcc version 2020-07-04 16:11:06 -07:00
6fde9c5ce6 libsysprof-capture: Add sysprof_collector_mark_{v,}printf() methods
These are just like `sysprof_collector_mark()`, but do the printf
formatting of the message internally, and only once the collector has
been fetched — so there is no overhead from the printf if sysprof is not
enabled at runtime.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
e8790bc3d6 build: Add more Meson options for disabling parts of the build
This is all aimed at making it so that sysprof can be built as a
subproject within GLib, with only `libsysprof-capture-4.a` being
produced as output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
d6e8d39292 build: Add subproject support for libsysprof-capture
This will be used to build libsysprof-capture as a subproject within
libglib, with the symbols from libglib being left unresolved until the
static libsysprof-capture is linked into libglib.

When built as a subproject, libsysprof-capture won’t install anything.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
e03b54fca5 build: Only run gdbus-codegen if building components which need it
This is to avoid running `gdbus-codegen` when building sysprof as a
subproject underneath libglib, as by that point in the GLib build
process, `gdbus-codegen` is not yet available.

The interfaces generated by these `gdbus-codegen` invocations are only
needed for `sysprofd` and libsysprof, not for the libraries like
`libsysprof-capture`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-03 22:01:33 +01:00
3c7b76c6ba build: Move Meson dependency() calls to where they’re used
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>
2020-07-03 22:01:33 +01:00
760805c8b9 memory-collector: avoid tracking scratch memory free 2020-07-03 22:00:34 +01:00
03326e82fa memory-collector: drop unused branch 2020-07-03 22:00:34 +01:00
484bc328ee collector: set unlikely for pthread_once() 2020-07-03 22:00:34 +01:00
5d20c3f6cf collector: disable re-entrancy during initialization
When creating a new collector, we need to prevent the following
call to sysprof_malloc0() from re-entering us into the same
position.
2020-07-03 22:00:34 +01:00
a9f136550b build: ensure libsysprof-memory-4.so is placed in libdir
This makes it consistent with other preloads.
2020-07-03 22:00:34 +01:00
97ddf5a0cc libsysprof: port UI to new ABI
Some minor changes were necessary so that we could change the ABI in
libsysprof-capture to be free from GLib (and therefore used by GLib).

This also adds some wrappers for capture API in libsysprof so that we
can continue to use GError from UI code.
2020-07-03 22:00:34 +01:00
608582d3c4 libsysprof-capture: Drop GLib dependency
None of the code uses it any more. This means that `libsysprof-capture.a`
can now be used within `libglib-2.0.so` for collecting main loop
statistics.

Brought to you by Opeth’s Deliverance on repeat.

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

Fixes: #40
2020-07-03 22:00:34 +01:00
45c8c95706 libsysprof-capture: Drop GError usage from SysprofCaptureWriter
Use `errno` instead, which is icky, but given that all of the failure
modes are from POSIX I/O functions, it’s at least in keeping with them.

This is a major API break.

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

Helps: #40
2020-07-03 22:00:34 +01:00
e19d70bca0 libsysprof-capture: Drop GError usage from SysprofCaptureReader
Use `errno` instead, which is icky, but given that all of the failure
modes are from POSIX I/O functions, it’s at least in keeping with them.

This is a major API break.

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

Helps: #40
2020-07-03 22:00:34 +01:00
fde278fb7f libsysprof-capture: Drop sysprof_capture_writer_set_flush_delay()
It was unused anywhere within sysprof.git, and couldn’t be modified to
drop its GLib dependency while still retaining its functionality.

If it’s still needed, it’ll have to be reimplemented in libsysprof.

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

Helps: #40
2020-07-03 22:00:34 +01:00
cef698e658 libsysprof-capture: wrap strdup to be NULL-safe 2020-07-03 22:00:34 +01:00
6a45f020f7 libsysprof-capture: Add SysprofCaptureJitmapIter to replace GHashTable
Change `sysprof_capture_reader_read_jitmap()` to return a `const
SysprofCaptureJitmap *` (like the other `read` functions), and add a new
`SysprofCaptureJitmapIter` type to allow easy iteration over the jitmap.

This allows a use of `GHashTable` to be removed from the API. It breaks
the libsysprof-capture API and ABI.

All the callers iterate over the jitmap rather than looking up elements
by key. If that functionality is needed in future, additional API can be
added to allow it on `SysprofCaptureJitmap`.

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

Helps: #40
2020-07-03 22:00:34 +01:00
75b69d0a89 libsysprof-capture: Rewrite list_files() to avoid GHashTable/GPtrArray
This changes its API and ABI: it now returns an allocated array of const
strings, rather than an allocated array of allocated strings.

The call sites in the source tree have been adjusted accordingly.

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

Helps: #40
2020-07-03 22:00:34 +01:00
13b1e79901 libsysprof-capture: Use POSIX socket functions rather than GSocket
This should be equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
5a2144e254 libsysprof-capture: Port from GLib to pthreads for locking and once-init
Another step towards dropping the GLib dependency.

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

Helps: #40
2020-07-03 22:00:34 +01:00
c89a47939e libsysprof-capture: Move SysprofBacktraceFunc to a different header
So it’s next to the definition of `SysprofCaptureAddress`, which it
uses.

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

Helps: #40
2020-07-03 22:00:34 +01:00
0d68b1afb5 libsysprof-capture: Use _WIN32 rather than G_OS_WIN32
They should be equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
214ec21ce8 libsysprof-capture: Use an internal header in writer-cat.c
This makes no functional difference, but does tidy up the code style a
bit. All other internal headers are included using quotes in other
files.

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

Helps: #40
2020-07-03 22:00:34 +01:00
b558e7b128 libsysprof-capture: Open-code MAX and CLAMP macros
The macros don’t seem to make things sufficiently much clearer that it
makes sense to provide them.

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

Helps: #40
2020-07-03 22:00:34 +01:00
d83adffd2d libsysprof-capture: Avoid using G_STMT_{START,END} from GLib
Open-code them instead, as they’re relatively simple.

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

Helps: #40
2020-07-03 22:00:34 +01:00
8748db4091 libsysprof-capture: Use calloc() to replace GArray in writer-cat.c
This is a straightforward replacement using a single allocation, as the
number of array elements is always known ahead of time.

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

Helps: #40
2020-07-03 22:00:34 +01:00
8641789d87 libsysprof-capture: Use unlink() rather than g_unlink()
They’re equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
621e7ea314 libsysprof-capture: Use mkostemp() rather than g_file_open_tmp()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
43530e3613 libsysprof-capture: Use vsnprintf() instead of g_strdup_printf()
This imposes an arbitrary limit of 2048B on the length of printf-ed log
messages, but is otherwise equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
f5cf12ae40 libsysprof-capture: Use POSIX environment functions instead of GLib ones
They are equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
e8a6474236 libsysprof-capture: Use strftime() to format dates rather than GLib
This means we lose support for local timezones other than UTC, but is
otherwise equivalent.

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

Helps: #40
2020-07-03 22:00:34 +01:00
6d3ede2e9f libsysprof-capture: Avoid using GLIB_SIZEOF_VOID_P
Use `UINTPTR_MAX` to calculate the size of a pointer instead. This
assumes that all pointers are the same width.

It also means that the sysprof-capture code uses the pointer size of the
platform that libsysprof-capture was compiled on, rather than the
pointer size of the platform that GLib was compiled on. They seem
unlikely to differ.

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

Helps: #40
2020-07-03 22:00:34 +01:00
113d9d166a libsysprof-capture: Use C-standard printf modifiers
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
14078e6c4d libsysprof-capture: Use SYSPROF_INT64_CONSTANT instead of GLib version
Same for the unsigned version. They do the same thing as the GLib
versions.

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

Helps: #40
2020-07-03 22:00:34 +01:00
f1cb640091 libsysprof-capture: Use reallocarray() instead of GArray in writer-cat.c
This is more of a direct port than previous replacements of `GArray`
(which have had linear growth): this one implements exponential growth
of the allocated array, as `GArray` does.

It uses `qsort()` to sort the array so that it can be binary searched as
before.

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

Helps: #40
2020-07-03 22:00:34 +01:00