How do I integrate google crashpad with my application?
Asked Answered
M

2

5

The breakpad project will be replaced by the google crashpad project. How do I integrate the new crash reporter with my application on Mac?

Madox answered 4/10, 2014 at 8:19 Comment(5)
tracking, I also cannot find much documentation...Scrivings
I wanted to do the same. I am new to developing android with native code. Is there any update or a tutorial to do the same?Konrad
I am also trying to do that. Were you able to integrate crashpad??Whop
I have not made any more attempts to use crashpad but I am certainly interested in a tutorial if some one is using crashpad.Madox
We wrote a tutorial for this the other day. I have copied a snippet from the tutorial below as an answer to this question.Breazeale
B
11

First, configure depot_tools to build Crashpad.

Next, acquire a copy of the Crashpad source.

Build Crashpad with gn and ninja, where gn generates a build configuration, and ninja does the actual building. Full instructions on how to build Crashpad are available here.

For MacOS, you will need to link against libclient.a, libutil.a, libbase.a, libcommon.a, and libmig_output.a if you want to generate minidumps and upload them to a remote server. Additionally, you'll need to package crashpad_handler with your application and ensure it is available at runtime.

Integrate Crashpad with your application by configuring the Crashpad handler and point it at a server capable of ingesting Crashpad crash reports.

#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"] = "[email protected]";   // 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;
}

You'll also need to generate sym files using dump_syms. You can upload sym files to a remote server using symupload. Finally, you can symbolicate the minidump using minidump_stackwalk.

Breazeale answered 6/5, 2020 at 22:35 Comment(1)
All of your links are broken.Peru
S
0

I have just got word from one of the devs that its not ready yet...https://groups.google.com/a/chromium.org/forum/#!topic/crashpad-dev/GbS_HcsYzbQ

Scrivings answered 11/11, 2014 at 20:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.