Commit Graph

232 Commits

Author SHA1 Message Date
b129c7dea2 mapped-ring-buffer: Round to the shared memory boundary on hppa
In map_head_and_body_twice(), the second mmap call fails:

mmap2(NULL, 135168, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0xf64a2000
mmap2(0xf64b3000, 65536, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0x1000) = -1 EINVAL (Invalid argument)

Due to cache issues, all shared mapping of a page must be equivalently
mapped.  This requires page mappings to be at the same virtual address
modulo 4 MB.  Due to a kernel limitation, all mappings to a file must
be equivalent.

The test can be fixed by rounding the buffer_size used in the mapped
ring buffer to 4 MB on hppa.  This makes the two mmap mappings equivalent.

Bug-Debian: https://bugs.debian.org/1021853
2025-03-17 11:53:28 -04:00
5151345ef4 libsysprof-capture: fix license of mapped-ring-buffer 2025-01-20 13:08:07 -08:00
45b3f99e55 libsysprof-capture: unsigned cast before shift 2024-11-25 16:24:28 -08:00
d305812932 libsysprof-capture: Set initial counter id to pid
This avoids collisions when using Sysprof collector in multiprocess
apps that share the same controlfd, such as WebKit.
2024-11-14 10:03:46 +01:00
788b1995b9 libsysprof-capture: add version macros for 48 2024-10-09 21:42:36 -07:00
c228634fcb libsysprof-capture: handle unwind length < 0 gracefully
Also do the snapshot before setting up frame so that unwinders can do
tricks to use extra space before the addr location.
2024-09-12 09:23:10 -07:00
10217bb0e2 libsysprof-capture: fix set_fd_blocking()
It was missing an include for the define and the variable was flat out
wrong when porting.

Fixes: #124
2024-08-22 08:33:45 -07:00
b4a592a020 Add test-cases that include sysprof headers into C++ code
Reproduces: https://gitlab.gnome.org/GNOME/sysprof/-/issues/114
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-02-24 11:41:56 +00:00
36f4988ecc Conditionalize uses of C99 restrict keyword
This is part of C99, but not part of Standard C++, so it can't be used
unconditionally if the sysprof headers might get included into C++ code.

Resolves: https://gitlab.gnome.org/GNOME/sysprof/-/issues/114
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-02-24 11:41:56 +00:00
c45aba997d libsysprof-capture: sleep and try again to get an event
Unless we've failed before, then just bail immediately so that applications
which loose their controller keep running with minimal overhead.
2023-08-15 15:37:24 -07:00
a9cf64903c libsysprof-capture: increase ring buffer size
Make sure there is less chance of losing information in these buffers.
2023-08-15 14:40:31 -07:00
f40587a38a meson: remove unnecessary argument nesting 2023-07-28 14:03:51 -05:00
50cfd82286 meson: remove extraneous default install_dir arguments 2023-07-28 14:02:33 -05:00
f93767cfb2 meson: use variables for gio-2.0, glib-2.0, and gio-unix-2.0 2023-07-28 14:00:04 -05:00
79ba6ab3d5 meson: remove explicit pkgconfig install_dir
This is the default.
2023-07-28 13:09:48 -05:00
e210572700 libsysprof-capture: add bus type to add_dbus API 2023-07-27 14:25:06 -07:00
f46d690a28 libsysprof-capture: add support for DBusMessage frames
These are still captive to the max size of a SysprofCaptureFrame, but
most messages fit into that.
2023-07-27 12:22:31 -07:00
a7fe9abb19 libsysprof-capture: add map variant with build-id
This allows tacking on suplimental data to the capture with a build-id so
that our SysprofDocumentMmap can read it. The format is @build-id\0 after
the trailing \0 of the filename in a SysprofCaptureMap frame.
2023-07-24 17:30:07 -07:00
dfd81f1ecb libsysprof-capture: ensure trailing bit is zero
This ensures situations that are not perfectly aligned can still be 1-off
checked for a trailing \0 without scanning.
2023-07-24 17:28:46 -07:00
732511076c libsysprof-capture: fix a 32-bit cast warning 2023-07-23 18:16:59 -07:00
ff40f7d37d tests: move tests to appropriate libraries 2023-07-20 16:20:52 -07:00
f8890fb040 libsysprof-capture: add rewrite-pid to capture tests 2023-07-17 12:24:44 -07:00
df8187f66b libsysprof-capture: move mapped ring buffer test to capture lib 2023-07-17 11:38:53 -07:00
1f4f4d7e50 build: keep libsysprof-capture version at 4
We haven't changed the format, so we really don't want to cause unnecessary
churn by applications consuming this.
2023-07-12 11:49:55 -07:00
db88129c81 libsysprof-capture: add API to duplicate underlying write FD
This is useful for use in our other libraries that may need access to these
to create document loaders for a completed writer.
2023-07-08 11:19:02 -07:00
3a94170b0a 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.
2023-06-13 12:41:50 -07:00
38dbf0dc95 build: add mapped_ring_buffer_sources for inclusion
We use this in various places but it relies on some static API in the
libsysprof-capture. Make it available to the other libraries.
2023-05-26 16:46:44 -07:00
582986f5c9 libsysprof-capture: free deduplicated array entries 2023-05-12 14:09:43 -07:00
dc99b46254 libsysprof-capture: fix leak of mapped ring buffer structure 2023-05-12 14:02:46 -07:00
6d50f3ca7b meson: Override dependencies to improve usage as a subproject
With this change, sysprof can be consumed as a subproject without
making any changes to the build files of a project. All you need to do
is provide a wrap file with a `[provide]` section:

https://mesonbuild.com/Wrap-dependency-system-manual.html#provide-section

This is also necessary because otherwise projects need to hard-code
the subproject name, which might be `sysprof` when using `wrap-git` or
`sysprof-3.46.0` when using `wrap-file` (to build from a release
tarball). This can cause conflicts between different subprojects that
consume sysprof differently.

Other projects like glib, cairo, pango, etc already do this.
2022-12-18 10:04:00 +05:30
9e2743fa76 build: gate capture pkgconfig by install-static 2022-07-22 13:45:55 -07:00
099330db90 build: allow disabling installation of static libraries 2022-07-22 13:43:54 -07:00
3c5540047f build: bump for development 2022-04-01 12:41:14 -07:00
14139232d5 capture: rename PidRoot to Overlay and add src/dst
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).
2021-02-25 13:43:09 -08:00
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
ff22417de9 build: add missing 3.40 version macros 2021-02-24 17:41:20 -08:00
adf8a3cd6a version: relicense with the rest of sysprof-capture 2021-02-24 09:39:01 -08:00
843585e00d cursor: handle NULL readers gracefully
Fixes #55
2021-02-23 15:33:51 -08:00
77a340e3f6 build: use specify pic for static libsysprof-capture 2021-02-19 09:37:24 -08:00
b8950c9409 platform: handle some differences on macOS 2020-11-16 14:13:50 -08:00
f18fbe5ae8 build: various fixes for compiling on macOS 2020-11-16 14:01:02 -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
f0303f4b68 meson: Fix pkgconfig generation
This fix error when gio is a subproject, when there is pc file
assotiated for objects in libraries_private meson automatically promote
them to requires.

