Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
694369c
feat: Implement the GPU Info gathering within the Native SDK
mujacica Aug 11, 2025
7abb10f
Fix file format
mujacica Aug 11, 2025
47d42e0
Add changelog entry
mujacica Aug 11, 2025
193415c
Extend README with new SENTRY_WITH_GPU_INFO option
mujacica Aug 11, 2025
61f26c5
Skip apple silicon tests on non darwin platforms
mujacica Aug 11, 2025
d390e3b
Enable GPU Info per default to test cmake on github runners
mujacica Aug 11, 2025
0e0fe32
Resolve compiler issues on Linux
mujacica Aug 11, 2025
76f29d2
Fix Windows builds
mujacica Aug 11, 2025
165448b
Fix failing tests
mujacica Aug 11, 2025
113a877
Fix IOS builds
mujacica Aug 11, 2025
e68008d
Fix remaining failing tests
mujacica Aug 11, 2025
a963cc5
Fix format
mujacica Aug 11, 2025
7bb1486
Keep GPU Info disabled by default
mujacica Aug 11, 2025
00f5fbe
Fix CMake for all platforms
mujacica Aug 11, 2025
cdd322b
Fix comments, and findings from testing
mujacica Aug 12, 2025
cf68326
Further testing fixes
mujacica Aug 12, 2025
9369bd4
Fix failing test
mujacica Aug 12, 2025
811af70
Use Sentry wstr function instead of custom implementation
mujacica Aug 12, 2025
366c951
Simplify Unix implementation and CMakeLists
mujacica Aug 14, 2025
ed6352a
Add nvml support, add multi-gpu support
mujacica Aug 14, 2025
38dbf53
Fix linux complier warnings
mujacica Aug 14, 2025
c92625b
Fix file formats
mujacica Aug 14, 2025
167a5b2
Fix build issues after refactoring
mujacica Aug 14, 2025
ce74008
Fix file formats
mujacica Aug 14, 2025
caf23dc
Use Vulkan for GPU info with multi-platform support
mujacica Aug 17, 2025
a0fe5f5
Fix file format
mujacica Aug 17, 2025
f6c415f
Fix None implementation
mujacica Aug 17, 2025
889a124
Don't use singleton
mujacica Aug 17, 2025
2e99fe2
Fix format
mujacica Aug 17, 2025
e40d3f4
Simplify driver version, remove test script
mujacica Aug 20, 2025
3d4aaa7
Use Vulkan headers, dynamically load
mujacica Aug 20, 2025
906b522
Fix format
mujacica Aug 20, 2025
01a60dc
Fix CMake to include headers only
mujacica Aug 20, 2025
8532078
Fix 32-bit builds
mujacica Aug 20, 2025
0596e66
Fix GPU test pritnf formats
mujacica Aug 20, 2025
d7a54bc
Fix format
mujacica Aug 20, 2025
5d4a440
One more test fix
mujacica Aug 20, 2025
7861d9f
Fix format
mujacica Aug 20, 2025
dd4ba8f
Fix cursor comment
mujacica Oct 2, 2025
bc60ed1
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
294d9c5
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
81d0cc9
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
1a102cc
Update README.md
mujacica Oct 9, 2025
a497edd
Fix PR Comments
mujacica Oct 9, 2025
b6f0b8c
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
33c6a57
Further fixes
mujacica Oct 9, 2025
a9736a9
Fix memory units
mujacica Oct 9, 2025
a44c5e8
Fix docs
mujacica Oct 9, 2025
95e7ae5
Fix more comments
mujacica Oct 9, 2025
e202fee
Fix Mac compatibility
mujacica Oct 9, 2025
6da0996
Fix Vendor ID's
mujacica Oct 13, 2025
2bc5e9d
Fix memory size to MB
mujacica Oct 13, 2025
06e0f7c
Fix CHANGELOG
mujacica Feb 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
run: |
sudo apt update
# Install common dependencies
sudo apt install cmake llvm valgrind zlib1g-dev libcurl4-openssl-dev
sudo apt install cmake llvm valgrind zlib1g-dev libcurl4-openssl-dev libvulkan-dev
# For GCC, install both gcc-X and g++-X. For Clang, only install clang-X (includes C++ compiler)
if [[ "$CC" == gcc-* ]]; then
sudo apt install "${CC}" "${CXX}"
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
[submodule "external/benchmark"]
path = external/benchmark
url = https://github.com/google/benchmark.git
[submodule "external/vulkan-headers"]
path = external/vulkan-headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

