• Stars
    star
    354
  • Rank 115,836 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sentry SDK for C, C++ and native applications.

Conan Center nixpkgs unstable vcpkg

Sentry

Official Sentry SDK for C/C++

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.

Note: This SDK is being actively developed and still in Beta. We recommend to check for updates regularly to benefit from latest features and bug fixes. Please see Known Limitations.

Resources

Table of Contents

Downloads

The SDK can be downloaded from the Releases page, which also lists the changelog of every version.

What is Inside

The SDK bundle contains the following folders:

  • external: These are external projects which are consumed via git submodules.
  • include: Contains the Sentry header file. Set the include path to this directory or copy the header file to your source tree so that it is available during the build.
  • src: Sources of the Sentry SDK required for building.

Platform and Feature Support

The SDK currently supports and is tested on the following OS/Compiler variations:

  • 64bit Linux with GCC 9
  • 64bit Linux with clang 9
  • 32bit Linux with GCC 7 (cross compiled from 64bit host)
  • 32bit Windows with MSVC 2019
  • 64bit Windows with MSVC 2022
  • macOS Catalina with most recent Compiler toolchain
  • Android API29 built by NDK21 toolchain
  • Android API16 built by NDK19 toolchain

Additionally, the SDK should support the following platforms, although they are not automatically tested, so breakage may occur:

  • Windows Versions lower than Windows 10 / Windows Server 2016
  • Windows builds with the MSYS2 + MinGW + Clang toolchain

The SDK supports different features on the target platform:

  • HTTP Transport is currently only supported on Windows and platforms that have the curl library available. On other platforms, library users need to implement their own transport, based on the function transport API.
  • Crashpad Backend is currently only supported on Linux, Windows and macOS.
  • Client-side stackwalking is currently only supported on Linux, Windows, and macOS.

Building and Installation

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.

Building the Crashpad Backend requires a C++14 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.dSYM

Please 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.

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 :

  • Create an environement variable MINGW_ROOT (ex : C:/msys64/mingw64)
  • Run from mingw64.exe : pacman -S --needed - < ./toolchains/msys2-mingw64-pkglist.txt
  • Build as :
# 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 build

MacOS:

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 arm64

Make 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)

Compile-Time Options

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_EXPORT_SYMBOLS (Default: ON): By default, sentry exposes all symbols in the dynamic symbol table. You might want to disable it in case the program intends to dlopen third-party shared libraries and avoid symbol collisions.

  • 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 has an effect on 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:

    • 5.1 (Windows XP)
    • 5.2 (Windows XP 64-bit / Server 2003 / Server 2003 R2)
    • 6.0 (Windows Vista / Server 2008)
    • 6.1 (Windows 7 / Server 2008 R2)
    • 6.2 (Windows 8.0 / Server 2012)
    • 6.3 (Windows 8.1 / Server 2012 R2)
    • 10 (Windows 10 / Server 2016 / Server 2019)

    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.

    • curl: This uses the curl library for HTTP handling. This requires that the development version of the package is available.
    • winhttp: This uses the winhttp system library, is only supported on Windows and is the default there.
    • none: Do not build any http transport. This should be used if users want to handle uploads themselves
  • SENTRY_BACKEND (Default: depending on platform): Sentry can use different backends depending on platform.

    • crashpad: This uses the out-of-process crashpad handler. It is currently only supported on Desktop OSs, and used as the default on Windows and macOS.
    • breakpad: This uses the in-process breakpad handler. It is currently only supported on Desktop OSs, and used as the default on Linux.
    • inproc: A small in-process handler which is supported on all platforms, and is used as default on Android.
    • none: This builds sentry-native without a backend, so it does not handle crashes at all. It is primarily used for tests.
  • SENTRY_INTEGRATION_QT (Default: OFF): Builds the Qt integration, which turns Qt log messages into breadcrumbs.

  • SENTRY_BREAKPAD_SYSTEM / SENTRY_CRASHPAD_SYSTEM (Default: OFF): This instructs the build system to use system-installed breakpad or crashpad libraries instead of using the in-tree version. This is generally not recommended for crashpad, as sentry uses a patched version that has attachment support. This is being worked on upstream as well, and a future version might work with an unmodified crashpad version as well.

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

