2
2
title : Native
3
3
---
4
4
5
+ {% capture __ alert_content -%}
6
+ Support for ` sentry-native ` is currently limited to the hosted version on
7
+ [ ` sentry.io ` ] ( https://sentry.io ) . The latest on-premise version of Sentry
8
+ (* 10.0* ) does not provide server-side support for events sent by
9
+ ` sentry-native ` . Full support for ` sentry-native ` will be made available to all
10
+ on-premise customers with the next release.
11
+ {%- endcapture -%}
12
+ {%- include components/alert.html
13
+ title="Sentry On-Premise"
14
+ content=__ alert_content
15
+ level="warning"
16
+ %}
17
+
5
18
The Sentry Native SDK is intended for C and C++. However, since it builds as a
6
19
dynamic library and exposes C-bindings, it can be used by any language that
7
20
supports interoperability with C, such as the Foreign Function Interface (FFI).
@@ -21,57 +34,37 @@ without using the Native SDK, see the following resources:
21
34
22
35
## Integrating the SDK
23
36
24
- The Native SDK currently supports ** Windows, macOS and Linux** . There are three
25
- distribution to choose from:
26
-
27
- | Standalone | With Breakpad | With Crashpad |
28
- | :----------------: | :-------------: | :-------------: |
29
- | Custom Messages | Custom Messages | Custom Messages |
30
- | Custom Errors | Custom Errors | Custom Errors |
31
- | Breadcrumbs | Breadcrumbs | Breadcrumbs |
32
- | _ Stack Traces* _ | Stack Traces | Stack Traces |
33
- | _ Capture Crashes* _ | Capture Crashes | Capture Crashes |
34
- | --- | Minidumps | Minidumps |
35
- | --- | Attachments | Attachments |
36
-
37
- \* _ Adding stack traces and capturing application crashes requires you to add an
38
- unwind library and hook into signal handlers of your process. The Standalone
39
- distribution currently does not contain integrations that perform this
40
- automatically._
37
+ The Native SDK currently supports ** Windows, macOS, Linux and Android** .
41
38
42
39
### Building the SDK
43
40
44
41
To build the SDK, download the latest release of the SDK from the [ Releases
45
- page] ( https://github.com/getsentry/sentry-native/releases ) . For each supported
46
- platform, there is a ` gen_* ` subfolder that contains build files:
47
-
48
- ** Windows**
49
-
50
- : ` gen_windows ` contains a Microsoft Visual Studio 2017 solution. Open the
51
- solution and add your projects or copy the projects to an existing solution.
52
- Each project supports a debug and release configuration and includes all
53
- sources required for building.
54
-
55
- ** Linux and macOS**
56
-
57
- : ` gen_linux ` and ` gen_macos ` contain Makefiles that can be used to produce
58
- dynamic libraries. Run ` make help ` to see an overview of the available
59
- configurations and target. There are debug and release configurations, that
60
- can be toggled when building:
61
-
62
- ``` bash
63
- make config=release sentry
64
- ```
65
-
66
- There are multiple available targets to build:
42
+ page] ( https://github.com/getsentry/sentry-native/releases ) .
43
+ The SDK is managed as a [ CMake] project, which additionally supports a number
44
+ of configuration options, such as the backend to use.
45
+
46
+ ` CMake ` can be used for example like this (on macOS):
47
+
48
+ ``` sh
49
+ # configure the cmake build into the `build` directory, with crashpad (on macOS)
50
+ $ cmake -B build -D SENTRY_BACKEND=crashpad
51
+ # build the project
52
+ $ cmake --build build --parallel
53
+ # install the resulting artifacts into a specific prefix
54
+ $ cmake --install build --prefix install
55
+ # which will result in the following (on macOS):
56
+ $ exa --tree install
57
+ install
58
+ ├── bin
59
+ │ └── crashpad_handler
60
+ ├── include
61
+ │ └── sentry.h
62
+ └── lib
63
+ ├── libsentry.dylib
64
+ └── libsentry.dylib.dSYM
65
+ ```
67
66
68
- - ` sentry ` : Builds the Native SDK built as a dynamic library.
69
- - ` sentry_breakpad ` : Builds the Native SDK with Google Breakpad as a dynamic
70
- library.
71
- - ` sentry_crashpad ` : Builds the Native SDK with Google Crashpad as a dynamic
72
- library.
73
- - ` crashpad_* ` : Builds crashpad utilities. To run the Crashpad distribution of
74
- the SDK, you must build ` crashpad_handler ` and ship it with your application.
67
+ [ cmake ] : https://cmake.org/cmake/help/latest/
75
68
76
69
### Connecting the SDK to Sentry
77
70
@@ -365,11 +358,11 @@ transport depends on the target platform:
365
358
366
359
- ** Linux** : Curl
367
360
- ** macOS** : Curl
368
- - ** Windows** : WinHTTP
369
361
370
362
To specify a custom transport, use the ` sentry_options_set_transport ` function
371
- and supply a transport that conforms to the ` sentry_transport_function_t `
372
- signature:
363
+ and supply a transport that implements the ` sentry_transport_t ` interface.
364
+ To simplify using a single function, one might use the
365
+ ` sentry_new_function_transport ` function:
373
366
374
367
``` c
375
368
#include < sentry.h>
@@ -387,7 +380,8 @@ int main(void) {
387
380
void * transport_data = 0;
388
381
389
382
sentry_options_t * options = sentry_options_new();
390
- sentry_options_set_transport(options, custom_transport, transport_data);
383
+ sentry_options_set_transport(options,
384
+ sentry_new_function_transport(custom_transport, transport_data));
391
385
sentry_init(options);
392
386
393
387
/* ... * /
@@ -402,38 +396,14 @@ background thread or thread pool to avoid blocking execution.
402
396
403
397
*Integrations* extend the functionality of the SDK for some common frameworks
404
398
and libraries. Similar to plugins, they extend the functionality of the Sentry
405
- SDK. The Native SDK comes in two additional distributions that include
406
- integrations into the Breakpad and Crashpad libraries, respectively.
407
-
408
- ### Google Breakpad
399
+ SDK.
409
400
410
- [Breakpad](https://chromium.googlesource.com/breakpad/breakpad/) is an
411
- open-source multiplatform crash reporting system written in C++ by Google and
412
- the predecessor of Crashpad. It supports macOS, Windows, and Linux, and features
413
- an uploader to submit minidumps to a configured URL right when the process
414
- crashes.
415
-
416
- To use the Breakpad integration with the Native SDK, build and link the
417
- `sentry_breakpad` dynamic library. Then, configure a path at which Breakpad can
418
- store its database. This location temporarily hosts Minidumps before they are
419
- uploaded to Sentry.
420
-
421
- ```c
422
- sentry_options_t *options = sentry_options_new();
423
- sentry_options_set_database_path(options, "sentry-db");
424
- sentry_init(options);
425
- ```
401
+ The Native SDK can use different backends that are responsible to capture
402
+ crashes. The backend is configured at build-time, using the `SENTRY_BACKEND`
403
+ CMake option.
426
404
427
- {% capture __ alert_content -%}
428
- Breakpad on macOS has been deprecated. If you are setting up a new project,
429
- consider to use the [ Crashpad distribution] ( #google-crashpad ) instead. The
430
- Sentry SDK is subject to limitations of Breakpad.
431
- {%- endcapture -%}
432
- {%- include components/alert.html
433
- title="Warning"
434
- content=__ alert_content
435
- level="warning"
436
- %}
405
+ The `crashpad` backend is used by default on Windows and macOS, whereas Linux
406
+ and Android use the `inproc` in-process backend by default.
437
407
438
408
### Google Crashpad
439
409
@@ -442,51 +412,43 @@ is an open-source multiplatform crash reporting system written in C++ by Google.
442
412
It supports macOS, Windows, and Linux (limited), and features an uploader to
443
413
submit minidumps to a configured URL right when the process crashes.
444
414
445
- To use the Crashpad integration with the Native SDK, build and link the
446
- ` sentry_crashpad ` dynamic library. Additonally, build the standalone
447
- ` crashpad_handler ` application. Then, configure a path at which Crashpad can
448
- store its database. This location temporarily hosts Minidumps before they are
449
- uploaded to Sentry.
415
+ To use the Crashpad backend with the Native SDK, configure the CMake build
416
+ with the `SENTRY_BACKEND=crashpad` option. This will automatically create a
417
+ `crashpad_handler` executable alongside the `sentry` library.
418
+
419
+ ```sh
420
+ $ cmake -B build -D SENTRY_BACKEND=crashpad
421
+ ```
422
+
423
+ The SDK will automatically look for a ` crashpad_handler ` executable in the same
424
+ directory as the running application. It will also use the ` .sentry-native `
425
+ directory as its database by default, relative to the current working directory
426
+ of your application.
427
+ This location temporarily hosts Minidumps before they are uploaded to Sentry.
428
+
429
+ Both of these paths can be customized like this:
450
430
451
431
``` c
452
432
sentry_options_t *options = sentry_options_new();
453
433
sentry_options_set_handler_path (options, "path/to/crashpad_handler");
454
- sentry_options_set_database_path(options, "sentry-db");
434
+ sentry_options_set_database_path(options, "sentry-db-directory ");
455
435
sentry_init(options);
456
436
```
457
437
458
438
The crashpad handler executable must be shipped alongside your application so
459
439
that it can be launched when initializing the SDK. The path is evaluated
460
440
relative to the current working directory at runtime.
461
441
462
- {% capture __alert_content -%}
463
- We do not recommend to run Crashpad on Linux as development of the Crashpad
464
- library for Linux has not been completed. The Sentry SDK is subject to
465
- limitations of Crashpad, which on Linux include:
466
-
467
- - No support for HTTPs uploads. Crash reports can only be uploaded to Sentry
468
- using insecure HTTP connections.
469
- - Limited crash handler support. In some cases, the crash handler may be
470
- unstable or not capture the process state correctly.
471
-
472
- Consider to use the [Breakpad distribution](#google-breakpad) instead.
473
- {%- endcapture -%}
474
- {%- include components/alert.html
475
- title="Warning"
476
- content=__alert_content
477
- level="warning"
478
- %}
479
-
480
- ### Event Attachments (Preview)
442
+ ## Event Attachments (Preview)
481
443
482
444
Besides the Minidump file, Sentry can optionally store additional files uploaded
483
445
in the same request, such as log files.
484
446
485
447
{% include platforms/event-attachments.md %}
486
448
487
- Attachments require the _Crashpad_ distribution of the SDK. To add an
488
- attachment, the path to the file has to be configured when initializing the SDK.
489
- It will monitor the file and add it to any Minidump that is sent to Sentry:
449
+ To add an attachment, the path to the file has to be configured when
450
+ initializing the SDK. It will monitor the file and upload it along any event
451
+ or crash that is sent to Sentry:
490
452
491
453
```c
492
454
sentry_options_add_attachment(options, "log", "/var/server.log");
0 commit comments