Google Breakpad

Learn about Sentry's integration with Google Breakpad.

Breakpad is an open-source multiplatform crash reporting system written in C++ by Google and the predecessor of Crashpad. It supports macOS, Windows and Linux, and features an uploader to submit minidumps to a configured URL right when the process crashes.

Build and integration depend on the target platform. Please refer to Breakpad Integration Overview for official instructions on how to integrate with your program. Generally, you will need to add the Breakpad headers to the include path and then start a platform dependent ExceptionHandler.

For official platform documentation, visit:

First, initialize the ExceptionHandler and pass it a callback that is invoked when a minidump is generated. This can be used to move it to a known location or register it for uploading:

Copied
#include "client/linux/handler/exception_handler.h"

using namespace google_breakpad;

namespace {

bool callback(const MinidumpDescriptor &descriptor,
              void *context,
              bool succeeded) {
    // if succeeded is true, descriptor.path() contains a path
    // to the minidump file. Context is the context passed to
    // the exception handler's constructor.
    return succeeded;
}

}

int main(int argc, char *argv[]) {
    MinidumpDescriptor descriptor("path/to/cache");
    ExceptionHandler eh(
      descriptor,
      /* filter */ nullptr,
      callback,
      /* context */ nullptr,
      /* install handler */ true,
      /* server FD */ -1
    );

    // run your program here
    return 0;
}

Next, implement a minidump upload to Sentry. Since the exception handler callback should perform as little action as possible, this upload is ideally started at the next application start. You can use the HttpUpload class, which is provided as part of the Breakpad client:

Copied
#include <string>
#include "common/linux/http_upload.h"

bool UploadMinidump(std::string &path) {
  // Add additional arguments for Sentry
  std::map<string, string> parameters;

  std::map<string, string> files;
  files["upload_file_minidump"] = path;

  return HTTPUpload::SendRequest(
    "https://o0.ingest.sentry.io/api/0/minidump/?sentry_key=examplePublicKey",
    parameters,
    files,
    /* proxy */ "",
    /* proxy password */ "",
    /* certificate */ "",
    /* response body */ nullptr,
    /* response code */ nullptr,
    /* error */ nullptr
  );
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").