#pragma once
|
#include <client/crash_report_database.h>
|
#include <client/settings.h>
|
#include <client/crashpad_client.h>
|
#include <tchar.h>
|
#include <iostream>
|
using namespace std;
|
|
|
bool initCrashPad()
|
{
|
|
using namespace crashpad;
|
std::map<std::string, std::string> annotations;
|
std::vector<std::string> arguments;
|
|
annotations["format"] = "minidump"; // Required: Crashpad setting to save crash as a minidump
|
annotations["database"] = "dumps"; // Required: BugSplat database
|
annotations["product"] = "gp";
|
annotations["version"] = "1.0.0";
|
|
|
std::string url("http://127.0.0.1:8000");
|
arguments.push_back("--no-rate-limit");
|
|
//std::string crashDirPath("C:/Program Files (x86)/yeshi/GP/logs/dumps/");
|
//·ÅdumpµÄÎļþ¼Ð °´Ðè¸Ä
|
if (0 != access("C:/Program Files (x86)/yeshi/GP/dumps", 0))
|
{
|
mkdir("C:/Program Files (x86)/yeshi/GP/dumps"); // ·µ»Ø 0 ±íʾ´´½¨³É¹¦£¬-1 ±íʾʧ°Ü
|
}
|
base::FilePath db( _T("C:/Program Files (x86)/yeshi/GP/dumps"));
|
//crashpad_handler.exe °´Ðè¸Ä
|
base::FilePath handler(_T("C:/Program Files (x86)/yeshi/GP/crashpad_handler.exe"));
|
|
std::unique_ptr<CrashReportDatabase> database =
|
crashpad::CrashReportDatabase::Initialize(db);
|
|
if (database == nullptr || database->GetSettings() == NULL)
|
{
|
cout << "CrashReportDatabase Init Error" <<endl;
|
return false;
|
}
|
|
database->GetSettings()->SetUploadsEnabled(TRUE);
|
|
CrashpadClient *client = new CrashpadClient();
|
bool ret = client->StartHandler(handler,
|
db,
|
db,
|
url,
|
annotations,
|
arguments,
|
true,
|
true);
|
if (ret == false)
|
{
|
return false;
|
}
|
|
return true;
|
}
|