【问题标题】:How do I integrate google crashpad with my application?如何将 google crashpad 与我的应用程序集成?
【发布时间】:2014-10-04 08:19:49
【问题描述】:

breakpad 项目将替换为google crashpad 项目。如何将新的崩溃报告器与我在 Mac 上的应用程序集成?

【问题讨论】:

  • 跟踪,我也找不到太多文档...
  • 我也想做同样的事情。我是使用本机代码开发 android 的新手。是否有任何更新或教程可以做到这一点?
  • 我也在尝试这样做。你能集成 crashpad 吗??
  • 我没有再尝试使用 crashpad,但如果有人在使用 crashpad,我当然对教程感兴趣。
  • 前几天我们为此写了一个教程。我从下面的教程中复制了一个 sn-p 作为这个问题的答案。

标签: crash-reports crash-dumps


【解决方案1】:

首先,您需要设置 depot_tools 以构建 Crashpad。

接下来,您必须获得 Crashpad source 的副本。

使用gnninja 构建Crashpad,其中gn 生成构建配置,ninja 执行实际构建。有关如何构建 Crashpad 的完整说明,请参阅here

对于 MacOS,如果要生成小型转储并将它们上传到远程服务器,则需要链接 libclient.alibutil.alibbase.aout/Default/obj/out/Default/gen/util/mach 中的所有 .o 文件。此外,您需要将 crashpad_handler 与您的应用程序一起打包,并确保它在运行时可用。

通过configuring Crashpad 处理程序将Crashpad 与您的应用程序集成,并将其指向能够提取Crashpad 崩溃报告的服务器。

#include "client/crashpad_client.h"
#include "client/crash_report_database.h"
#include "client/settings.h"

#if defined(OS_POSIX)
typedef std::string StringType;
#elif defined(OS_WIN)
typedef std::wstring StringType;
#endif

using namespace base;
using namespace crashpad;
using namespace std;

bool initializeCrashpad(void);
StringType getExecutableDir(void);

bool initializeCrashpad() {
  // Get directory where the exe lives so we can pass a full path to handler, reportsDir and metricsDir
  StringType exeDir = getExecutableDir();

  // Ensure that handler is shipped with your application
  FilePath handler(exeDir + "/path/to/crashpad_handler");

  // Directory where reports will be saved. Important! Must be writable or crashpad_handler will crash.
  FilePath reportsDir(exeDir + "/path/to/crashpad");

  // Directory where metrics will be saved. Important! Must be writable or crashpad_handler will crash.
  FilePath metricsDir(exeDir + "/path/to/crashpad");

  // Configure url with BugSplat’s public fred database. Replace 'fred' with the name of your BugSplat database.
  StringType url = "https://fred.bugsplat.com/post/bp/crash/crashpad.php";

  // Metadata that will be posted to the server with the crash report map
  map<StringType, StringType> annotations;
  annotations["format"] = "minidump";          // Required: Crashpad setting to save crash as a minidump
  annotations["product"] = "myCrashpadCrasher" // Required: BugSplat appName
  annotations["version"] = "1.0.0";            // Required: BugSplat appVersion
  annotations["key"] = "Sample key";           // Optional: BugSplat key field
  annotations["user"] = "fred@bugsplat.com";   // Optional: BugSplat user email
  annotations["list_annotations"] = "Sample comment"; // Optional: BugSplat crash description

  // Disable crashpad rate limiting so that all crashes have dmp files
  vector<StringType> arguments; 
  arguments.push_back("--no-rate-limit");

  // Initialize Crashpad database
  unique_ptr<CrashReportDatabase> database = CrashReportDatabase::Initialize(reportsDir);
  if (database == NULL) return false;

  // Enable automated crash uploads
  Settings *settings = database->GetSettings();
  if (settings == NULL) return false;
  settings->SetUploadsEnabled(true);

  // Start crash handler
  CrashpadClient *client = new CrashpadClient();
  bool status = client->StartHandler(handler, reportsDir, metricsDir, url, annotations, arguments, true, true);
  return status;
}

您还需要使用dump_syms 生成符号文件。您可以使用symupload 将 sym 文件上传到远程服务器。最后,您可以使用minidump_stackwalk 来表示小型转储。

【讨论】:

    【解决方案2】:

    我刚刚从其中一位开发人员那里得到消息说它还没有准备好...https://groups.google.com/a/chromium.org/forum/#!topic/crashpad-dev/GbS_HcsYzbQ

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      • 2023-03-22
      • 2016-03-18
      • 1970-01-01
      • 1970-01-01
      • 2020-12-08
      • 2018-12-16
      相关资源
      最近更新 更多