| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The Sentry Native SDK is an error and crash reporting client for native applications, optimized for C and C++. Sentry allows to add tags, breadcrumbs and arbitrary custom context to enrich error reports. Supports Sentry 20.6.0 and later.
Using the sentry-native SDK in a standalone use case is currently an experimental feature. The SDK’s primary function is to fuel our other SDKs, like sentry-java or sentry-unreal. Support from our side is best effort and we do what we can to respond to issues in a timely fashion, but please understand if we won’t be able to address your issues or feature suggestions.
The SDK can be downloaded from the Releases page, which also lists the changelog of every version. We recommend using our release packages, but if you want to use this repo directly, please follow the contribution guide to understand the setup better.
The SDK bundle contains the following folders:
The SDK currently supports and is tested on the following OS/Compiler variations:
Additionally, the SDK should support the following platforms, although they are not automatically tested, so breakage may occur:
The SDK supports different features on the target platform:
The SDK is developed and shipped as a CMake project. CMake will pick an appropriate compiler and buildsystem toolchain automatically 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.
Building the Breakpad and Crashpad backends requires a C++17 compatible compiler.
Build example:
# configure the cmake build into the `build` directory, with crashpad (on macOS)
$ cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
# build the project
$ cmake --build build --parallel
# install the resulting artifacts into a specific prefix (use the correct config on windows)
$ cmake --install build --prefix install --config RelWithDebInfo
# which will result in the following (on macOS):
$ exa --tree install
install
├── bin
│ └── crashpad_handler
├── include
│ └── sentry.h
└── lib
├── cmake
│ └── sentry
├── libsentry.dylib
└── libsentry.dylib.dSYMPlease refer to the CMake Manual for more details.
Android:
The CMake project can also be configured to correctly work with the Android NDK, see the dedicated CMake Guide for details on how to integrate it with Gradle or use it on the command line.
The ndk folder provides Gradle project which adds a Java JNI layer for Android, suitable for accessing the sentry-native SDK from Java. See the NDK Readme for more details about this topic.
MinGW:
64-bits is the only platform supported for now. LLVM + Clang are mandatory here : they are required to generate .pdb files, used by Crashpad for the report generation.
For your application to generate the appropriate .pdb output, you need to activate CodeView file format generation on your application target. To do so, update your own CMakeLists.txt with something like target_compile_options(${yourApplicationTarget} PRIVATE -gcodeview).
If you use a MSYS2 environement to compile with MinGW, make sure to :
# Configure with Ninja as generator and use the MSYS2 toolchain file
$ cmake -GNinja -Bbuild -H. -DCMAKE_TOOLCHAIN_FILE=toolchains/msys2.cmake
# build with Ninja
$ ninja -C buildMacOS:
Building universal binaries/libraries is possible out of the box when using the CMAKE_OSX_ARCHITECTURES define, both with the Xcode generator as well as the default generator:
# using xcode generator:
$ cmake -B xcodebuild -GXcode -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
$ xcodebuild build -project xcodebuild/Sentry-Native.xcodeproj
$ lipo -info xcodebuild/Debug/libsentry.dylib
Architectures in the fat file: xcodebuild/Debug/libsentry.dylib are: x86_64 arm64
# using default generator:
$ cmake -B defaultbuild -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
$ cmake --build defaultbuild --parallel
$ lipo -info defaultbuild/libsentry.dylib
Architectures in the fat file: defaultbuild/libsentry.dylib are: x86_64 arm64Make sure that MacOSX SDK 11 or later is used. It is possible that this requires manually overriding the SDKROOT:
$ export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)The following options can be set when running the cmake generator, for example using cmake -D BUILD_SHARED_LIBS=OFF ...
SENTRY_BUILD_SHARED_LIBS (Default: ON): By default, sentry is built as a shared library. Setting this option to OFF will build sentry as a static library instead. If sentry is used as a subdirectory of another project, the value BUILD_SHARED_LIBS will be inherited by default.
When using sentry as a static library, make sure to #define SENTRY_BUILD_STATIC 1 before including the sentry header.
SENTRY_PIC (Default: ON): By default, sentry is built as a position-independent library.
SENTRY_BUILD_RUNTIMESTATIC (Default: OFF): Enables linking with the static MSVC runtime. Has no effect if the compiler is not MSVC.
SENTRY_LINK_PTHREAD (Default: ON): Links platform threads library like pthread on UNIX targets.
SENTRY_BUILD_FORCE32 (Default: OFF): Forces cross-compilation from 64-bit host to 32-bit target. Only affects Linux.
CMAKE_SYSTEM_VERSION (Default: depending on Windows SDK version): Sets up a minimal version of Windows where sentry-native can be guaranteed to run. Possible values:
For Windows versions below than 6.0 it is also necessary to use XP toolchain in case of MSVC compiler (pass -T v141_xp to CMake command line).
SENTRY_TRANSPORT (Default: depending on platform): Sentry can use different http libraries to send reports to the server.
SENTRY_BACKEND (Default: depending on platform): Sentry can use different backends depending on platform.
SENTRY_INTEGRATION_QT (Default: OFF): Builds the Qt integration, which turns Qt log messages into breadcrumbs.
SENTRY_BREAKPAD_SYSTEM (Default: OFF): This instructs the build system to use system-installed breakpad libraries instead of the in-tree version.
SENTRY_TRANSPORT_COMPRESSION (Default: OFF): Adds Gzip transport compression. Requires zlib.
SENTRY_FOLDER (Default: not defined): Sets the sentry-native projects folder name for generators that support project hierarchy (like Microsoft Visual Studio). To use this feature, you need to enable hierarchy via USE_FOLDERS property
CRASHPAD_ENABLE_STACKTRACE (Default: OFF): This enables client-side stackwalking when using the crashpad backend. Stack unwinding will happen on the client's machine and the result will be submitted to Sentry attached to the generated minidump. Note that this feature is still experimental.
SENTRY_SDK_NAME (Default: sentry.native or sentry.native.android): Sets the SDK name that should be included in the reported events. If you're overriding this, also define the same value using target_compile_definitions() on your own targets that include sentry.h.
SENTRY_HANDLER_STACK_SIZE (Default: 64): This specifies the size in KiB of the stack reserved for the crash handler (including hooks like on_crash and before_send) on Windows, Linux and the inproc backend in macOS. Reserving the stack is necessary in case of a stack-overflow, where the handler could otherwise no longer execute. This parameter allows users to specify their target stack size in KiB, because some applications might require a different value from our default. This value can be as small as 16KiB (on crashpad and breakpad) for handlers to work, but we recommend 32KiB as the lower bound on 64-bit systems. The value should be a multiple of the page size.
SENTRY_THREAD_STACK_GUARANTEE_FACTOR (Default: 10, only for Windows): Defines the factor by which the thread's stack reserve must be bigger than the specified guarantee for the handler. Example: if the SENTRY_HANDLER_STACK_SIZE is defined as 64KiB then the thread's stack reserve must at least have a size of 640KiB.
SENTRY_THREAD_STACK_GUARANTEE_AUTO_INIT (Default: ON, only for Windows): Ensures that all threads created after the SDK's initialization will be configured to use the SENTRY_HANDLER_STACK_SIZE as its handler stack guarantee.
Note: assigning this to all threads only works when building the SDK as a shared library. If you build it as a static library and this option is enabled, only the sentry_init() thread will have a stack guarantee for the handler (other threads must be manually initialized via sentry_set_thread_stack_guarantee()).
SENTRY_THREAD_STACK_GUARANTEE_VERBOSE_LOG (Default: OFF, only for Windows): Adds info level logs for every successfully set thread stack guarantee. This is OFF by default, because depending on the number of threads used (by all dependencies) this could flood the logs. But it will be helpful to anyone tuning the thread stack guarantee parameters. Warnings and errors in the process of setting thread stack guarantees will always be logged.
| Feature | Windows | macOS | Linux | Android | iOS |
|---|---|---|---|---|---|
| Transports | |||||
| - curl | ☑ | ☑ | (✓)*** | ||
| - winhttp | ☑ | ||||
| - none | ✓ | ✓ | ✓ | ☑ | ☑ |
| Backends | |||||
| - crashpad | ☑ | ☑ | ☑ | ||
| - breakpad | ✓ | ✓ | ✓ | (✓)** | (✓)** |
| - inproc | ✓ | (✓)* | ✓ | ☑ | |
| - none | ✓ | ✓ | ✓ | ✓ |
Legend:
In addition to platform support, the "Advanced Usage" section of the SDK docs now describes the tradeoffs involved in choosing a suitable backend for a particular use case.
A minimal working example looks like this. For a more elaborate example see the example.c file which is also used to run sentries integration tests.
sentry_options_t *options = sentry_options_new();
sentry_options_set_dsn(options, "https://YOUR_KEY@oORG_ID.ingest.sentry.io/PROJECT_ID");
sentry_init(options);
// your application code …
sentry_close();Other important configuration options include:
The SDK is automatically benchmarked in the CI on every push to the master branch. The benchmarks cover the following scenarios:
The benchmarks are run on Windows, macOS, and Linux, and the results are published on GitHub Pages. If you want to run benchmarks locally, follow the instructions in the contribution guide.
Please see the contribution guide.
| Back | FazBrowse Home | New Git URL |