Commit Graph

22 Commits

Author SHA1 Message Date
4758fb42ce 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.
2021-02-24 17:56:37 -08:00
8f8ce85327 libsysprof-capture: Drop duplicate struct typedefs
All three of these structs are already defined in
`sysprof-capture-types.h`, which is included from these three headers.

Drop the duplicate definition to silence the Clang warning:
```
In file included from /opt/gnome/install/include/sysprof-4/sysprof-capture.h:63:
/opt/gnome/install/include/sysprof-4/sysprof-capture-cursor.h:67:38: warning: redefinition of typedef 'SysprofCaptureCursor' is a C11 feature [-Wtypedef-redefinition]
typedef struct _SysprofCaptureCursor SysprofCaptureCursor;
                                     ^
/opt/gnome/install/include/sysprof-4/sysprof-capture-types.h:98:41: note: previous definition is here
typedef struct _SysprofCaptureCursor    SysprofCaptureCursor;
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-11-16 15:15:26 +00:00
e19d70bca0 libsysprof-capture: Drop GError usage from SysprofCaptureReader
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
2020-07-03 22:00:34 +01:00
6a45f020f7 libsysprof-capture: Add SysprofCaptureJitmapIter to replace GHashTable
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
2020-07-03 22:00:34 +01:00
75b69d0a89 libsysprof-capture: Rewrite list_files() to avoid GHashTable/GPtrArray
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
2020-07-03 22:00:34 +01:00
41ec04ea99 libsysprof-capture: Replace G_BEGIN_DECLS with SYSPROF_BEGIN_DECLS
It does the same job, but doesn’t require GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-03 22:00:34 +01:00
5636bbf4f0 libsysprof-capture: Use stdbool instead of gboolean
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
2020-07-02 21:07:11 +01:00
2c2cbf6343 libsysprof-capture: Use C11 types instead of GLib types
This is an almost entirely mechanical* conversion from (for example)
`gint` → `int`, `guint8` → `uint8_t`, etc.

It is not entirely complete, as many GLib functions are still used in
libsysprof-capture, which necessitate some use of GLib types.

It also avoids renaming `gboolean` → `bool` as that’s a slightly more
controversial change which will happen in the following commit.

*Code was manually realigned afterwards.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #40
2020-07-02 21:07:11 +01:00
d2047fb557 libsysprof-capture: Move autocleanup definitions to libsysprof
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
2020-07-02 21:07:11 +01:00
33c81a3a9c memprof: add memory profiling using LD_PRELOAD
This brings over some of the techniques from the old memprof design.
Sysprof and memprof shared a lot of code, so it is pretty natural to
bring back the same callgraph view based on memory allocations.

This reuses the StackStash just like it did in memprof. While it
would be nice to reuse some existing tools out there, the fit of
memprof with sysprof is so naturally aligned, it's not really a
big deal to bring back the LD_PRELOAD. The value really comes
from seeing all this stuff together instead of multiple apps.

There are plenty of things we can implement on top of this that
we are not doing yet such as temporary allocations, cross-thread
frees, graphing the heap, and graphing differences between the
heap at to points in time. I'd like all of these things, given
enough time to make them useful.

This is still a bit slow though due to the global lock we take
to access the writer. To improve the speed here we need to get
rid of that lock and head towards a design that allows a thread
to request a new writer from Sysprof and save it in TLS (to be
destroyed when the thread exits).
2020-02-07 19:00:33 -08:00
532972beb6 libsysprof-capture: relicense as BSD-2-Clause-Patent
This allows embedding the static capture library without having to deal
with license incompatibility while retaining the patent clause. We want
as many consumers of the format as makes sense without the restriction
of what kind of app/library/tooling they are.

The application, sysprofd, libsysprof, and libsysprof-ui continue to be
GPLv3+.
2019-06-05 13:25:21 -07:00
7743a047b6 libsysprof-capture: add sysprof_capture_reader_find_file() 2019-05-29 15:13:01 -07:00
ffda366809 libsysprof-capture: add byte-order helper
This isn't needed for reading captures, but can be helpful when dealing
with embedded data such as file frames.
2019-05-29 15:13:01 -07:00
596d29496d libsysprof-capture: add file reader helper 2019-05-29 15:13:01 -07:00
336dae4d1f libsysprof-capture: add helper to list files in capture 2019-05-29 15:13:01 -07:00
7650d6e7c6 libsysprof-capture: add file chunk frame type 2019-05-29 15:13:01 -07:00
cc415c9140 libsysprof-capture: add log frame type
This is useful to interleave logs with the capture so that we can have
correlation without interjecting them into mark fields.
2019-05-29 15:13:01 -07:00
567f8a3a0f libsysprof-capture: shorten names by removing Frame 2019-05-29 15:13:01 -07:00
db9aea95ea libsysprof-capture: add metadata frame type
This will allow sources and aids to discover information about what was
done between capture loading and saving.
2019-05-29 15:13:00 -07:00
aed80ea51f libsysprof-capture: add stats to reader when possible
We can also back-fill these when reading a capture file.
2019-05-29 15:13:00 -07:00
d38b3be158 libsysprof-capture: whitespace cleanup 2019-05-29 15:13:00 -07:00
53c718b708 build: rename all symbols to use sysprof_ as prefix
As we gain in usage, we need to be more careful about using a prefix
that will not collide with other symbols. So version 3 of our ABI will
change to using Sysprof/SYSPROF/sysprof as the various prefixes.

The soname/api version bump will happen later on this branch so that
things are easier to test up until then.
2019-05-29 15:12:59 -07:00