Legend:

  • ☑ default

  • ✓ supported

  • unsupported

  • SENTRY_FOLDER (Default: not defined): Sets the sentry-native projects folder name for generators which 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, make sure to also define the same value using target_compile_definitions() on your own targets that include sentry.h.

Build Targets

  • sentry: This is the main library and the only default build target.
  • crashpad_handler: When configured with the crashpad backend, this is the out of process crash handler, which will need to be installed along with the projects executable.
  • sentry_test_unit: These are the main unit-tests, which are conveniently built also by the toplevel makefile.
  • sentry_example: This is a small example program highlighting the API, which can be controlled via command-line parameters, and is also used for integration tests.

Runtime Configuration

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:

  • sentry_options_set_database_path: Sentry needs to persist some cache data across application restarts, especially for proper handling of release health sessions. It is recommended to set an explicit absolute path corresponding to the applications cache directory (equivalent to AppData/Local on Windows, and XDG_CACHE_HOME on Linux). Sentry should be given its own directory which is not shared with other application data, as the SDK will enumerate and possibly delete files in that directory. An example might be $XDG_CACHE_HOME/your-app/sentry. When not set explicitly, sentry will create and use the .sentry-native directory inside of the current working directory.
  • sentry_options_set_handler_path: When using the crashpad backend, sentry will look for a crashpad_handler executable in the same directory as the running executable. It is recommended to set this as an explicit absolute path based on the applications install location.
  • sentry_options_set_release: Some features in sentry, including release health, need to have a release version set. This corresponds to the application’s version and needs to be set explicitly. See Releases for more information.

Known Limitations

  • The crashpad backend on macOS currently has no support for notifying the crashing process, and can thus not properly terminate sessions or call the registered before_send or on_crash hook. It will also lose any events that have been queued for sending at time of crash.
  • The Crashpad backend on Windows supports fast-fail crashes, which bypass SEH (Structured Exception Handling) primarily for security reasons. sentry-native registers a WER (Windows Error Reporting) module, which signals the crashpad_handler to send a minidump when a fast-fail crash occurs But since this process bypasses SEH, the application local exception handler is no longer invoked, which also means that for these kinds of crashes, before_send and on_crash will not be invoked before sending the minidump and thus have no effect.

Development

Please see the contribution guide.

More Repositories

1

sentry

Developer-first error tracking and performance monitoring
Python
36,992
star
2

sentry-javascript

Official Sentry SDKs for JavaScript
TypeScript
7,600
star
3

self-hosted

Sentry, feature-complete and packaged up for low-volume deployments and proofs-of-concept
Shell
7,130
star
4

responses

A utility for mocking out the Python Requests library.
Python
4,030
star
5

sentry-php

The official PHP SDK for Sentry (sentry.io)
PHP
1,779
star
6

raven-python

Raven is the legacy Python client for Sentry (getsentry.com) — replaced by sentry-python
Python
1,678
star
7

sentry-python

The official Python SDK for Sentry.io
Python
1,533
star
8

sentry-react-native

Official Sentry SDK for React-Native
TypeScript
1,509
star
9

sentry-laravel

The official Laravel SDK for Sentry (sentry.io)
PHP
1,157
star
10

sentry-java

A Sentry SDK for Java, Android and other JVM languages.
Kotlin
1,097
star
11

sentry-ruby

Sentry SDK for Ruby
Ruby
909
star
12

sentry-go

The official Go SDK for Sentry (sentry.io)
Go
864
star
13

sentry-cli

A command line utility to work with Sentry.
Rust
833
star
14

milksnake

A setuptools/wheel/cffi extension to embed a binary data in wheels
Python
764
star
15

