capture: add pid-root frame type

While I'm not thrilled to add new frame types for every sort of thing, I
think having this will be relatively useful so we can improve decoding
operations.

This adds SysprofCapturePidRoot which lets us specify a root directory
on the host system for which is the real root (/) of the PID. This can
be useful when reconstructing overlays for containers and you need to
direct access to alternate roots.

The layer gives us some ability to try to deal with overlayfs, albeit at
a very rudimentary level. In most cases I anticipate we just deal with
the main root and ignore overlays until necessary.
This commit is contained in:
Christian Hergert
2021-02-24 17:50:36 -08:00
parent ff22417de9
commit 4758fb42ce
8 changed files with 138 additions and 2 deletions

View File

@ -827,6 +827,39 @@ sysprof_capture_writer_add_fork (SysprofCaptureWriter *self,
return true;
}
bool
sysprof_capture_writer_add_pid_root (SysprofCaptureWriter *self,
int64_t time,
int cpu,
int32_t pid,
const char *path,
uint32_t layer)
{
SysprofCapturePidRoot *ev;
size_t strl = strlen (path);
size_t len = sizeof *ev + strl + 1;
assert (self != NULL);
ev = (SysprofCapturePidRoot *)sysprof_capture_writer_allocate (self, &len);
if (!ev)
return false;
sysprof_capture_writer_frame_init (&ev->frame,
len,
cpu,
pid,
time,
SYSPROF_CAPTURE_FRAME_PID_ROOT);
ev->layer = layer;
memcpy (ev->path, path, strl);
ev->path[strl] = 0;
self->stat.frame_count[SYSPROF_CAPTURE_FRAME_PID_ROOT]++;
return true;
}
bool
sysprof_capture_writer_add_exit (SysprofCaptureWriter *self,
int64_t time,