For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/real_user_monitoring/application_monitoring/cpp/error_tracking.md. A documentation index is available at /llms.txt.
This product is not supported for your selected Datadog site. ().

Overview

Enable crash reporting for your C and C++ applications to surface, triage, and debug crashes in Error Tracking. On Linux and macOS, the C++ SDK captures unhandled signals (such as SIGSEGV and SIGABRT). On Windows, it captures unhandled structured exceptions. In both cases, the SDK stores a crash report with the crashing thread’s stack trace locally for upload on the next application launch.

Crash reports appear in Error Tracking and are deduplicated and grouped into issues to help you prioritize and resolve the most impactful crashes.

Setup

If you have not set up the RUM C++ SDK yet, follow the in-app setup instructions or see the RUM C++ setup documentation.

To enable crash reporting, register the CrashReporting feature as early as possible after creating your SDK core, before calling Start().

#include "datadog.hpp"

datadog::CoreConfig config("<client_token>", "<service_name>", "<environment>");
auto core = datadog::Core::Create(config, datadog::TrackingConsent::Granted);

// Register crash reporting
auto crash_reporting = datadog::CrashReporting::Register(core);

// Register RUM
datadog::RumConfig rum_config("<rum_application_id>");
auto rum = datadog::Rum::Register(core, rum_config);

// Start the core
core->Start();
#include "datadog.h"

dd_core_config_t config;
dd_core_config_init(&config, "<client_token>", "<service_name>", "<environment>");
dd_core_t* core = dd_core_create(&config, DD_TRACKING_CONSENT_GRANTED);

/* Register crash reporting */
dd_crash_reporting_t* crash_reporting = dd_crash_reporting_init(core, NULL);

/* Register RUM */
dd_rum_config_t rum_config;
dd_rum_config_init(&rum_config, "<rum_application_id>");
dd_rum_t* rum = dd_rum_init(core, &rum_config);

dd_core_start(core);

The SDK captures crashes automatically once registered.

Crash reporting modes

The crash reporting mode is set at build time using the DD_CRASH_MODE CMake variable.

In-process (default)

The default mode, inprocess, captures the stack trace of the crashing thread and stores it locally for upload on the next launch:

set(DD_CRASH_MODE "inprocess" CACHE STRING "")

For accurate stack traces on Linux and macOS, compile your application with -fno-omit-frame-pointer. The in-process handler walks the call stack using frame pointers, and without this flag, stack traces may be incomplete or inaccurate.

Disabled (noop)

To disable crash reporting entirely without removing the API calls from your code, set DD_CRASH_MODE to noop:

set(DD_CRASH_MODE "noop" CACHE STRING "")

Symbolication

To get human-readable function names and line numbers in your crash reports, upload your application’s debug symbols to Datadog. See RUM Debug Symbols for setup instructions.

Test your implementation

To verify that crash reporting is working:

  1. Run your application with crash reporting enabled.
  2. Trigger a crash. The simplest way is to use a direct system call:
#include <signal.h>
raise(SIGSEGV);
#include <windows.h>
RaiseException(EXCEPTION_ACCESS_VIOLATION, 0, 0, NULL);
  1. Relaunch the application. The crash report is uploaded during the next launch.
  2. After a few seconds, navigate to Error Tracking in Datadog to confirm the crash report appears.

Further Reading