We don't need a socketpair for this. Additionally, things seem to work
better from the service when the client provides the pipe. Otherwise, when
running as a dbus service I often have issues with things getting closed
out from under us.
This provides a new sysprof-live-unwinder subprocess that runs as root to
allow accessing all processes on the system via /proc/$pid/. It is spawned
by sysprofd with various perf event FDs and a FD to write captures to.
Ideally the capture_fd is something that will naturally error if the client
application crashes (such as a socketpair() having the peer close). This
is not enforced but encouraged. Additionally, an event_fd is used to allow
the client application to signal the live-unwinder to exit.
Unwinding is performed by looking at the modules loaded into the target
pid and using libdwfl to access DWARF/CFI/etc state machinery. Stack data
does not touch the disk as it exists in a mmap buffer from perf and is
then translated into a callchain and sent to the Sysprof client.
Unwinding occurs as normal post-mortem though is improved through the use
of debuginfod to locate the appropriate symbols.
This requires a coordinating sysprofd that knows how to handle reading the
new attributes. Setting these fields will allow snapshotting the contents
of the stack and registers to do offline unwinding.
Also make the conversion to GVariant available outside the module so that
we can consume it for live unwinding.
We will want to be able to open perf event streams with these options so
that we can get the build-id extracted from an ELF without having to rely
on parsing it at resolution time.
Additionally, it could give us an option for live-decoding at some point
in userspace without having to write the major DWARF capture data to disk.
This brings together the two libraries back into one now that the whole
design is pretty well sorted out. They depend on roughly the same libraries
anyway and it's way easier of the single library can both read and write
the capture files (along with bringing in libsysprof-capture symbols in
a single place).
This removes -Dagent and just uses -Dtools as it only affects sysprof-cli
and sysprof-agent. We still need to patch sysprof-cli for recent changes
as we did for sysprof-agent though.
Additionally, we haven't used the v2 service in forever, so drop that as
I can't imagine anyone has been using it.
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>
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
This is more reliable than using a PTY and allows us to use a regular
pipe to output data into a GIOChannel. This also changes the design to
use async IO watches for sample delivery.
This allows consumers to get a RAPL profiler object on the D-Bus at
org.gnome.Sysprof3 with path /org/gnome/Sysprof3/RAPL. This can be used
by the clients to record extra power statistics.
It requires the `turbostat` program to be installed, and is provided in
packages such as `kernel-tools` on Fedora. Distributions may want to
ensure that is available as a dependency of Sysprof, but it is not
strictly required.
This is useful for optimized parsing of proc files such as necessary by
the memory source to seek() back to the start (instead of re-opening a
new file).
Calling all the individual function calls to get process information would
be considerably inefficient, so we can coalesce a bunch of that and change
our process-model implementation (and proc source) to use this.