githubEdit

Crashpad

Overview ℹ️

circle-exclamation

Crashpad is the latest open-source crash reporting tool built by Google and is the successor to the popular Breakpad crash reporter. Crashpad allows you to submit minidumps to a configured URL after a crash occurs in your product. Crashpad and Breakpad are 'wire compatible.' The crash reports created by both systems are processed similarly on our backend.

The official Crashpad documentation is available herearrow-up-right.

Build Configuration 🏗️

The first step to integrating Crashpad is to configure your build process. BugSplat provides pre-built versions of Crashpad that are updated monthly. You can find the prebuilt libraries on the Releasesarrow-up-right page in the bugsplat-crashpadarrow-up-right repo. The bugsplat-crashpadarrow-up-right repo also includes scripts that demonstrate how to build Crashpad on Windowsarrow-up-right, macOSarrow-up-right, and Linuxarrow-up-right with Chromium's Depot Toolsarrow-up-right.

We also offer a detailed walkthrough that describes how to build Crashpad from scratch.

Binaries and Libraries

To add Crashpad to your application, you'll need to link with the client , common, util, and base libraries. Additionally, on macOS, you'll need to link with the mig_output library. On all platforms, you'll need to copy crashpad_handler to your build output directory and include it in your installer so that it is available at runtime.

The following example is a snippet from CMakeLists.txtarrow-up-right for Windows - please see our samplearrow-up-right for macOS and Linux.

# Library vars
set(CRASHPAD_LIBRARIES
    ${CRASHPAD_OUT_DIR}/obj/client/client.lib
    ${CRASHPAD_OUT_DIR}/obj/client/common.lib
    ${CRASHPAD_OUT_DIR}/obj/util/util.lib
    ${CRASHPAD_OUT_DIR}/obj/third_party/mini_chromium/mini_chromium/base/base.lib
)

# Handler var
set(CRASHPAD_HANDLER ${CRASHPAD_OUT_DIR}/crashpad_handler.exe)

# Link crashpad libs
target_link_libraries(MyCMakeCrasher ${CRASHPAD_LIBRARIES})

# Copy handler exe
add_custom_command(TARGET MyCMakeCrasher POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy
    ${CRASHPAD_HANDLER}
    ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_CONFIG_DIR}/crashpad_handler${CMAKE_EXECUTABLE_SUFFIX}
)

Include Directories

You'll also need to add a few Crashpad directories to your app's includes list.

Code Integration 🧑‍💻

The bugsplat-crashpadarrow-up-right repo provides a my-cmake-crasherarrow-up-right sample application that demonstrates how to configure Crashpad. The following code snippets are from the my-cmake-crasher examplearrow-up-right.

Includes and Namespaces

Add the following:

Initialization

Copy the initializeCrashpad and getExecutableDir methods from the BugSplat sample. The Crashpad url and parameters format, database, product and version are required to upload crash reports to BugSplat. You can optionally specify values for the parameters user, list_annotations, and key which will be tracked with each crash report.

The following snippet is for Windows. Please see my-cmake-crasherarrow-up-right for macOS, and Linux compatible code changes.

Call initializeCrashpad using parameters specific to your application for dbName, appName, and appVersion.

Attributes

BugSplat will parse the annotations fields as attributes that can be configured as searchable columns within the BugSplat web app. For more information, please refer to the Crash Attributes documentation.

Symbol Uploads 🗺️

You will need to generate and upload .sym files to BugSplat to generate function names and line numbers in the stack traces of your crash reports. BugSplat's symbol-uploadarrow-up-right tool can be used conveniently to generate and upload .sym files with a single terminal command. Download a copy of symbol-upload from GitHubarrow-up-right or install it via npmarrow-up-right.

Once you have symbol-upload downloaded or installed, modify the following command to suit your needs.

Testing 🧪

Trigger a crash in your application. The crash report should be available immediately on the BugSplat website. Click on the link in the ID column. If everything worked correctly, you should see something that resembles the following.

BugSplat Crash Details Page

Additional Considerations 🤔

Databases

The BugSplat database for your crash reports is created on the Manage Databasearrow-up-right page in Settings. Typically, you will create a new database for each major release of your product.

Optimizations

Compiler optimizations can cause a mismatch between the line numbers in crash reports and the actual line numbers in your code. BugSplat recommends turning off compiler optimizations to ensure that the line numbers in your crash reports match the line numbers in your code. To turn off optimizations in Visual Studio, right-click your project and navigate to Properties > C/C++ > Optimization > Optimization, and set the value to Disabled (/Od).

Last updated

Was this helpful?