Also remove some values that are already the default.
2020-10-01 10:15:38 -04:00
b39a43d218 capture: dont leak listed files strings
Fix leak introduced by #50
2020-09-28 15:56:36 -07:00
28bb526603 capture: fix sysprof_capture_reader_list_files()
This needs to stash the string pointers internally so that we can maintain
ABI and still fix the issue at hand.

Fixes #50
2020-09-28 15:53:54 -07:00
254b9f8f69 capture: fix compilation on Clang 11
Fixes #48
2020-09-16 12:41:09 -07:00
2260945e8f Merge branch 'wip/issue49' into 'master'
libsysprof, libsysprof-ui: Generate pkg-config dependencies

Closes #49

See merge request GNOME/sysprof!38
2020-09-16 18:09:27 +00:00
04b6fdfcbe libsysprof, libsysprof-ui: Generate pkg-config dependencies
Otherwise, using libsysprof-ui will usually fail because <dazzle.h>
is not added to the search path.

Resolves: https://gitlab.gnome.org/GNOME/sysprof/-/issues/49
Signed-off-by: Simon McVittie <smcv@debian.org>
2020-09-16 10:48:04 +01:00
68c50ba869 build: Pass libraries to pkgconfig.generate as a positional argument
This allows Meson to associate the pkg-config module with the "main"
library that it represents, in an unambiguous way.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-09-16 10:47:22 +01:00
088408c085 sysprof-capture-condition: always return even if unreachable
Fix the problem with -Werror=return-type
2020-09-15 20:51:28 +07:00