This allows you to set a flag to show the thread id of what was recorded.
Use this to help disassociate similar threads in a process to figure out
which thread is consuming a majority of the Total time of that process.
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 just serves as a prototyping ground so that we can have a callgraph
view widget in the future based on these principles. It also shows some
areas that still need work, such as sorting within the tree and fixing the
text offset calculation for ELF symbols.
We don't need to dynamically link against libsysprof for sysprof-cli as
we can do the same thing that sysprof-agent does. In fact, we can probably
even make sysprof-cli wrap sysprof-agent in the future (or be the same
binary that looks at it's argv[0]).
This also builds the agent statically with libsysprof_static_dep since
we'd need that to avoid installing libsysprof when that isn't wanted.
It also ensures the LD_PRELOAD libraries are installed for use by the
agent.
This is a program that can be communicated with over private D-Bus using
pipes to control a process. It is useful in an automated fashion from
tooling such as Builder.
This allows, when installed into SDKs like GNOMEs, to profile from inside
the container rather than from the outside. Such is useful when you need
to ensure you have access to LD_PRELOAD/etc within the context.
Really what we want to deal with here is tracking an overlay that we may
need to be able to decode after the fact (in case processes exit or we
need to do post-processing symbol resolution).
For the podman case, that is $some_path mapped to root (/), generally
speaking. For flatpak though, that would have two mappings, one for
/app and another for /usr (possibly more).
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 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>
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>
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>
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
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
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
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
Another step towards dropping GLib as a dependency of
libsysprof-capture.
Unlike the previous commit which replaced GLib integer types with the
bitwise equivalent C standard types, `stdbool` is potentially a different
width from `gboolean`, so this is an ABI break.
It therefore involves some changes to callback functions in the tests
and tools, and in libsysprof.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
In preparation for dropping the GLib dependency from libsysprof-capture,
move the autocleanup definitions up to libsysprof. Add a new header for
them.
This is slightly awkward in the tools, which depend on
libsysprof-capture but not libsysprof. Rather than make them depend on
libsysprof (which might be disabled at configure time), include the
`sysprof-capture-autocleanups.h` file between source directories.
`SYSPROF_COMPILATION` needs to be defined for this to work.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
`reader` can be `NULL`, but the `NULL` check was done after potentially
dereferencing it.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
It has previously been implicitly pulled in by libsysprof-capture, but
that will change in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
When trying to build gjs with --werror, I get the following error:
In file included from /nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture-condition.h:59,
from /nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture.h:66,
from ../gjs/profiler.cpp:53:
/nix/store/snc19nr462570ssx03v455p164vyz15s-sysprof-3.36.0-dev/include/sysprof-3/sysprof-capture-types.h:76:40: error: invalid suffix on literal; C++11 requires a space between literal and string macro [-Werror=literal-suffix]
76 | #define SYSPROF_CAPTURE_ADDRESS_FORMAT "0x%016"G_GINT64_MODIFIER"x"
| ^
cc1plus: all warnings being treated as errors