Backtrace-Crashpad 0.0.1

Backtrace-Crashpad 0.0.1

Rick Foster维护。



  • Backtrace I/O

Backtrace-Crashpad

BacktraceCrashpad提供的二进制软件包,经Backtrace I/O修改。

Crashpad

Crashpad是一项崩溃报告系统。

文档

源代码

Crashpad的源代码存储在https://chromium.googlesource.com/crashpad/crashpad的Git仓库中。

其他链接

安装

通过CocoaPods

要使用CocoaPods,只需将其添加到您的Podfile中

pod 'Backtrace-Crashpad'

注意:在Podfile中需要指定use_frameworks!

示例用法

#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();
}

已知限制

该包目前不支持通过Mac App Store分发macOS应用程序,因为需要禁用App Sandbox功能