sentry-cocoa

The official Sentry SDK for iOS, tvOS, macOS, watchOS.
Objective-C
762
star
16

sentry-dart

Sentry SDK for Dart and Flutter
Dart
714
star
17

sentry-symfony

The official Symfony SDK for Sentry (sentry.io)
PHP
673
star
18

sentry-webpack-plugin

Repo moved to https://github.com/getsentry/sentry-javascript-bundler-plugins. Please open any issues/PRs there.
JavaScript
662
star
19

freight

Freight is a service which aims to make application deployments better.
Python
610
star
20

sentry-elixir

The official Elixir SDK for Sentry (sentry.io)
Elixir
597
star
21

raven-go

Sentry client in Go
Go
560
star
22

sentry-dotnet

Sentry SDK for .NET
C#
551
star
23

sentry-rust

Official Sentry SDK for Rust
Rust
515
star
24

raven-node

A standalone (Node.js) client for Sentry
JavaScript
457
star
25

symbolic

Stack trace symbolication library written in Rust
Rust
420
star
26

action-release

GitHub Action for creating a release on Sentry
TypeScript
410
star
27

sentry-kubernetes

Kubernetes event reporter for Sentry
Python
408
star
28

docker-sentry

Docker Official Image packaging for Sentry
Python
348
star
29

pdb

A parser for Microsoft PDB (Program Database) debugging information
Rust
342
star
30

symbolicator

Native Symbolication as a Service
Rust
328
star
31

sentry-docs

Sentry's documentation (and tools to build it)
MDX
313
star
32

rb

Routing and connection management for Redis in Python
Python
300
star
33

sentry-php-sdk

This is a meta package to ship sentry-php with a recommend http client.
298
star
34

spotlight

Your Universal Debug Toolbar
TypeScript
290
star
35

snuba

Search the seas for your lost treasure.
Python
272
star
36

relay

Sentry event forwarding and ingestion service.
Rust
246
star
37

raven-csharp

Superseded by: https://github.com/getsentry/sentry-dotnet
C#
232
star
38

sentry-electron

The official Sentry SDK for Electron
TypeScript
217
star
39

sentry-plugins

Official plugins for Sentry server
Python
212
star
40

zeus

WIP: A dashboard for CI
Python
209
star
41

rust-sourcemap

A library for rust that implements basic sourcemap handling
Rust
188
star
42

sentry-unity

Development of Sentry SDK for Unity
C#
187
star
43

action-github-app-token

Gets a GitHub auth token for a GitHub App installation
TypeScript
179
star
44

sentry-wizard

Sentry Project Setup Wizard
TypeScript
139
star
45

sentry-slack

DEPRECATED Slack integration for Sentry
Python
135
star
46

sentry-fastlane-plugin

Official fastlane plugin for Sentry
Ruby
131
star
47

sentry-android-gradle-plugin

Gradle plugin for Sentry Android. Upload proguard, debug files, and more.
Kotlin
130
star
48

action-git-diff-suggestions

This GitHub Action will take the current git changes and apply them as GitHub code review suggestions
TypeScript
122
star
49

craft

The universal Sentry release CLI 🚀
TypeScript
118
star
50

examples

Collection of all different kinds of Sentry SDKs and integrations
C#
118
star
51

sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
TypeScript
115
star
52

sentry-capacitor

The official Sentry SDK for Capacitor
TypeScript
114
star
53

sentry-kotlin-multiplatform

Sentry SDK for Kotlin Multiplatform
Kotlin
104
star
54

raven-objc

This SDK is deprecated. Use https://github.com/getsentry/sentry-cocoa
Objective-C
98
star
55

sentry-clj

Sentry SDK for Clojure
Clojure
98
star
56

sentry-jira

A Plugin for sentry that lets you create JIRA issues
Python
95
star
57

raven-aiohttp

An aiohttp transport for raven-python
Python
90
star
58

sentry-android

MOVED: https://github.com/getsentry/sentry-java
87
star
59

