2020-05-07 20:31:26 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jeremy Apthorp <jeremya@chromium.org>
|
|
|
|
Date: Thu, 30 Apr 2020 10:08:06 -0700
|
|
|
|
Subject: crash: allow setting more options
|
|
|
|
|
|
|
|
This allows the client of //components/crash to set upload url,
|
|
|
|
rate-limiting, compression and global annotations.
|
|
|
|
|
|
|
|
This should be upstreamed.
|
|
|
|
|
|
|
|
diff --git a/components/crash/core/app/breakpad_linux.cc b/components/crash/core/app/breakpad_linux.cc
|
2020-12-14 18:57:36 +00:00
|
|
|
index 9e850c0380b8a856dace5f68c80dd11a5b95a671..76993a9ec8dcd6c69cf3e58c49838264783a06c9 100644
|
2020-05-07 20:31:26 +00:00
|
|
|
--- a/components/crash/core/app/breakpad_linux.cc
|
|
|
|
+++ b/components/crash/core/app/breakpad_linux.cc
|
2020-12-14 18:57:36 +00:00
|
|
|
@@ -111,6 +111,7 @@ void SetUploadURL(const std::string& url) {
|
2020-05-15 03:09:02 +00:00
|
|
|
}
|
2020-05-07 20:31:26 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
+bool g_is_node = false;
|
|
|
|
bool g_is_crash_reporter_enabled = false;
|
|
|
|
uint64_t g_process_start_time = 0;
|
|
|
|
pid_t g_pid = 0;
|
|
|
|
diff --git a/components/crash/core/app/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
|
2020-09-21 08:00:36 +00:00
|
|
|
index 1d0fb4f2a633fa5ddbe232ce19d716c22be78a37..5b81608d6e90f62f435302a53976fb18bbbf9e98 100644
|
2020-05-07 20:31:26 +00:00
|
|
|
--- a/components/crash/core/app/crash_reporter_client.cc
|
|
|
|
+++ b/components/crash/core/app/crash_reporter_client.cc
|
2020-08-12 18:33:58 +00:00
|
|
|
@@ -140,6 +140,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
|
2020-05-07 20:31:26 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
+bool CrashReporterClient::GetShouldRateLimit() {
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool CrashReporterClient::GetShouldCompressUploads() {
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void CrashReporterClient::GetProcessSimpleAnnotations(std::map<std::string, std::string>* annotations) {
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
#if defined(OS_ANDROID)
|
|
|
|
unsigned int CrashReporterClient::GetCrashDumpPercentage() {
|
|
|
|
return 100;
|
|
|
|
diff --git a/components/crash/core/app/crash_reporter_client.h b/components/crash/core/app/crash_reporter_client.h
|
2020-09-21 08:00:36 +00:00
|
|
|
index aaa9ad1d58d7f584cbf391e0cb0a61a0d25d5c69..5b02834b5ecaf4bcb7e051d9ee98cd5eb087b4fc 100644
|
2020-05-07 20:31:26 +00:00
|
|
|
--- a/components/crash/core/app/crash_reporter_client.h
|
|
|
|
+++ b/components/crash/core/app/crash_reporter_client.h
|
|
|
|
@@ -5,6 +5,7 @@
|
|
|
|
#ifndef COMPONENTS_CRASH_CORE_APP_CRASH_REPORTER_CLIENT_H_
|
|
|
|
#define COMPONENTS_CRASH_CORE_APP_CRASH_REPORTER_CLIENT_H_
|
|
|
|
|
|
|
|
+#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "base/strings/string16.h"
|
2020-08-12 18:33:58 +00:00
|
|
|
@@ -145,6 +146,19 @@ class CrashReporterClient {
|
2020-05-07 20:31:26 +00:00
|
|
|
// that case, |breakpad_enabled| is set to the value enforced by policies.
|
|
|
|
virtual bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled);
|
|
|
|
|
|
|
|
+ // Returns true if crash uploads should be rate limited. If false, no
|
|
|
|
+ // throttling will be applied for uploads.
|
|
|
|
+ virtual bool GetShouldRateLimit();
|
|
|
|
+
|
|
|
|
+ // Returns true if crash uploads should be compressed with gzip. If false,
|
|
|
|
+ // reports will be uploaded uncompressed.
|
|
|
|
+ virtual bool GetShouldCompressUploads();
|
|
|
|
+
|
|
|
|
+ // Allows the client to add or edit global annotations passed to the crashpad
|
|
|
|
+ // handler.
|
|
|
|
+ virtual void GetProcessSimpleAnnotations(
|
|
|
|
+ std::map<std::string, std::string>* annotations);
|
|
|
|
+
|
|
|
|
#if defined(OS_ANDROID)
|
|
|
|
// Used by WebView to sample crashes without generating the unwanted dumps. If
|
|
|
|
// the returned value is less than 100, crash dumping will be sampled to that
|
|
|
|
diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
|
2020-11-14 00:16:56 +00:00
|
|
|
index eb675321436a53e82432144d43f258bed6e938e2..ae2032a12eac7c789d790e53857d11ba3e03d510 100644
|
2020-05-07 20:31:26 +00:00
|
|
|
--- a/components/crash/core/app/crashpad_mac.mm
|
|
|
|
+++ b/components/crash/core/app/crashpad_mac.mm
|
2020-11-14 00:16:56 +00:00
|
|
|
@@ -77,6 +77,8 @@
|
2020-05-07 20:31:26 +00:00
|
|
|
} // @autoreleasepool
|
|
|
|
return process_annotations;
|
|
|
|
}();
|
|
|
|
+ CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
|
|
|
|
+ crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
|
|
|
|
return annotations;
|
|
|
|
}
|
|
|
|
|
2020-11-14 00:16:56 +00:00
|
|
|
@@ -147,6 +149,13 @@ void DumpProcessWithoutCrashing(task_t task_port) {
|
2020-05-07 20:31:26 +00:00
|
|
|
|
|
|
|
std::vector<std::string> arguments;
|
|
|
|
|
|
|
|
+ if (!crash_reporter_client->GetShouldRateLimit()) {
|
|
|
|
+ arguments.push_back("--no-rate-limit");
|
|
|
|
+ }
|
|
|
|
+ if (!crash_reporter_client->GetShouldCompressUploads()) {
|
|
|
|
+ arguments.push_back("--no-upload-gzip");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
|
|
|
|
arguments.push_back("--monitor-self");
|
|
|
|
}
|
|
|
|
diff --git a/components/crash/core/app/crashpad_win.cc b/components/crash/core/app/crashpad_win.cc
|
2020-05-15 03:09:02 +00:00
|
|
|
index c199b467ffeb007f3098ccde6879fbd71e9ec9fd..a2007514e799b77fa15cbc178d38594e4d847caa 100644
|
2020-05-07 20:31:26 +00:00
|
|
|
--- a/components/crash/core/app/crashpad_win.cc
|
|
|
|
+++ b/components/crash/core/app/crashpad_win.cc
|
2020-05-15 03:09:02 +00:00
|
|
|
@@ -84,6 +84,7 @@ base::FilePath PlatformCrashpadInitialization(
|
2020-05-07 20:31:26 +00:00
|
|
|
|
|
|
|
std::map<std::string, std::string> process_annotations;
|
|
|
|
GetPlatformCrashpadAnnotations(&process_annotations);
|
|
|
|
+ crash_reporter_client->GetProcessSimpleAnnotations(&process_annotations);
|
|
|
|
|
2020-05-15 03:09:02 +00:00
|
|
|
std::string url = crash_reporter_client->GetUploadUrl();
|
2020-05-07 20:31:26 +00:00
|
|
|
|
2020-05-15 03:09:02 +00:00
|
|
|
@@ -122,6 +123,13 @@ base::FilePath PlatformCrashpadInitialization(
|
2020-05-07 20:31:26 +00:00
|
|
|
|
|
|
|
std::vector<std::string> arguments(start_arguments);
|
|
|
|
|
|
|
|
+ if (!crash_reporter_client->GetShouldRateLimit()) {
|
|
|
|
+ arguments.push_back("--no-rate-limit");
|
|
|
|
+ }
|
|
|
|
+ if (!crash_reporter_client->GetShouldCompressUploads()) {
|
|
|
|
+ arguments.push_back("--no-upload-gzip");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
|
|
|
|
arguments.push_back("--monitor-self");
|
|
|
|
for (const std::string& start_argument : start_arguments) {
|