libsysprof-capture: add frame type for tracing

This is like sample but has an "enter/exit" flag with it. This can be
useful when you want to provide tracing instead of sampling. We use a
different frame type so that we can denote that this isn't traditional
sampling, and the flag can be used to find the next exit for the current
enter for calculating durations.

The entire stack trace is provided to make things easier on tools
which may want to deal with indirect functions that were not instrumented
but can be unwound. That may allow for tooling to give the user some
insight that it's not *just* this function entering, but some functions
before it were entered too.

This also adds a SysprofTracer instrument which will preload a
libsysprof-tracer-6.so into the process providing the
__cyg_profile_func_enter() and __cyg_profile_func_leave() hooks.
This commit is contained in:
Christian Hergert
2023-06-13 12:11:55 -07:00
parent 81eafb9232
commit 3a94170b0a
17 changed files with 369 additions and 9 deletions

View File

@ -301,6 +301,26 @@ main (gint argc,
break;
}
case SYSPROF_CAPTURE_FRAME_TRACE:
{
const SysprofCaptureTrace *s = sysprof_capture_reader_read_trace (reader);
gdouble ptime = (s->frame.time - begin_time) / (gdouble)SYSPROF_NSEC_PER_SEC;
SysprofAddressContext context = SYSPROF_ADDRESS_CONTEXT_NONE;
g_print ("TRACE: pid=%d tid=%d time=%" G_GINT64_FORMAT " (%lf) %s\n",
s->frame.pid, s->tid, s->frame.time, ptime,
s->entering ? "ENTER" : "EXIT");
for (guint i = 0; i < s->n_addrs; i++)
{
g_autofree char *name = symbolize (resolvers, &s->frame, &context, s->addrs[i]);
g_print (" " SYSPROF_CAPTURE_ADDRESS_FORMAT " (%s)\n", s->addrs[i], name);
}
break;
}
case SYSPROF_CAPTURE_FRAME_TIMESTAMP:
{
const SysprofCaptureTimestamp *ts = sysprof_capture_reader_read_timestamp (reader);