sysprofd: add support for unwinding without frame pointers

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 commit is contained in:
Christian Hergert
2024-11-03 10:41:44 -08:00
parent 39b96f47f5
commit 1bd79af439
15 changed files with 2580 additions and 4 deletions

View File

@ -30,9 +30,11 @@
#include "ipc-rapl-profiler.h"
#include "ipc-service-impl.h"
#include "ipc-unwinder-impl.h"
#define V3_PATH "/org/gnome/Sysprof3"
#define RAPL_PATH "/org/gnome/Sysprof3/RAPL"
#define UNWINDER_PATH "/org/gnome/Sysprof3/Unwinder"
#define NAME_ACQUIRE_DELAY_SECS 3
#define INACTIVITY_TIMEOUT_SECS 120
@ -126,6 +128,7 @@ main (gint argc,
{
g_autoptr(IpcProfiler) rapl = ipc_rapl_profiler_new ();
g_autoptr(IpcService) v3_service = ipc_service_impl_new ();
g_autoptr(IpcUnwinder) unwinder = ipc_unwinder_impl_new ();
g_signal_connect (v3_service, "activity", G_CALLBACK (activity_cb), NULL);
g_signal_connect (rapl, "activity", G_CALLBACK (activity_cb), NULL);
@ -133,7 +136,8 @@ main (gint argc,
activity_cb (NULL, NULL);
if (g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (v3_service), bus, V3_PATH, &error) &&
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (rapl), bus, RAPL_PATH, &error))
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (rapl), bus, RAPL_PATH, &error) &&
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (unwinder), bus, UNWINDER_PATH, &error))
{
for (guint i = 0; i < G_N_ELEMENTS (bus_names); i++)
{