Qt


Qt is a powerful cross platform C++ app development platform. With a few easy steps you can integrate BugSplat crash reporting in your Windows or MacOS Qt application and leverage the most in-depth crash data on the market. Before starting this tutorial please complete the following:

Building Crashpad


BugSplat leverages Crashpad to provide crash reporting for both Windows and MacOS Qt applications. For an in depth guide that discusses how to build Crashpad, please see this article.

For Windows you'll need to build shared libraries. After running gn gen out/Default modify out/Default/toolchain.ninja and add the argument /MDd after the argument ${cflags_c}. Make sure the version of MSVC used to compile Crashpad is the same version used by your Qt build otherwise your project will not build.

For more info on how to build shared libraries for Windows, see this post.

Integrating Crashpad


Once Crashpad has been built you'll need to add the relevant include directories to your project. Copy all of the Crashpad .h files to the directory $$PWD/Crashpad/Include/crashpad where $$PWD is your project's working directory. Add the include directories to your project by pasting the following snippet at the top of your project file:

Next, link your app with the Crashpad libraries. Linking with the Crashpad libraries is platform dependent.

MacOS

Copy libbase.a, libutil.a and libclient.a into $$PWD/Crashpad/Libraries/MacOS. Additionally you'll need to copy all of the .o files from the Crashpad build folder /out/Default/gen/util/mach to the directory $$PWD/Crashpad/Libraries/MacOS/util/mach. Finally, you'll need to link with the system libraries libbsm, AppKit.Framework, and Security.Framework. Add the following snippet to your project file to link with the aformentioned libraries:

Additionally, you'll need ship a copy of the crashpad_handler executable with your application. Copy crashpad_handler to the $$PWD/Crashpad/Bin/MacOS directory. Add the following snippet to the macx section of your project file that copies the MacOS crashpad_handler to your projects build directory.

Windows

Copy base.lib, client.lib and util.lib into $$PWD/Crashpad/Libraries/Windows. Additionally you'll need to link with the system library Advapi32. Add the following snippet to your project file to link with the aformentioned libraries:

Additionally, you'll need ship a copy of the crashpad_handler.exe executable with your application. Copy crashpad_handler.exe to the $$PWD/Crashpad/Bin/Windows directory. Add the following snippet to the win32 section of your project file that copies the Windows crashpad_handler.exe to your projects build directory.

Configuring Crashpad


To enable Crashpad in your application you'll need to configure the Crashpad handler with your BugSplat database, application name and application version.  The following is a Windows and MacOS compatible snippet that will configure the Crashpad handler:

Be sure to update the values for dbName, appName and appVersion to values specific to your application. The Paths class allows you to get platform specific paths for Crashpad and its source can be found here. To configure the paths to crashpad_handler, metricsDir and reportsDir you'll first want to find the location your executable using the sample code below:

Add a call to initializeCrashpad at your application's entry point.

Symbols


In order to get function names and line numbers in your crash reports you will need to generate and upload .sym files to BugSplat. Crashpad .sym files can be generated from a MacOS .dSYM file or a Windows .pdb file. To generate .dSYM or .pdb files add the following to the project file:

MacOS

To generate .sym files you will need to build or locate a copy of dump_syms. Additionally, to upload symbol files to BugSplat you will need to build or locate a copy of symupload. Prebuilt copies of dump_syms and symupload can be found here. Build your project and run dump_syms to generate .sym files:

Upload the generated .sym file by running symupload. Be sure to replace the {{database}}, {{application}} and {{version}} with the values you used in the Configuring Crashpad section:

After each release build you'll need to generate and upload .sym files making sure to increment the version number each time. The version number from the Configuring Crashpad section must match the version number in your upload URL.

Windows

The functionality of dump_syms.exe is built into symupload.exe on Windows. Therefore, in order to generate .sym files you will need to build or locate a copy of symupload.exe. A prebuilt copy of symupload.exe can be found here. Additionally, in order to run symupload.exe a copy of msdia140.dll must be present in the same directory as symupload.exe.

Run symupload.exe to upload .sym files to BugSplat. Be sure to replace the {{database}}, {{application}} and {{version}} with the values you used in the Configuring Crashpad section:

After each release build you'll need to generate and upload .sym files making sure to increment the version number each time. The version number from the Configuring Crashpad section must match the version number in your upload URL.

Generating a Crash Report


Force a crash in your application after Crashpad has been initialized:

After you've submitted a crash report, navigate to the Dashboard page. Click the link in the ID column to see the details of your crash report. The following image is from our sample myQtCrasher application:

BugSplat qt crash