**Features**:

- Implement the GPU Info gathering within the Native SDK ([#1336](https://github.com/getsentry/sentry-native/pull/1336))

**Fixes**:

- Remove spurious decref in `sentry_capture_user_feedback()` ([#1510](https://github.com/getsentry/sentry-native/pull/1510))
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@ option(SENTRY_PIC "Build sentry (and dependent) libraries as position independen

option(SENTRY_TRANSPORT_COMPRESSION "Enable transport gzip compression" OFF)

# GPU information gathering support - enabled by default on supported platforms only
set(SENTRY_GPU_INFO_DEFAULT OFF)

# Only enable GPU info on supported platforms
if(WIN32)
set(SENTRY_GPU_INFO_DEFAULT ON)
elseif(APPLE AND NOT IOS)
set(SENTRY_GPU_INFO_DEFAULT ON)
elseif(LINUX)
set(SENTRY_GPU_INFO_DEFAULT ON)
else()
# Disable GPU info on all other platforms (Android, iOS, AIX, etc.)
message(STATUS "GPU Info: Platform not supported, GPU information gathering disabled")
endif()

option(SENTRY_WITH_GPU_INFO "Build with GPU information gathering support" ${SENTRY_GPU_INFO_DEFAULT})

# GPU info enabled - no longer requires Vulkan SDK (uses headers submodule + dynamic linking)
if(SENTRY_WITH_GPU_INFO)
message(STATUS "GPU information gathering enabled (using vulkan-headers submodule)")
endif()

option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}")
option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF)
Expand Down Expand Up @@ -591,6 +613,12 @@ if(NOT XBOX)
endif()
endif()

# handle Vulkan headers for GPU info
if(SENTRY_WITH_GPU_INFO)
target_include_directories(sentry PRIVATE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/vulkan-headers/include>")
endif()

# apply platform libraries to sentry library
target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS})

Expand Down
39 changes: 22 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ The example currently supports the following commands:
- `discarding-before-transaction`: Installs a `before_transaction()` callback that discards the transaction.
- `traces-sampler`: Installs a traces sampler callback function when used alongside `capture-transaction`.
- `attach-view-hierarchy`: Adds a `view-hierarchy.json` attachment file, giving it the proper `attachment_type` and `content_type`.
This file can be found in `./tests/fixtures/view-hierachy.json`.
This file can be found in `./tests/fixtures/view-hierachy.json`.
- `set-trace`: Sets the scope `propagation_context`'s trace data to the given `trace_id="aaaabbbbccccddddeeeeffff00001111"` and `parent_span_id=""f0f0f0f0f0f0f0f0"`.
- `capture-with-scope`: Captures an event with a local scope.
- `attach-to-scope`: Same as `attachment` but attaches the file to the local scope.
Expand All @@ -196,6 +196,7 @@ The example currently supports the following commands:
- `test-logger-before-crash`: Outputs marker directly using printf for test parsing before crash.

Only on Linux using crashpad:

- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.

Only on Windows using crashpad with its WER handler module:
Expand All @@ -218,21 +219,25 @@ invoked directly.

## Handling locks

There are a couple of rules based on the current usage of mutexes in the Native SDK that should always be
There are a couple of rules based on the current usage of mutexes in the Native SDK that should always be
applied in order not to have to fight boring concurrency bugs:

* we use recursive mutexes throughout the code-base
* these primarily allow us to call public interfaces from internal code instead of having a layer in-between
* but they come at the risk of less clarity whether a lock release still leaves a live lock
* they should not be considered as convenience:
* reduce the amount of recursive locking to an absolute minimum
* instead of retrieval via global locks, pass shared state like `options` or `scope` around in internal helpers
* or better yet: extract what you need into locals, then release the lock early
* we provide lexical scope macros `SENTRY_WITH_OPTIONS` and `SENTRY_WITH_SCOPE` (and variants) as convenience wrappers
* if you use them be aware of the following:
* as mentioned above, while the macros are convenience, their lexical scope should be as short as possible
* avoid nesting them unless strictly necessary
* if you nest them (directly or via callees), the `options` lock **must always be acquired before** the `scope` lock
* never early-return or jump (via `goto` or `return`) from within a `SENTRY_WITH_*` block: doing so skips the corresponding release or cleanup
* in particular, since `options` are readonly after `sentry_init()` the lock is only acquired to increment the refcount for the duration of `SENTRY_WITH_OPTIONS`
* however, `SENTRY_WITH_SCOPE` (and variants) always hold the lock for the entirety of their lexical scope
- we use recursive mutexes throughout the code-base
- these primarily allow us to call public interfaces from internal code instead of having a layer in-between
- but they come at the risk of less clarity whether a lock release still leaves a live lock
- they should not be considered as convenience:
- reduce the amount of recursive locking to an absolute minimum
- instead of retrieval via global locks, pass shared state like `options` or `scope` around in internal helpers
- or better yet: extract what you need into locals, then release the lock early
- we provide lexical scope macros `SENTRY_WITH_OPTIONS` and `SENTRY_WITH_SCOPE` (and variants) as convenience wrappers
- if you use them be aware of the following:
- as mentioned above, while the macros are convenience, their lexical scope should be as short as possible
- avoid nesting them unless strictly necessary
- if you nest them (directly or via callees), the `options` lock **must always be acquired before** the `scope` lock
- never early-return or jump (via `goto` or `return`) from within a `SENTRY_WITH_*` block: doing so skips the corresponding release or cleanup
- in particular, since `options` are readonly after `sentry_init()` the lock is only acquired to increment the refcount for the duration of `SENTRY_WITH_OPTIONS`
- however, `SENTRY_WITH_SCOPE` (and variants) always hold the lock for the entirety of their lexical scope

## Runtime Library Requirements

**Vulkan**: libraries (e.g. libvulkan, vulkan-1, MoltenVK) are required for gathering GPU Context data. Native SDK provides vendored Headers of Vulkan for easier compilation and integration, however it relies on the libraries being installed in a known location.
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Conan Center](https://shields.io/conan/v/sentry-native)](https://conan.io/center/recipes/sentry-native) [![homebrew](https://img.shields.io/homebrew/v/sentry-native)](https://formulae.brew.sh/formula/sentry-native) [![nixpkgs unstable](https://repology.org/badge/version-for-repo/nix_unstable/sentry-native.svg)](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/se/sentry-native/package.nix) [![vcpkg](https://shields.io/vcpkg/v/sentry-native)](https://vcpkg.link/ports/sentry-native)

<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<picture>
Expand All @@ -10,6 +11,7 @@
</p>

# Official Sentry SDK for C/C++ <!-- omit in toc -->

[![GH Workflow](https://img.shields.io/github/actions/workflow/status/getsentry/sentry-native/ci.yml?branch=master)](https://github.com/getsentry/sentry-native/actions)
[![codecov](https://codecov.io/gh/getsentry/sentry-native/branch/master/graph/badge.svg)](https://codecov.io/gh/getsentry/sentry-native)

Expand Down Expand Up @@ -98,7 +100,7 @@ per platform, and can also be configured for cross-compilation.
System-wide installation of the resulting sentry library is also possible via
CMake.

The prerequisites for building differ depending on the platform and backend. You will always need `CMake` to build the code. Additionally, when using the `crashpad` backend, `zlib` is required. On Linux and macOS, `libcurl` is a prerequisite. For more details, check out the [contribution guide](./CONTRIBUTING.md).
The prerequisites for building differ depending on the platform and backend. You will always need `CMake` to build the code. Additionally, when using the `crashpad` backend, `zlib` is required. On Linux and macOS, `libcurl` is a prerequisite. When GPU information gathering is enabled (`SENTRY_WITH_GPU_INFO=ON`), the **Vulkan** is required for cross-platform GPU detection. For more details, check out the [contribution guide](./CONTRIBUTING.md).

Building the Breakpad and Crashpad backends requires a `C++17` compatible compiler.

Expand Down Expand Up @@ -186,8 +188,8 @@ specifying the `SDKROOT`:
$ export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
```

If you build on macOS using _CMake 4_, then you _must_ specify the `SDKROOT`, because
[CMake 4 defaults to an empty `CMAKE_OSX_SYSROOT`](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html),
If you build on macOS using _CMake 4_, then you _must_ specify the `SDKROOT`, because
[CMake 4 defaults to an empty `CMAKE_OSX_SYSROOT`](https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_SYSROOT.html),
which could lead to inconsistent include paths when CMake tries to gather the `sysroot` later in the build.

### Compile-Time Options
Expand Down Expand Up @@ -299,20 +301,27 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`.
tuning the thread stack guarantee parameters. Warnings and errors in the process of setting thread stack guarantees
will always be logged.

- `SENTRY_WITH_GPU_INFO` (Default: `ON` on Windows, macOS, and Linux, otherwise `OFF`):
Enables GPU information collection and reporting. When enabled, the SDK will attempt to gather GPU details such as
GPU name, vendor, memory size, and driver version, which are included in event contexts. The implementation uses
the Vulkan API for cross-platform GPU detection. **Requires the Vulkan SDK to be installed** - if not found,
GPU information gathering will be automatically disabled during build. Setting this to `OFF` disables GPU
information collection entirely, which can reduce dependencies and binary size.

### Support Matrix

| Feature | Windows | macOS | Linux | Android | iOS |
|------------|---------|-------|-------|---------|-------|
| Transports | | | | | |
| - curl | | ☑ | ☑ | (✓)*** | |
| - winhttp | ☑ | | | | |
| - none | ✓ | ✓ | ✓ | ☑ | ☑ |
| | | | | | |
| Backends | | | | | |
| - crashpad | ☑ | ☑ | ☑ | | |
| - breakpad | ✓ | ✓ | ✓ | (✓)** | (✓)** |
| - inproc | ✓ | (✓)* | ✓ | ☑ | |
| - none | ✓ | ✓ | ✓ | ✓ | |
| Feature | Windows | macOS | Linux | Android | iOS |
| ---------- | ------- | ----- | ----- | --------- | ------- |
| Transports | | | | | |
| - curl | | ☑ | ☑ | (✓)\*\*\* | |
| - winhttp | ☑ | | | | |
| - none | ✓ | ✓ | ✓ | ☑ | ☑ |
| | | | | | |
| Backends | | | | | |
| - crashpad | ☑ | ☑ | ☑ | | |
| - breakpad | ✓ | ✓ | ✓ | (✓)\*\* | (✓)\*\* |
| - inproc | ✓ | (✓)\* | ✓ | ☑ | |
| - none | ✓ | ✓ | ✓ | ✓ | |

Legend:

Expand Down
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,4 @@ target_include_directories(breakpad_client
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
)

1 change: 1 addition & 0 deletions external/vulkan-headers
Submodule vulkan-headers added at 2efaa5
27 changes: 27 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,30 @@ else()
screenshot/sentry_screenshot_none.c
)
endif()

# gpu
if(SENTRY_WITH_GPU_INFO)
target_compile_definitions(sentry PRIVATE SENTRY_WITH_GPU_INFO)
sentry_target_sources_cwd(sentry
sentry_gpu.h
gpu/sentry_gpu_common.c
)

if(WIN32 OR (APPLE AND NOT IOS) OR LINUX)
sentry_target_sources_cwd(sentry
gpu/sentry_gpu_vulkan.h
gpu/sentry_gpu_vulkan.c
)
else()
# For platforms that do not support GPU info gathering, we provide a no-op implementation
sentry_target_sources_cwd(sentry
gpu/sentry_gpu_none.c
)
endif()
else()
sentry_target_sources_cwd(sentry
sentry_gpu.h
gpu/sentry_gpu_common.c
gpu/sentry_gpu_none.c
)
endif()
Loading
Loading