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/crash_reporter_client.cc b/components/crash/core/app/crash_reporter_client.cc
|
2022-10-03 20:21:00 +00:00
|
|
|
index 284dd099122df85d2cebf467cdb3a54b45a343eb..bb21ddbd2ee4d2952a4b753a5c553005f8dc46db 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
|
2022-07-20 11:03:34 +00:00
|
|
|
@@ -145,6 +145,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) {
|
|
|
|
+}
|
|
|
|
+
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
2020-05-07 20:31:26 +00:00
|
|
|
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
|
2022-10-03 20:21:00 +00:00
|
|
|
index 9f8f20dfa65068a13ce3b035a7e3ce062d767161..9b45c7276e97253f79f4555ee692687b040afa67 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>
|
|
|
|
|
2021-03-04 17:27:05 +00:00
|
|
|
#include "build/build_config.h"
|
2022-07-20 11:03:34 +00:00
|
|
|
@@ -151,6 +152,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);
|
|
|
|
+
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
2020-05-07 20:31:26 +00:00
|
|
|
// 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
|
2021-07-19 17:11:10 +00:00
|
|
|
diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc
|
2022-10-03 20:21:00 +00:00
|
|
|
index 99efa6b245b9944710b76a342ec9a37947078a48..e55df93f17560a566e1dd2a63c560054edd772a5 100644
|
2021-07-19 17:11:10 +00:00
|
|
|
--- a/components/crash/core/app/crashpad_linux.cc
|
|
|
|
+++ b/components/crash/core/app/crashpad_linux.cc
|
2022-03-25 01:39:03 +00:00
|
|
|
@@ -170,6 +170,7 @@ bool PlatformCrashpadInitialization(
|
2021-07-19 17:11:10 +00:00
|
|
|
// where crash_reporter provides it's own values for lsb-release.
|
|
|
|
annotations["lsb-release"] = base::GetLinuxDistro();
|
|
|
|
#endif
|
|
|
|
+ crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
|
|
|
|
|
|
|
|
std::vector<std::string> arguments;
|
|
|
|
if (crash_reporter_client->ShouldMonitorCrashHandlerExpensively()) {
|
2022-03-25 01:39:03 +00:00
|
|
|
@@ -191,6 +192,13 @@ bool PlatformCrashpadInitialization(
|
2021-07-19 17:11:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+ if (!crash_reporter_client->GetShouldRateLimit()) {
|
|
|
|
+ arguments.push_back("--no-rate-limit");
|
|
|
|
+ }
|
|
|
|
+ if (!crash_reporter_client->GetShouldCompressUploads()) {
|
|
|
|
+ arguments.push_back("--no-upload-gzip");
|
|
|
|
+ }
|
|
|
|
+
|
2022-06-27 20:50:08 +00:00
|
|
|
CHECK(client.StartHandler(handler_path, *database_path, metrics_path, url,
|
|
|
|
annotations, arguments, false, false));
|
|
|
|
} else {
|
2020-05-07 20:31:26 +00:00
|
|
|
diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
|
2022-10-03 20:21:00 +00:00
|
|
|
index cab2c95eee53e6c406d6867b0a6e53a3a9fb5ce3..46935fcbf84cf1472214904cf96b03aa0e57be8f 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
|
2021-05-04 03:13:46 +00:00
|
|
|
@@ -85,6 +85,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;
|
|
|
|
}
|
|
|
|
|
2021-11-24 08:45:59 +00:00
|
|
|
@@ -155,6 +157,13 @@ bool PlatformCrashpadInitialization(
|
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
|
2022-10-03 20:21:00 +00:00
|
|
|
index 9ab5fb1c822752854fc88ba0ee3d24ddca4dd107..11ae602ccc58cb2728911b28d6637079d2dcb359 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
|
2022-07-20 11:03:34 +00:00
|
|
|
@@ -91,6 +91,7 @@ bool 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
|
|
|
|
2022-07-20 11:03:34 +00:00
|
|
|
@@ -129,6 +130,13 @@ bool 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) {
|