pytest-responses

py.test integration for responses
Python
83
star
60

sentry-github

A Sentry extension which integrates with GitHub.
Python
79
star
61

libsourcemap

DEPRECATED: Implements efficient sourcemap processing for Python in Rust
Rust
78
star
62

sentry-rrweb

Moved to: https://github.com/getsentry/sentry-javascript/tree/master/packages/replay#sentry-session-replay
TypeScript
73
star
63

sentry-unreal

Unreal Engine
C++
71
star
64

sentry-cordova

The official Sentry SDK for Cordova
TypeScript
68
star
65

sentry-dart-plugin

A Dart Build Plugin that uploads debug symbols for Android, iOS/macOS and source maps for Web to Sentry via sentry-cli
Dart
63
star
66

sourcemaps.io

Web-based Source Map validator
TypeScript
58
star
67

breakpad-tools

Prebuilt tools and examples to work with Breakpad's minidumps
Makefile
53
star
68

sentry-webhooks

An extension for Sentry which allows creation various web hooks.
Python
52
star
69

dotnet-assembly-alias

Tool to rename .NET assemblies and references
C#
50
star
70

sentry-netlify-build-plugin

The Sentry Netlify build plugin automatically notifies Sentry of new releases being deployed to your site.
JavaScript
45
star
71

develop

TypeScript
43
star
72

babel-gettext-extractor

A fork of babel-gettext-plugin that works with older versions of node and supports comment and location extraction
JavaScript
43
star
73

sentry-mobile-release-health-app

Sentry Mobile App
Dart
42
star
74

sentry-xamarin

Sentry for Xamarin Native and Xamarin.Forms
C#
41
star
75

raven-swift

This SDK is deprecated. Use https://github.com/getsentry/sentry-cocoa
40
star
76

pytest-sentry

Track flaky tests in Sentry
Python
39
star
77

sentry-auth-github

GitHub SSO provider for Sentry
Python
39
star
78

action-visual-snapshot

Save and compare your visual snapshots
TypeScript
38
star
79

sentry-fullstory

The Sentry-FullStory integration seamlessly integrates the Sentry and FullStory platforms.
TypeScript
37
star
80

sentry-phabricator

A Sentry extension which integrates with Phabricator
Python
36
star
81

platformicons

A platform and framework icon font.
TypeScript
36
star
82

arroyo

A library to build streaming applications that consume from and produce to Kafka.
Python
35
star
83

sentry-auth-google

Google Apps SSO provider for Sentry
Python
34
star
84

integration-platform-example

An example kanban application which explores the ways developers can build apps on Sentry's integration platform
TypeScript
32
star
85

unity

Unity SDK UPM package
Objective-C
31
star
86

vanguard

TypeScript
29
star
87

profiling-node

The code for this repo now lives in https://github.com/getsentry/sentry-javascript/tree/develop/packages/profiling-node
TypeScript
28
star
88

sentry-vscode

VSCode editor integration for Sentry
TypeScript
28
star
89

probot-report

Probot app that sends periodic reminder emails for outstanding PR reviews
JavaScript
28
star
90

hackweek-coda

A queue thing with a sprinkle of Italian
Python
27
star
91

sentry-replay

Moved to http://github.com/getsentry/sentry-javascript
TypeScript
27
star
92

symbol-collector

Clients and Server to collect system symbols.
C#
27
star
93

perl-raven

A perl sentry client
Perl
26
star
94

sentry_airflow

Airflow integration with Sentry (https://sentry.io)
Python
26
star
95

cloud-run-typescript-template

Template for Google Cloud Run (typescript)
JavaScript
24
star
96

symsynd

C++
23
star
97

sentry-relay-attic

A relay server for Sentry (https://getsentry.com)
Rust
23
star
98

freight-cli

A command line interface to Freight
Python
22
star
99

xds

xDS service for Envoy
Go
22
star
100

gib-potato

More Potato, more awesome 🥔
PHP
21
star