Backtrace-Crashpad 0.0.1

Backtrace-Crashpad 0.0.1

Maintained by Rick Foster.



  • By
  • Backtrace I/O

Backtrace-Crashpad

Backtrace's binary package for Crashpad with modifications provided by Backtrace I/O.

Crashpad

Crashpad is a crash-reporting system.

Documentation

Source Code

Crashpad’s source code is hosted in a Git repository at https://chromium.googlesource.com/crashpad/crashpad.

Other Links

Installation

via CocoaPods

To use CocoaPods just add this to your Podfile:

pod 'Backtrace-Crashpad'

Note: It is required to specify use_frameworks! in your Podfile.

Sample usage

#include <iostream>
#include <base/files/file_path.h>
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_client.h>

void startCrashpad() {

std::map<std::string, std::string> annotations;
annotations["format"] = "minidump";
annotations["token"] = "<BACKTRACE_TOKEN>";
std::vector<std::string> arguments;
CrashpadClient client;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
std::unique_ptr<CrashReportDatabase> database = CrashReportDatabase::Initialize(base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]});
database->GetSettings()->SetUploadsEnabled(true);
NSString *crashpadHandlerPath = [[NSBundle mainBundle] pathForResource: @"crashpad_handler" ofType: @""];
arguments.push_back("--no-rate-limit");
client.StartHandler(base::FilePath{[crashpadHandlerPath cStringUsingEncoding: NSUTF8StringEncoding]},
                    base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]},
                    base::FilePath{[[docsPath stringByAppendingString:@"/crashpad_db"] cStringUsingEncoding: NSUTF8StringEncoding]},
                    "https://team.sp.backtrace.io:6098/post",
                    annotations,
                    arguments,
                    true,
                    true);

// Crash the app
DoTheImpossible();
}

Known limitations

This package currently does not support distributing macOS app through the Mac App Store, because App Sandbox capability needs to be disabled.