2020-05-07 13:31:26 -07: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
|
2024-11-25 10:45:47 -05:00
|
|
|
index b6a2910848c66489e70acdce6e09237bf6188f94..744cca2d1b8856719b9ae5aed6c443e8752da75e 100644
|
2020-05-07 13:31:26 -07:00
|
|
|
--- a/components/crash/core/app/crash_reporter_client.cc
|
|
|
|
|
+++ b/components/crash/core/app/crash_reporter_client.cc
|
2024-11-19 19:52:20 -08:00
|
|
|
@@ -119,6 +119,17 @@ bool CrashReporterClient::ReportingIsEnforcedByPolicy(bool* breakpad_enabled) {
|
2020-05-07 13:31:26 -07: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-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
2020-05-07 13:31:26 -07: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
|
2024-11-25 10:45:47 -05:00
|
|
|
index 7c890b331be4aaaf20c7efe8a4bcc2f6e9012b7a..c573524d05c07ec67d35046bc8548cc1dfdd0df3 100644
|
2020-05-07 13:31:26 -07:00
|
|
|
--- a/components/crash/core/app/crash_reporter_client.h
|
|
|
|
|
+++ b/components/crash/core/app/crash_reporter_client.h
|
2023-04-12 18:10:31 -07:00
|
|
|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2020-05-07 13:31:26 -07:00
|
|
|
|
|
|
|
|
+#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2021-03-04 09:27:05 -08:00
|
|
|
#include "build/build_config.h"
|
2024-11-25 10:45:47 -05:00
|
|
|
@@ -141,6 +142,19 @@ class CrashReporterClient {
|
2020-05-07 13:31:26 -07: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-09 18:58:52 -08:00
|
|
|
#if BUILDFLAG(IS_ANDROID)
|
2020-05-07 13:31:26 -07: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 10:11:10 -07:00
|
|
|
diff --git a/components/crash/core/app/crashpad_linux.cc b/components/crash/core/app/crashpad_linux.cc
|
2025-10-14 11:25:30 -04:00
|
|
|
index d4d3555891b19d61676465c856055fb04e0168bc..3228888f5449df723f4385a0f2c9b456caa472f0 100644
|
2021-07-19 10:11:10 -07:00
|
|
|
--- a/components/crash/core/app/crashpad_linux.cc
|
|
|
|
|
+++ b/components/crash/core/app/crashpad_linux.cc
|
2025-10-14 11:25:30 -04:00
|
|
|
@@ -219,6 +219,7 @@ bool PlatformCrashpadInitialization(
|
2021-07-19 10:11:10 -07: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()) {
|
2025-10-14 11:25:30 -04:00
|
|
|
@@ -240,6 +241,13 @@ bool PlatformCrashpadInitialization(
|
2021-07-19 10:11:10 -07: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 15:50:08 -05:00
|
|
|
CHECK(client.StartHandler(handler_path, *database_path, metrics_path, url,
|
2025-10-14 11:25:30 -04:00
|
|
|
annotations, arguments, false, false,
|
|
|
|
|
attachments));
|
2020-05-07 13:31:26 -07:00
|
|
|
diff --git a/components/crash/core/app/crashpad_mac.mm b/components/crash/core/app/crashpad_mac.mm
|
2025-10-14 11:25:30 -04:00
|
|
|
index 3b131e1fc804a55c80b3b2704686270211fcf9fb..f14ab66f240a236bd90ff4240089a0036ce7d460 100644
|
2020-05-07 13:31:26 -07:00
|
|
|
--- a/components/crash/core/app/crashpad_mac.mm
|
|
|
|
|
+++ b/components/crash/core/app/crashpad_mac.mm
|
2024-06-07 17:18:35 -04:00
|
|
|
@@ -86,6 +86,8 @@
|
2020-05-07 13:31:26 -07:00
|
|
|
} // @autoreleasepool
|
|
|
|
|
return process_annotations;
|
|
|
|
|
}();
|
|
|
|
|
+ CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
|
|
|
|
|
+ crash_reporter_client->GetProcessSimpleAnnotations(&annotations);
|
|
|
|
|
return annotations;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-14 11:25:30 -04:00
|
|
|
@@ -159,6 +161,13 @@ bool PlatformCrashpadInitialization(
|
2020-05-07 13:31:26 -07: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
|
2025-10-14 11:25:30 -04:00
|
|
|
index a7af39181e259b4c793fa9a39cb95e4f86ac47d1..6101018813315074a1e06bea318ecf3f91188415 100644
|
2020-05-07 13:31:26 -07:00
|
|
|
--- a/components/crash/core/app/crashpad_win.cc
|
|
|
|
|
+++ b/components/crash/core/app/crashpad_win.cc
|
2025-10-14 11:25:30 -04:00
|
|
|
@@ -94,6 +94,7 @@ bool PlatformCrashpadInitialization(
|
2020-05-07 13:31:26 -07:00
|
|
|
|
|
|
|
|
std::map<std::string, std::string> process_annotations;
|
|
|
|
|
GetPlatformCrashpadAnnotations(&process_annotations);
|
|
|
|
|
+ crash_reporter_client->GetProcessSimpleAnnotations(&process_annotations);
|
|
|
|
|
|
2020-05-14 20:09:02 -07:00
|
|
|
std::string url = crash_reporter_client->GetUploadUrl();
|
2020-05-07 13:31:26 -07:00
|
|
|
|
2025-10-14 11:25:30 -04:00
|
|
|
@@ -134,6 +135,13 @@ bool PlatformCrashpadInitialization(
|
2020-05-07 13:31:26 -07: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) {
|