Skip to content
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c65001f
feat: Implement the GPU Info gathering within the Native SDK
mujacica Aug 11, 2025
fab50a7
Fix file format
mujacica Aug 11, 2025
e1854e3
Add changelog entry
mujacica Aug 11, 2025
dc72b0e
Extend README with new SENTRY_WITH_GPU_INFO option
mujacica Aug 11, 2025
093d100
Skip apple silicon tests on non darwin platforms
mujacica Aug 11, 2025
c3fc125
Enable GPU Info per default to test cmake on github runners
mujacica Aug 11, 2025
de8516a
Resolve compiler issues on Linux
mujacica Aug 11, 2025
1bf85b3
Fix Windows builds
mujacica Aug 11, 2025
cfb142b
Fix failing tests
mujacica Aug 11, 2025
63285cd
Fix IOS builds
mujacica Aug 11, 2025
0be6800
Fix remaining failing tests
mujacica Aug 11, 2025
6d5d211
Fix format
mujacica Aug 11, 2025
75436f6
Keep GPU Info disabled by default
mujacica Aug 11, 2025
b337dc9
Fix CMake for all platforms
mujacica Aug 11, 2025
324aa86
Fix comments, and findings from testing
mujacica Aug 12, 2025
15cbc84
Further testing fixes
mujacica Aug 12, 2025
90e801e
Fix failing test
mujacica Aug 12, 2025
a56f85d
Use Sentry wstr function instead of custom implementation
mujacica Aug 12, 2025
4c9023f
Simplify Unix implementation and CMakeLists
mujacica Aug 14, 2025
a5bc079
Add nvml support, add multi-gpu support
mujacica Aug 14, 2025
18edccc
Fix linux complier warnings
mujacica Aug 14, 2025
86ba123
Fix file formats
mujacica Aug 14, 2025
abd63a8
Fix build issues after refactoring
mujacica Aug 14, 2025
47e0626
Fix file formats
mujacica Aug 14, 2025
b08c744
Use Vulkan for GPU info with multi-platform support
mujacica Aug 17, 2025
fa3b147
Fix file format
mujacica Aug 17, 2025
8db38fb
Fix None implementation
mujacica Aug 17, 2025
d362fc9
Don't use singleton
mujacica Aug 17, 2025
41a291e
Fix format
mujacica Aug 17, 2025
4454b4d
Simplify driver version, remove test script
mujacica Aug 20, 2025
dea2782
Use Vulkan headers, dynamically load
mujacica Aug 20, 2025
9491418
Fix format
mujacica Aug 20, 2025
13d1561
Fix CMake to include headers only
mujacica Aug 20, 2025
0f8e7fa
Fix 32-bit builds
mujacica Aug 20, 2025
b8f3072
Fix GPU test pritnf formats
mujacica Aug 20, 2025
966dc77
Fix format
mujacica Aug 20, 2025
7ef5f42
One more test fix
mujacica Aug 20, 2025
7d1ce41
Fix format
mujacica Aug 20, 2025
0c22332
Fix cursor comment
mujacica Oct 2, 2025
924aef3
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
641744d
Update src/gpu/sentry_gpu_vulkan.c
mujacica Oct 9, 2025
921f817
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
150e542
Update README.md
mujacica Oct 9, 2025
899d2fb
Fix PR Comments
mujacica Oct 9, 2025
6b37c65
Update tests/unit/test_gpu.c
mujacica Oct 9, 2025
284dfd0
Further fixes
mujacica Oct 9, 2025
d610338
Fix memory units
mujacica Oct 9, 2025
022ec51
Fix docs
mujacica Oct 9, 2025
6b4e712
Fix more comments
mujacica Oct 9, 2025
7de05b4
Fix Mac compatibility
mujacica Oct 9, 2025
bb12c54
Fix Vendor ID's
mujacica Oct 13, 2025
f7eef2b
Fix memory size to MB
mujacica Oct 13, 2025
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 @@ -196,7 +196,7 @@ jobs:
if: ${{ runner.os == 'Linux' && matrix.os != 'ubuntu-22.04' && !env['TEST_X86'] && !matrix.container }}
run: |
sudo apt update
sudo apt install cmake clang-19 llvm g++-12 valgrind zlib1g-dev libcurl4-openssl-dev
sudo apt install cmake clang-19 llvm g++-12 valgrind zlib1g-dev libcurl4-openssl-dev libvulkan-dev
# Install kcov from source
sudo apt-get install binutils-dev libssl-dev libelf-dev libstdc++-12-dev libdw-dev libiberty-dev
git clone https://github.com/SimonKagstrom/kcov.git
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 @@ -6,6 +6,10 @@

- Use proper SDK name determination for structured logs `sdk.name` attribute. ([#1399](https://github.com/getsentry/sentry-native/pull/1399))

**Features**:

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

## 0.11.2

**Fixes**:
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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 @@ -563,6 +585,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 @@ -198,3 +198,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